public final class IterableUtil extends GroupFormatUtil
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isNullOrEmpty(Iterable<?> iterable)
Indicates whether the given
Iterable is null or empty. |
static String |
multiLineFormat(Representation representation,
Iterable<?> iterable) |
static <T> List<T> |
nonNullElementsIn(Iterable<? extends T> i)
Returns all the non-
null elements in the given Iterable. |
static String |
singleLineFormat(Representation representation,
Iterable<?> iterable,
String start,
String end) |
static int |
sizeOf(Iterable<?> iterable)
Returns the size of the given
Iterable. |
static String |
smartFormat(Representation representation,
Iterable<?> iterable)
Returns the
String representation of the given Iterable, or null if the given
Iterable is null. |
static <T> T[] |
toArray(Iterable<? extends T> iterable)
Create an array from an
Iterable. |
static <T> T[] |
toArray(Iterable<? extends T> iterable,
Class<T> type)
Create an typed array from an
Iterable. |
setMaxLengthForSingleLineDescriptionpublic static boolean isNullOrEmpty(Iterable<?> iterable)
Iterable is null or empty.iterable - the given Iterable to check.true if the given Iterable is null or empty, otherwise false.public static int sizeOf(Iterable<?> iterable)
Iterable.iterable - the Iterable to get size.Iterable.NullPointerException - if given Iterable is null.public static <T> List<T> nonNullElementsIn(Iterable<? extends T> i)
null elements in the given Iterable.T - the type of elements of the Iterable.i - the given Iterable.null elements in the given Iterable. An empty list is returned if the given
Iterable is null.public static <T> T[] toArray(Iterable<? extends T> iterable)
Iterable.
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));
}
public static <T> T[] toArray(Iterable<? extends T> iterable, Class<T> type)
Iterable.public static String smartFormat(Representation representation, Iterable<?> iterable)
String representation of the given Iterable, or null if the given
Iterable is null.
The Iterable will be formatted to a single line if it does not exceed 100 char, otherwise each elements
will be formatted on a new line with 4 space indentation.
representation - iterable - the Iterable to format.String representation of the given Iterable.public static String singleLineFormat(Representation representation, Iterable<?> iterable, String start, String end)
public static String multiLineFormat(Representation representation, Iterable<?> iterable)
Copyright © 2013-2015 AssertJ. All Rights Reserved.