Skip to content

Commit

Permalink
add javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
h908714124 committed Jul 19, 2021
1 parent 19253b7 commit 6548c10
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/java/io/jbock/util/Either.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,20 @@ public static <L, R> Either<L, R> right(R value) {
* If the provided list is empty, returns an empty {@link Optional}.
* Otherwise, returns an {@code Optional} containing the list.
*
* @param failures a failures
* @param <L> the type of the members of the failures
* @return an {@code Optional} which is empty if and only if {@code failures}
* <p>This utility method can sometimes be used to express a
* {@link #filter(Function)} operation more efficiently.
*
* @param values a list of objects
* @param <T> the type of the members of {@code values}
* @return an {@code Optional} which is empty if and only if {@code values}
* is empty
*/
public static <L> Optional<List<L>> optionalList(List<? extends L> failures) {
if (failures.isEmpty()) {
public static <T> Optional<List<T>> optionalList(List<? extends T> values) {
if (values.isEmpty()) {
return Optional.empty();
}
@SuppressWarnings("unchecked")
List<L> result = (List<L>) failures;
List<T> result = (List<T>) values;
return Optional.of(result);
}

Expand Down

0 comments on commit 6548c10

Please sign in to comment.