Package org.atlanmod.commons.collect
Class MoreIterables
- java.lang.Object
-
- org.atlanmod.commons.collect.MoreIterables
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E> Optional<E>firstElement(Iterable<E> iterable)Returns the first element contained initerable.static booleanisEmpty(Iterable<?> iterable)Determines if the giveniterablecontains no element.static booleannotEmpty(Iterable<?> iterable)Determines if the giveniterablecontains at least one element.static <E> Optional<E>onlyElement(Iterable<E> iterable)Returns the single element contained initerable.static <E> Stream<E>parallelStream(Iterable<E> iterable)Returns a parallelStreamof the contents ofiterable.static <E> Stream<E>stream(Iterable<E> iterable)Returns a sequentialStreamof the contents ofiterable.
-
-
-
Method Detail
-
stream
@Nonnull public static <E> Stream<E> stream(@Nullable Iterable<E> iterable)
Returns a sequentialStreamof the contents ofiterable.- Parameters:
iterable- the iterable- Returns:
- a sequential
Streamof the contents ofiterable
-
parallelStream
@Nonnull public static <E> Stream<E> parallelStream(@Nullable Iterable<E> iterable)
Returns a parallelStreamof the contents ofiterable.- Parameters:
iterable- the iterable- Returns:
- a parallel
Streamof the contents ofiterable
-
isEmpty
public static boolean isEmpty(Iterable<?> iterable)
Determines if the giveniterablecontains no element.- Parameters:
iterable- the iterable- Returns:
trueif the iterable contains no element
-
notEmpty
public static boolean notEmpty(Iterable<?> iterable)
Determines if the giveniterablecontains at least one element.- Parameters:
iterable- the iterable- Returns:
trueif the iterable contains at least one element
-
onlyElement
@Nonnull public static <E> Optional<E> onlyElement(Iterable<E> iterable)
Returns the single element contained initerable.- Parameters:
iterable- the iterable- Returns:
- an
Optionalcontaining the single element of theiterable, orOptional.empty()if theiterableis empty. - Throws:
IllegalArgumentException- if theiterablecontains more than one element
-
firstElement
@Nonnull public static <E> Optional<E> firstElement(Iterable<E> iterable)
Returns the first element contained initerable.- Parameters:
iterable- the iterable- Returns:
- an
Optionalcontaining the first element of theiterable, orOptional.empty()if theiterableis empty. - Throws:
IllegalArgumentException- if theiterablecontains more than one element
-
-