org.assertj.core.util
Class Iterables

java.lang.Object
  extended by org.assertj.core.util.Iterables

public final class Iterables
extends Object

Utility methods related to Iterables.

Author:
Yvonne Wang, Alex Ruiz, Joel Costigliola

Method Summary
static boolean isNullOrEmpty(Iterable<?> iterable)
          Indicates whether the given Iterable is null or empty.
static
<T> List<T>
nonNullElementsIn(Iterable<? extends T> i)
          Returns all the non-null elements in the given Iterable.
static int sizeOf(Iterable<?> iterable)
          Returns the size of the given Iterable.
static
<T> T[]
toArray(Iterable<? extends T> iterable)
          Create an array from an Iterable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isNullOrEmpty

public static boolean isNullOrEmpty(Iterable<?> iterable)
Indicates whether the given Iterable is null or empty.

Parameters:
iterable - the given Iterable to check.
Returns:
true if the given Iterable is null or empty, otherwise false.

sizeOf

public static int sizeOf(Iterable<?> iterable)
Returns the size of the given Iterable.

Parameters:
iterable - the Iterable to get size.
Returns:
the size of the given Iterable.
Throws:
NullPointerException - if given Iterable is null.

nonNullElementsIn

public static <T> List<T> nonNullElementsIn(Iterable<? extends T> i)
Returns all the non-null elements in the given Iterable.

Type Parameters:
T - the type of elements of the Iterable.
Parameters:
i - the given Iterable.
Returns:
all the non-null elements in the given Iterable. An empty list is returned if the given Iterable is null.
Since:
1.1.3

toArray

public static <T> T[] toArray(Iterable<? extends T> iterable)
Create an array from an Iterable.

Type Parameters:
T - the type of elements of the Iterable.
Parameters:
iterable - an Iterable to translate in an array.
Returns:
all the elements from the given Iterable in an array. null if given Iterable is null.


Copyright © 2013–2015 AssertJ. All rights reserved.