Skip to content

Commit 4715df0

Browse files
committed
refactoring
1 parent 04b183f commit 4715df0

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

‎src/main/java/io/jbock/util/Eithers.java‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,9 @@ public final class Eithers {
9393
}
9494

9595
/**
96-
* If the provided list is empty, returns an empty {@link Optional}.
97-
* Otherwise, returns an {@code Optional} containing the nonempty
98-
* input list.
99-
*
100-
* <p>Note: The resulting {@code Optional} might be used in a
101-
* {@link Either#filter(Function) filter} or
102-
* {@link Either#filterLeft(Function) filterLeft} operation.
96+
* If the provided list is empty or null, this method
97+
* returns an empty {@link Optional}. Otherwise it returns
98+
* an {@code Optional} containing the input list.
10399
*
104100
* @see #toOptionalList()
105101
* @param values a list of objects
@@ -108,7 +104,7 @@ public final class Eithers {
108104
* contains a nonempty list
109105
*/
110106
public static <T> Optional<List<T>> optionalList(List<? extends T> values) {
111-
if (values.isEmpty()) {
107+
if (values == null || values.isEmpty()) {
112108
return Optional.empty();
113109
}
114110
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)