Skip to content

Commit

Permalink
Delete some deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo committed May 27, 2024
1 parent 83e1f03 commit 7481c89
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ public static <E, T> boolean noneMatchWith(@NotNull Iterator<? extends E> it, @N
return true;
}


@Deprecated
public static <E> E first(@NotNull Iterator<? extends E> it) {
return it.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<T> firstOption() {
return getFirstOption();
}

default T getLast() {
return reverseIterator().next();
}
Expand All @@ -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<T> lastOption() {
return getLastOption();
}

@Deprecated
@ReplaceWith("findFirst(Predicate<T>)")
default T first(@NotNull Predicate<? super T> predicate) {
return findFirst(predicate).get();
}

@Deprecated
@ReplaceWith("findFirst(Predicate<T>)")
default @Nullable T firstOrNull(@NotNull Predicate<? super T> predicate) {
return findFirst(predicate).getOrNull();
}

@Deprecated
@ReplaceWith("findFirst(Predicate<T>)")
default @NotNull Option<T> firstOption(@NotNull Predicate<? super T> predicate) {
return findFirst(predicate);
}

@Deprecated
@ReplaceWith("findLast(Predicate<T>)")
default T last(@NotNull Predicate<? super T> predicate) {
return findLast(predicate).get();
}

@Deprecated
@ReplaceWith("findLast(Predicate<T>)")
default @Nullable T lastOrNull(@NotNull Predicate<? super T> predicate) {
return findLast(predicate).getOrNull();
}

@Deprecated
@ReplaceWith("findLast(Predicate<T>)")
default @NotNull Option<T> lastOption(@NotNull Predicate<? super T> predicate) {
return findLast(predicate);
}

//endregion

//region Search Operations
Expand Down
7 changes: 0 additions & 7 deletions kala-base/src/main/java/kala/control/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -90,12 +89,6 @@ public static <T> Option<T> narrow(Option<? extends T> option) {
return (Option<T>) None;
}

@Deprecated
@ReplaceWith("ofNullable(T)")
public static <T> @NotNull Option<T> 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()}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ public final void replaceAllIndexed(@NotNull IndexedFunction<? super E, ? extend
}

@Override
public final boolean retainAll(@NotNull Predicate<? super E> predicate) {
public final boolean retainIf(@NotNull Predicate<? super E> predicate) {
Node<E> prev = null;
Node<E> cur = first;
if (cur == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,6 @@ default boolean removeIf(@NotNull Predicate<? super E> predicate) {
return changed;
}

@Deprecated
@ReplaceWith("removeIf(Predicate<E>)")
default boolean removeAll(@NotNull Predicate<? super E> predicate) {
return removeIf(predicate);
}

@Contract(mutates = "this")
default boolean retainIf(@NotNull Predicate<? super E> predicate) {
MutableListIterator<E> it = this.seqIterator();
Expand All @@ -422,12 +416,6 @@ default boolean retainIf(@NotNull Predicate<? super E> predicate) {
return changed;
}

@Deprecated
@ReplaceWith("retainIf(Predicate<E>)")
default boolean retainAll(@NotNull Predicate<? super E> predicate) {
return retainIf(predicate);
}

@Contract(mutates = "this")
void clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer> 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<Integer> 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<Integer> 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<Integer> 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);
}

Expand Down

0 comments on commit 7481c89

Please sign in to comment.