From 7481c89b6b278461e8e656c95274d155a6a3564b Mon Sep 17 00:00:00 2001 From: Glavo Date: Tue, 28 May 2024 06:38:58 +0800 Subject: [PATCH] Delete some deprecated methods --- .../java/kala/collection/base/Iterators.java | 1 - .../collection/base/OrderedTraversable.java | 73 ------------------- .../src/main/java/kala/control/Option.java | 7 -- .../immutable/ImmutableLinkedSeq.java | 2 +- .../kala/collection/mutable/MutableList.java | 12 --- .../mutable/MutableListTestTemplate.java | 20 ++--- 6 files changed, 11 insertions(+), 104 deletions(-) diff --git a/kala-base/src/main/java/kala/collection/base/Iterators.java b/kala-base/src/main/java/kala/collection/base/Iterators.java index da122974..6bb2a648 100644 --- a/kala-base/src/main/java/kala/collection/base/Iterators.java +++ b/kala-base/src/main/java/kala/collection/base/Iterators.java @@ -319,7 +319,6 @@ public static boolean noneMatchWith(@NotNull Iterator it, @N return true; } - @Deprecated public static E first(@NotNull Iterator it) { return it.next(); diff --git a/kala-base/src/main/java/kala/collection/base/OrderedTraversable.java b/kala-base/src/main/java/kala/collection/base/OrderedTraversable.java index f0961af1..43098e22 100644 --- a/kala-base/src/main/java/kala/collection/base/OrderedTraversable.java +++ b/kala-base/src/main/java/kala/collection/base/OrderedTraversable.java @@ -16,7 +16,6 @@ package kala.collection.base; import kala.annotations.DelegateBy; -import kala.annotations.ReplaceWith; import kala.control.Option; import kala.function.CheckedIndexedConsumer; import kala.function.IndexedBiFunction; @@ -115,24 +114,6 @@ default T getFirst() { return isNotEmpty() ? Option.some(getFirst()) : Option.none(); } - @Deprecated - @ReplaceWith("getFirst()") - default T first() { - return getFirst(); - } - - @Deprecated - @ReplaceWith("getFirstOrNull()") - default T firstOrNull() { - return getFirstOrNull(); - } - - @Deprecated - @ReplaceWith("getFirstOption()") - default Option firstOption() { - return getFirstOption(); - } - default T getLast() { return reverseIterator().next(); } @@ -147,60 +128,6 @@ default T getLast() { return isNotEmpty() ? Option.some(getLast()) : Option.none(); } - @Deprecated - @ReplaceWith("getLast()") - default T last() { - return getLast(); - } - - @Deprecated - @ReplaceWith("getLastOrNull()") - default T lastOrNull() { - return getLastOrNull(); - } - - @Deprecated - @ReplaceWith("getLastOption()") - default Option lastOption() { - return getLastOption(); - } - - @Deprecated - @ReplaceWith("findFirst(Predicate)") - default T first(@NotNull Predicate predicate) { - return findFirst(predicate).get(); - } - - @Deprecated - @ReplaceWith("findFirst(Predicate)") - default @Nullable T firstOrNull(@NotNull Predicate predicate) { - return findFirst(predicate).getOrNull(); - } - - @Deprecated - @ReplaceWith("findFirst(Predicate)") - default @NotNull Option firstOption(@NotNull Predicate predicate) { - return findFirst(predicate); - } - - @Deprecated - @ReplaceWith("findLast(Predicate)") - default T last(@NotNull Predicate predicate) { - return findLast(predicate).get(); - } - - @Deprecated - @ReplaceWith("findLast(Predicate)") - default @Nullable T lastOrNull(@NotNull Predicate predicate) { - return findLast(predicate).getOrNull(); - } - - @Deprecated - @ReplaceWith("findLast(Predicate)") - default @NotNull Option lastOption(@NotNull Predicate predicate) { - return findLast(predicate); - } - //endregion //region Search Operations diff --git a/kala-base/src/main/java/kala/control/Option.java b/kala-base/src/main/java/kala/control/Option.java index 570bf554..d543ec23 100644 --- a/kala-base/src/main/java/kala/control/Option.java +++ b/kala-base/src/main/java/kala/control/Option.java @@ -15,7 +15,6 @@ */ package kala.control; -import kala.annotations.ReplaceWith; import kala.collection.base.Iterators; import kala.control.primitive.PrimitiveOption; import kala.tuple.Tuple2; @@ -90,12 +89,6 @@ public static Option narrow(Option option) { return (Option) None; } - @Deprecated - @ReplaceWith("ofNullable(T)") - public static @NotNull Option of(@Nullable T value) { - return value == null ? none() : new Option<>(value); - } - /** * Returns {@code Option.some(value)} if value is not null, otherwise returns {@code Option.none()}. * diff --git a/kala-collection/src/main/java/kala/collection/immutable/ImmutableLinkedSeq.java b/kala-collection/src/main/java/kala/collection/immutable/ImmutableLinkedSeq.java index 31a4abf3..aa1cb251 100644 --- a/kala-collection/src/main/java/kala/collection/immutable/ImmutableLinkedSeq.java +++ b/kala-collection/src/main/java/kala/collection/immutable/ImmutableLinkedSeq.java @@ -833,7 +833,7 @@ public final void replaceAllIndexed(@NotNull IndexedFunction predicate) { + public final boolean retainIf(@NotNull Predicate predicate) { Node prev = null; Node cur = first; if (cur == null) { diff --git a/kala-collection/src/main/java/kala/collection/mutable/MutableList.java b/kala-collection/src/main/java/kala/collection/mutable/MutableList.java index 61304851..62f08916 100644 --- a/kala-collection/src/main/java/kala/collection/mutable/MutableList.java +++ b/kala-collection/src/main/java/kala/collection/mutable/MutableList.java @@ -402,12 +402,6 @@ default boolean removeIf(@NotNull Predicate predicate) { return changed; } - @Deprecated - @ReplaceWith("removeIf(Predicate)") - default boolean removeAll(@NotNull Predicate predicate) { - return removeIf(predicate); - } - @Contract(mutates = "this") default boolean retainIf(@NotNull Predicate predicate) { MutableListIterator it = this.seqIterator(); @@ -422,12 +416,6 @@ default boolean retainIf(@NotNull Predicate predicate) { return changed; } - @Deprecated - @ReplaceWith("retainIf(Predicate)") - default boolean retainAll(@NotNull Predicate predicate) { - return retainIf(predicate); - } - @Contract(mutates = "this") void clear(); diff --git a/src/test/template/kala/collection/mutable/MutableListTestTemplate.java b/src/test/template/kala/collection/mutable/MutableListTestTemplate.java index 251c43e7..2c0a112d 100644 --- a/src/test/template/kala/collection/mutable/MutableListTestTemplate.java +++ b/src/test/template/kala/collection/mutable/MutableListTestTemplate.java @@ -283,36 +283,36 @@ default void removeInRangeTest() { } @Test - default void retainAllTest() { + default void retainIfTest() { final MutableList empty = factory().empty(); - empty.retainAll(e -> true); + empty.retainIf(e -> true); assertIterableEquals(List.of(), empty); - empty.retainAll(e -> false); + empty.retainIf(e -> false); assertIterableEquals(List.of(), empty); final MutableList b1 = of(0, 1, 2, 3, 4, 5); - b1.retainAll(it -> it > 2); + b1.retainIf(it -> it > 2); assertIterableEquals(List.of(3, 4, 5), b1); final MutableList b2 = of(0, 1, 2, 3, 4, 5); - b2.retainAll(it -> it % 2 == 0); + b2.retainIf(it -> it % 2 == 0); assertIterableEquals(List.of(0, 2, 4), b2); } @Test - default void removeAllTest() { + default void removeIfTest() { final MutableList empty = factory().empty(); - empty.removeAll(e -> true); + empty.removeIf(e -> true); assertIterableEquals(List.of(), empty); - empty.removeAll(e -> false); + empty.removeIf(e -> false); assertIterableEquals(List.of(), empty); final MutableList b1 = of(0, 1, 2, 3, 4, 5); - b1.removeAll(it -> it > 2); + b1.removeIf(it -> it > 2); assertIterableEquals(List.of(0, 1, 2), b1); final MutableList b2 = of(0, 1, 2, 3, 4, 5); - b2.removeAll(it -> it % 2 == 0); + b2.removeIf(it -> it % 2 == 0); assertIterableEquals(List.of(1, 3, 5), b2); }