public class Arrays extends GroupFormatUtil
DEFAULT_END, DEFAULT_START, ELEMENT_SEPARATOR_WITH_NEWLINE
Modifier and Type | Method and Description |
---|---|
static <T> T[] |
array(T... values)
Returns an array containing the given arguments.
|
static String |
format(Representation representation,
Object o)
Returns the
String representation of the given array, or null if the given object is either
null or not an array. |
static <T> boolean |
hasOnlyNullElements(T[] array)
Returns
true if the given array has only null elements, false otherwise. |
static boolean |
isArray(Object o)
Indicates whether the given object is not
null and is an array. |
static <T> boolean |
isNullOrEmpty(T[] array)
Indicates whether the given array is
null or empty. |
static <T> List<T> |
nonNullElementsIn(T[] array)
Returns all the non-
null elements in the given array. |
setMaxLengthForSingleLineDescription
public static boolean isArray(Object o)
null
and is an array.o
- the given object.true
if the given object is not null
and is an array, otherwise false
.public static <T> boolean isNullOrEmpty(T[] array)
null
or empty.T
- the type of elements of the array.array
- the array to check.true
if the given array is null
or empty, otherwise false
.@SafeVarargs public static <T> T[] array(T... values)
T
- the type of the array to return.values
- the values to store in the array.public static <T> List<T> nonNullElementsIn(T[] array)
null
elements in the given array.T
- the type of elements of the array.array
- the given array.null
elements in the given array. An empty list is returned if the given array is
null
.public static <T> boolean hasOnlyNullElements(T[] array)
true
if the given array has only null
elements, false
otherwise. If given array is
empty, this method returns true
.T
- the type of elements of the array.array
- the given array. It must not be null.true
if the given array has only null
elements or is empty, false
otherwise.NullPointerException
- if the given array is null
.public static String format(Representation representation, Object o)
String
representation of the given array, or null
if the given object is either
null
or not an array. This method supports arrays having other arrays as elements.representation
- array
- the object that is expected to be an array.String
representation of the given array.Copyright © 2014–2016 AssertJ. All rights reserved.