Skip to content

Commit 2f159a9

Browse files
author
Grzegorz Piwowarek
committed
RequireNonNull in unchecked()
1 parent 65c1723 commit 2f159a9

10 files changed

+25
-0
lines changed

src/main/java/pl/touk/throwing/ThrowingBiConsumer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ default ThrowingBiFunction<T, U, Void, E> asFunction() {
4040
}
4141

4242
static <T, U, E extends Exception> BiConsumer<T, U> unchecked(ThrowingBiConsumer<T, U, E> consumer) {
43+
Objects.requireNonNull(consumer);
44+
4345
return consumer.unchecked();
4446
}
4547

src/main/java/pl/touk/throwing/ThrowingBiFunction.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ default <V> ThrowingBiFunction<T1, T2, V, E> andThen(final ThrowingFunction<? su
3333
}
3434

3535
static <T1, T2, R, E extends Exception> BiFunction<T1, T2, R> unchecked(ThrowingBiFunction<T1, T2, R, E> function) {
36+
Objects.requireNonNull(function);
37+
3638
return function.unchecked();
3739
}
3840

src/main/java/pl/touk/throwing/ThrowingBiPredicate.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ default ThrowingBiFunction<T, U, Boolean, E> asFunction() {
4646
}
4747

4848
static <T, U, E extends Exception> BiPredicate<T, U> unchecked(ThrowingBiPredicate<T, U, E> predicate) {
49+
Objects.requireNonNull(predicate);
50+
4951
return predicate.unchecked();
5052
}
5153

src/main/java/pl/touk/throwing/ThrowingBinaryOperator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ public interface ThrowingBinaryOperator<T, E extends Exception> extends Throwing
2222

2323
static <T, E extends Exception> ThrowingBinaryOperator<T, E> minBy(Comparator<? super T> comparator) {
2424
Objects.requireNonNull(comparator);
25+
2526
return (a, b) -> comparator.compare(a, b) <= 0 ? a : b;
2627
}
2728

2829
static <T, E extends Exception> ThrowingBinaryOperator<T, E> maxBy(Comparator<? super T> comparator) {
2930
Objects.requireNonNull(comparator);
31+
3032
return (a, b) -> comparator.compare(a, b) >= 0 ? a : b;
3133
}
3234
}

src/main/java/pl/touk/throwing/ThrowingConsumer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ default ThrowingFunction<T, Void, E> asFunction() {
4141
}
4242

4343
static <T, E extends Exception> Consumer<T> unchecked(ThrowingConsumer<T, E> consumer) {
44+
Objects.requireNonNull(consumer);
45+
4446
return consumer.unchecked();
4547
}
4648

src/main/java/pl/touk/throwing/ThrowingFunction.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ default <V> ThrowingFunction<V, R, E> compose(final ThrowingFunction<? super V,
3535

3636
default <V> ThrowingFunction<T, V, E> andThen(final ThrowingFunction<? super R, ? extends V, E> after) {
3737
Objects.requireNonNull(after);
38+
3839
return (T t) -> after.apply(apply(t));
3940
}
4041

@@ -53,6 +54,8 @@ default Function<T, Optional<R>> returningOptional() {
5354
}
5455

5556
static <T, R, E extends Exception> Function<T, R> unchecked(ThrowingFunction<T, R, E> function) {
57+
Objects.requireNonNull(function);
58+
5659
return function.unchecked();
5760
}
5861

src/main/java/pl/touk/throwing/ThrowingPredicate.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ default ThrowingFunction<T, Boolean, E> asFunction() {
5656
}
5757

5858
static <T, E extends Exception> Predicate<T> unchecked(ThrowingPredicate<T, E> predicate) {
59+
Objects.requireNonNull(predicate);
60+
5961
return predicate.unchecked();
6062
}
6163

src/main/java/pl/touk/throwing/ThrowingRunnable.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package pl.touk.throwing;
22

3+
import java.util.Objects;
4+
35
/**
46
* Represents an action that can be performed.
57
* Function might throw a checked exception instance.
@@ -11,6 +13,8 @@ public interface ThrowingRunnable<E extends Exception> {
1113
void run() throws E;
1214

1315
static <E extends Exception> Runnable unchecked(ThrowingRunnable<E> runnable) {
16+
Objects.requireNonNull(runnable);
17+
1418
return runnable.unchecked();
1519
}
1620

src/main/java/pl/touk/throwing/ThrowingSupplier.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package pl.touk.throwing;
22

3+
import java.util.Objects;
34
import java.util.function.Supplier;
45

56
/**
@@ -32,6 +33,8 @@ default ThrowingFunction<Void, T, E> asFunction() {
3233
}
3334

3435
static <T, E extends Exception> Supplier<T> unchecked(ThrowingSupplier<T, E> supplier) {
36+
Objects.requireNonNull(supplier);
37+
3538
return supplier.unchecked();
3639
}
3740

src/main/java/pl/touk/throwing/ThrowingUnaryOperator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package pl.touk.throwing;
22

3+
import java.util.Objects;
34
import java.util.function.UnaryOperator;
45

56
/**
@@ -17,6 +18,8 @@
1718
public interface ThrowingUnaryOperator<T, E extends Exception> extends ThrowingFunction<T, T, E> {
1819

1920
static <T, E extends Exception> UnaryOperator<T> unchecked(ThrowingUnaryOperator<T, E> operator) {
21+
Objects.requireNonNull(operator);
22+
2023
return operator.unchecked();
2124
}
2225

0 commit comments

Comments
 (0)