From 8802be6bbad45336c792d7ee38ac6dd24a704906 Mon Sep 17 00:00:00 2001 From: Glavo Date: Fri, 13 Dec 2024 20:33:06 +0800 Subject: [PATCH] More checked/unchecked methods --- .../kala/collection/base/Traversable.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/kala-base/src/main/java/kala/collection/base/Traversable.java b/kala-base/src/main/java/kala/collection/base/Traversable.java index af8911fb..e0b275de 100644 --- a/kala-base/src/main/java/kala/collection/base/Traversable.java +++ b/kala-base/src/main/java/kala/collection/base/Traversable.java @@ -31,6 +31,7 @@ import kala.tuple.Tuple2; import kala.value.primitive.IntVar; import org.intellij.lang.annotations.Flow; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -182,6 +183,16 @@ default boolean anyMatch(@NotNull Predicate predicate) { return Iterators.anyMatch(iterator(), predicate); } + @ApiStatus.NonExtendable + default boolean anyMatchChecked(@NotNull CheckedPredicate predicate) throws Ex { + return anyMatch(predicate); + } + + @ApiStatus.NonExtendable + default boolean anyMatchUnchecked(@NotNull CheckedPredicate predicate) { + return anyMatch(predicate); + } + /** * Tests whether all elements of this {@code Traversable} match the {@code predicate}. * @@ -192,6 +203,16 @@ default boolean allMatch(@NotNull Predicate predicate) { return Iterators.allMatch(iterator(), predicate); } + @ApiStatus.NonExtendable + default boolean allMatchChecked(@NotNull CheckedPredicate predicate) throws Ex { + return allMatch(predicate); + } + + @ApiStatus.NonExtendable + default boolean allMatchUnchecked(@NotNull CheckedPredicate predicate) { + return allMatch(predicate); + } + /** * Tests whether none elements of this {@code Traversable} match the {@code predicate}. * @@ -202,6 +223,16 @@ default boolean noneMatch(@NotNull Predicate predicate) { return Iterators.noneMatch(iterator(), predicate); } + @ApiStatus.NonExtendable + default boolean noneMatchChecked(@NotNull CheckedPredicate predicate) throws Ex { + return noneMatch(predicate); + } + + @ApiStatus.NonExtendable + default boolean noneMatchUnchecked(@NotNull CheckedPredicate predicate) { + return noneMatch(predicate); + } + /** * Equivalent to {@code this.zip(other).anyMatch(it -> predicate.test(it._1, it._2))} */ @@ -209,6 +240,20 @@ default boolean anyMatchWith(@NotNull Iterable other, @NotNull return Iterators.anyMatchWith(iterator(), other.iterator(), predicate); } + @ApiStatus.NonExtendable + default boolean anyMatchWithChecked( + @NotNull Iterable other, + @NotNull CheckedBiPredicate predicate) throws Ex { + return anyMatchWith(other, predicate); + } + + @ApiStatus.NonExtendable + default boolean anyMatchWithUnchecked( + @NotNull Iterable other, + @NotNull CheckedBiPredicate predicate) { + return anyMatchWith(other, predicate); + } + /** * Equivalent to {@code this.zip(other).allMatch(it -> predicate.test(it._1, it._2))} */ @@ -216,6 +261,20 @@ default boolean allMatchWith(@NotNull Iterable other, @NotNull return Iterators.allMatchWith(iterator(), other.iterator(), predicate); } + @ApiStatus.NonExtendable + default boolean allMatchWithChecked( + @NotNull Iterable other, + @NotNull CheckedBiPredicate predicate) throws Ex { + return allMatchWith(other, predicate); + } + + @ApiStatus.NonExtendable + default boolean allMatchWithUnchecked( + @NotNull Iterable other, + @NotNull CheckedBiPredicate predicate) { + return allMatchWith(other, predicate); + } + /** * Equivalent to {@code this.zip(other).noneMatch(it -> predicate.test(it._1, it._2))} */ @@ -223,6 +282,20 @@ default boolean noneMatchWith(@NotNull Iterable other, @NotNull return Iterators.noneMatchWith(iterator(), other.iterator(), predicate); } + @ApiStatus.NonExtendable + default boolean noneMatchWithChecked( + @NotNull Iterable other, + @NotNull CheckedBiPredicate predicate) throws Ex { + return noneMatchWith(other, predicate); + } + + @ApiStatus.NonExtendable + default boolean noneMatchWithUnchecked( + @NotNull Iterable other, + @NotNull CheckedBiPredicate predicate) { + return noneMatchWith(other, predicate); + } + //endregion @DelegateBy("filterTo(Growable, Predicate)")