public class Arrays extends GroupFormatUtil
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
NULL |
DEFAULT_END, DEFAULT_START, ELEMENT_SEPARATOR, ELEMENT_SEPARATOR_WITH_NEWLINE, INDENTATION_AFTER_NEWLINE, INDENTATION_FOR_SINGLE_LINE, maxLengthForSingleLineDescription
Modifier | Constructor and Description |
---|---|
private |
Arrays() |
Modifier and Type | Method and Description |
---|---|
static <T> T[] |
array(T... values)
Returns an array containing the given arguments.
|
private static boolean |
doesDescriptionFitOnSingleLine(java.lang.String singleLineDescription) |
static java.lang.String |
format(Representation representation,
java.lang.Object o)
Returns the
String representation of the given array, or null if the given object is either
null or not an array. |
private static java.lang.String |
format(Representation representation,
java.lang.Object[] array,
java.lang.String elementSeparator,
java.lang.String indentation,
java.util.Set<java.lang.Object[]> alreadyFormatted) |
private static java.lang.String |
formatPrimitiveArray(Representation representation,
java.lang.Object o) |
static <T> boolean |
hasOnlyNullElements(T[] array)
Returns
true if the given array has only null elements, false otherwise. |
static boolean |
isArray(java.lang.Object o)
Indicates whether the given object is not
null and is an array. |
private static boolean |
isArrayTypePrimitive(java.lang.Object o) |
private static <T> boolean |
isEmpty(T[] array) |
static <T> boolean |
isNullOrEmpty(T[] array)
Indicates whether the given array is
null or empty. |
private static boolean |
isObjectArray(java.lang.Object o) |
private static java.lang.String |
multiLineFormat(Representation representation,
java.lang.Object[] iterable,
java.util.Set<java.lang.Object[]> alreadyFormatted) |
static <T> java.util.List<T> |
nonNullElementsIn(T[] array)
Returns all the non-
null elements in the given array. |
(package private) static java.lang.IllegalArgumentException |
notAnArrayOfPrimitives(java.lang.Object o) |
private static java.lang.String |
singleLineFormat(Representation representation,
java.lang.Object[] iterable,
java.lang.String start,
java.lang.String end,
java.util.Set<java.lang.Object[]> alreadyFormatted) |
private static java.lang.String |
smartFormat(Representation representation,
java.lang.Object[] iterable) |
setMaxLengthForSingleLineDescription
private static final java.lang.String NULL
public static boolean isArray(java.lang.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> java.util.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.java.lang.NullPointerException
- if the given array is null
.public static java.lang.String format(Representation representation, java.lang.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.private static <T> boolean isEmpty(T[] array)
private static boolean isObjectArray(java.lang.Object o)
private static boolean isArrayTypePrimitive(java.lang.Object o)
static java.lang.IllegalArgumentException notAnArrayOfPrimitives(java.lang.Object o)
private static java.lang.String smartFormat(Representation representation, java.lang.Object[] iterable)
private static java.lang.String singleLineFormat(Representation representation, java.lang.Object[] iterable, java.lang.String start, java.lang.String end, java.util.Set<java.lang.Object[]> alreadyFormatted)
private static java.lang.String multiLineFormat(Representation representation, java.lang.Object[] iterable, java.util.Set<java.lang.Object[]> alreadyFormatted)
private static boolean doesDescriptionFitOnSingleLine(java.lang.String singleLineDescription)
private static java.lang.String format(Representation representation, java.lang.Object[] array, java.lang.String elementSeparator, java.lang.String indentation, java.util.Set<java.lang.Object[]> alreadyFormatted)
private static java.lang.String formatPrimitiveArray(Representation representation, java.lang.Object o)