Skip to content

Commit

Permalink
Comparator can be nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
aNNiMON committed Mar 22, 2019
1 parent 5f0d31a commit 6f2a806
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions stream/src/main/java/com/annimon/stream/ComparatorCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static <T extends Comparable<? super T>> ComparatorCompat<T> reverseOrder
* @throws NullPointerException if {@code comparator} is null
*/
@NotNull
public static <T> Comparator<T> reversed(Comparator<T> comparator) {
public static <T> Comparator<T> reversed(@Nullable Comparator<T> comparator) {
return Collections.reverseOrder(comparator);
}

Expand Down Expand Up @@ -243,7 +243,7 @@ public static <T> ComparatorCompat<T> nullsFirst() {
* @return a comparator
*/
@NotNull
public static <T> ComparatorCompat<T> nullsFirst(Comparator<? super T> comparator) {
public static <T> ComparatorCompat<T> nullsFirst(@Nullable Comparator<? super T> comparator) {
return nullsComparator(true, comparator);
}

Expand All @@ -269,7 +269,7 @@ public static <T> ComparatorCompat<T> nullsLast() {
* @return a comparator
*/
@NotNull
public static <T> ComparatorCompat<T> nullsLast(Comparator<? super T> comparator) {
public static <T> ComparatorCompat<T> nullsLast(@Nullable Comparator<? super T> comparator) {
return nullsComparator(false, comparator);
}

Expand Down
2 changes: 1 addition & 1 deletion stream/src/main/java/com/annimon/stream/DoubleStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ public DoubleStream sorted() {
* @return the new {@code DoubleStream}
*/
@NotNull
public DoubleStream sorted(@NotNull Comparator<Double> comparator) {
public DoubleStream sorted(@Nullable Comparator<Double> comparator) {
return boxed().sorted(comparator).mapToDouble(UNBOX_FUNCTION);
}

Expand Down
2 changes: 1 addition & 1 deletion stream/src/main/java/com/annimon/stream/IntStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ public IntStream sorted() {
* @return the new {@code IntStream}
*/
@NotNull
public IntStream sorted(@NotNull Comparator<Integer> comparator) {
public IntStream sorted(@Nullable Comparator<Integer> comparator) {
return boxed().sorted(comparator).mapToInt(UNBOX_FUNCTION);
}

Expand Down
2 changes: 1 addition & 1 deletion stream/src/main/java/com/annimon/stream/LongStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ public LongStream sorted() {
* @return the new {@code LongStream}
*/
@NotNull
public LongStream sorted(@NotNull Comparator<Long> comparator) {
public LongStream sorted(@Nullable Comparator<Long> comparator) {
return boxed().sorted(comparator).mapToLong(UNBOX_FUNCTION);
}

Expand Down
2 changes: 1 addition & 1 deletion stream/src/main/java/com/annimon/stream/Stream.java
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ public int compare(T o1, T o2) {
* @return the new stream
*/
@NotNull
public Stream<T> sorted(@NotNull final Comparator<? super T> comparator) {
public Stream<T> sorted(@Nullable final Comparator<? super T> comparator) {
return new Stream<T>(params, new ObjSorted<T>(iterator, comparator));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Iterator;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class ObjSorted<T> extends LsaExtIterator<T> {

Expand All @@ -16,7 +17,7 @@ public class ObjSorted<T> extends LsaExtIterator<T> {

public ObjSorted(
@NotNull Iterator<? extends T> iterator,
@NotNull Comparator<? super T> comparator) {
@Nullable Comparator<? super T> comparator) {
this.iterator = iterator;
this.comparator = comparator;
}
Expand Down

0 comments on commit 6f2a806

Please sign in to comment.