Package org.fest.util
Class Arrays
- java.lang.Object
-
- org.fest.util.Arrays
-
public class Arrays extends java.lang.ObjectUtility methods related to arrays.- Author:
- Alex Ruiz, Joel Costigliola
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T[]array(T... values)Returns an array containing the given arguments.static java.lang.Stringformat(java.lang.Object array)Returns theStringrepresentation of the given array, ornullif the given object is eithernullor not an array.static <T> booleanhasOnlyNullElements(T[] array)Returnstrueif the given array has onlynullelements,falseotherwise.static booleanisArray(java.lang.Object o)Indicates whether the given object is notnulland is an array.static <T> booleanisNullOrEmpty(T[] array)Indicates whether the given array isnullor empty.static <T> java.util.List<T>nonNullElementsIn(T[] array)Returns all the non-nullelements in the given array.
-
-
-
Method Detail
-
isArray
public static boolean isArray(java.lang.Object o)
Indicates whether the given object is notnulland is an array.- Parameters:
o- the given object.- Returns:
trueif the given object is notnulland is an array, otherwisefalse.
-
isNullOrEmpty
public static <T> boolean isNullOrEmpty(T[] array)
Indicates whether the given array isnullor empty.- Type Parameters:
T- the type of elements of the array.- Parameters:
array- the array to check.- Returns:
trueif the given array isnullor empty, otherwisefalse.
-
array
public static <T> T[] array(T... values)
Returns an array containing the given arguments.- Type Parameters:
T- the type of the array to return.- Parameters:
values- the values to store in the array.- Returns:
- an array containing the given arguments.
-
format
public static java.lang.String format(java.lang.Object array)
Returns theStringrepresentation of the given array, ornullif the given object is eithernullor not an array. This method supports arrays having other arrays as elements.- Parameters:
array- the object that is expected to be an array.- Returns:
- the
Stringrepresentation of the given array.
-
nonNullElementsIn
public static <T> java.util.List<T> nonNullElementsIn(T[] array)
Returns all the non-nullelements in the given array.- Type Parameters:
T- the type of elements of the array.- Parameters:
array- the given array.- Returns:
- all the non-
nullelements in the given array. An empty list is returned if the given array isnull. - Since:
- 1.1.3
-
hasOnlyNullElements
public static <T> boolean hasOnlyNullElements(T[] array)
Returnstrueif the given array has onlynullelements,falseotherwise. If given array is empty, this method returnstrue.- Type Parameters:
T- the type of elements of the array.- Parameters:
array- the given array. It must not be null.- Returns:
trueif the given array has onlynullelements or is empty,falseotherwise.- Throws:
java.lang.NullPointerException- if the given array isnull.- Since:
- 1.1.3
-
-