Package org.assertj.core.util
Class IterableUtil
java.lang.Object
org.assertj.core.util.IterableUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isNullOrEmpty
(Iterable<?> iterable) Indicates whether the givenIterable
isnull
or 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-null
elements in the givenIterable
.static int
Returns 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 givenIterable
isnull
or empty.- Parameters:
iterable
- the givenIterable
to check.- Returns:
true
if the givenIterable
isnull
or empty, otherwisefalse
.
-
sizeOf
Returns the size of the givenIterable
.- Parameters:
iterable
- theIterable
to get size.- Returns:
- the size of the given
Iterable
. - Throws:
NullPointerException
- if givenIterable
is null.
-
nonNullElementsIn
Returns all the non-null
elements in the givenIterable
.- Type Parameters:
T
- the type of elements of theIterable
.- Parameters:
i
- the givenIterable
.- Returns:
- all the non-
null
elements in the givenIterable
. An empty list is returned if the givenIterable
isnull
.
-
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
-