Package org.assertj.core.util
Class IterableUtil
java.lang.Object
org.assertj.core.util.IterableUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisNullOrEmpty(Iterable<?> iterable) Indicates whether the givenIterableisnullor empty.static <T> Iterable<T> iterable(T... elements) static <T> Iterator<T> iterator(T... elements) static <T> List<T> nonNullElementsIn(Iterable<? extends T> i) Returns all the non-nullelements in the givenIterable.static intReturns the size of the givenIterable.static <T> T[]Create an array from anIterable.static <T> T[]Create an typed array from anIterable.static <T> Collection<T> toCollection(Iterable<T> iterable)
-
Method Details
-
isNullOrEmpty
Indicates whether the givenIterableisnullor empty.- Parameters:
iterable- the givenIterableto check.- Returns:
trueif the givenIterableisnullor empty, otherwisefalse.
-
sizeOf
Returns the size of the givenIterable.- Parameters:
iterable- theIterableto get size.- Returns:
- the size of the given
Iterable. - Throws:
NullPointerException- if givenIterableis null.
-
nonNullElementsIn
Returns all the non-nullelements in the givenIterable.- Type Parameters:
T- the type of elements of theIterable.- Parameters:
i- the givenIterable.- Returns:
- all the non-
nullelements in the givenIterable. An empty list is returned if the givenIterableisnull.
-
toArray
Create an array from anIterable.Note: this method will return Object[]. If you require a typed array please use
toArray(Iterable, Class). It's main usage is to keep the generic type for chaining call like in:public S containsOnlyElementsOf(Iterable<? extends T> iterable) { return containsOnly(toArray(iterable)); } -
toArray
Create an typed array from anIterable. -
toCollection
-
iterable
-
iterator
-