Skip to content

Commit

Permalink
Add tests for CollectionUtils#getFirstElement
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed May 1, 2024
1 parent bc80531 commit 9aeec78
Show file tree
Hide file tree
Showing 2 changed files with 252 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static <T> Optional<T> getFirstElement(Collection<T> collection) {
Preconditions.notNull(collection, "collection must not be null");
return collection.isEmpty() //
? Optional.empty() //
: Optional.of(firstElement(collection));
: Optional.ofNullable(firstElement(collection));
}

private static <T> T firstElement(Collection<T> collection) {
Expand Down
Loading

0 comments on commit 9aeec78

Please sign in to comment.