Skip to content

Commit fe9f4df

Browse files
committed
Update Optionals.
1 parent 8c9720b commit fe9f4df

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ var set2 = emptySetOf(Integer.class);
10701070
The `Optionals` class contains methods for working with optional (or "nullable") values:
10711071

10721072
```java
1073-
public static <T> T coalesce(T value, Supplier<T> supplier) { ... }
1073+
public static <T> T coalesce(T value, Supplier<? extends T> supplier) { ... }
10741074
public static <T, U> U map(T value, Function<? super T, ? extends U> transform) { ... }
10751075
public static <T> void perform(T value, Consumer<? super T> action) { ... }
10761076
```

kilo-client/src/main/java/org/httprpc/kilo/util/Optionals.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private Optionals() {
4242
* The provided value, or the value produced by the supplier if the value
4343
* was {@code null}.
4444
*/
45-
public static <T> T coalesce(T value, Supplier<T> supplier) {
45+
public static <T> T coalesce(T value, Supplier<? extends T> supplier) {
4646
if (supplier == null) {
4747
throw new IllegalArgumentException();
4848
}
@@ -74,7 +74,7 @@ public static <T, U> U map(T value, Function<? super T, ? extends U> transform)
7474
throw new IllegalArgumentException();
7575
}
7676

77-
return (value == null) ? null : transform.apply(value);
77+
return (value != null) ? transform.apply(value) : null;
7878
}
7979

8080
/**

0 commit comments

Comments
 (0)