Package io.github.amanzat.util
Class CollectionUtils
java.lang.Object
io.github.amanzat.util.CollectionUtils
Miscellaneous collections related utilities.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionTransforms an iterator into a stream of lists with a maximum size.static <E> Optional<E>Returns an optional containing the first element of the list if any.static booleanisEmpty(Collection<?> collection) Returnstrueif the specified collection is empty,falseotherwise.
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
getFirst
Returns an optional containing the first element of the list if any.- Type Parameters:
E- The list elements type.- Parameters:
list- The list- Returns:
- An optional containing the first element of the list if any
- Implementation Note:
- The optional will be empty if the list is empty or if the fist element is
null.
-
isEmpty
Returnstrueif the specified collection is empty,falseotherwise.- Parameters:
collection- The collection to check- Returns:
trueif the specified collection is empty,falseotherwise.- Implementation Note:
- A
nullcollection is considered empty.
-
chunkify
Transforms an iterator into a stream of lists with a maximum size.- Type Parameters:
T- The element type.- Parameters:
iterator- The iteratorsize- The list (chunk) max size- Returns:
- A stream of lists with the specified maximum size.
- See Also:
-