Package org.fest.util
Class Arrays
java.lang.Object
org.fest.util.Arrays
Understands utility methods related to arrays.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T[]array(T... values) Returns an array containing the given arguments.static StringReturns theStringrepresentation of the given array, ornullif the given object is eithernullor not an array.private static <T> booleanhasElements(T[] array) static <T> booleanhasOnlyNullElements(T[] array) Returnstrueif the given array has onlynullelements,falseotherwise.static <T> booleanisEmpty(T[] array) Returnstrueif the given array isnullor empty.static <T> T[]nonNullElements(T[] array) Returns a new array containing the non-null elements of the given array.
-
Field Details
-
formatter
-
-
Constructor Details
-
Arrays
private Arrays()
-
-
Method Details
-
isEmpty
public static <T> boolean isEmpty(T[] array) Returnstrueif 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
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.
-
nonNullElements
public static <T> T[] nonNullElements(T[] array) Returns a new array containing the non-null elements of the given array. This method returns an empty array if the given array has onlynullelements or if it is empty. This method returnsnullif the given array isnull.- Type Parameters:
T- the type of elements of the array.- Parameters:
array- the array we want to extract the non-null elements from.- Returns:
- a new array containing the non-null elements of the given array, or
nullif 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:
NullPointerException- if the given array isnull.- Since:
- 1.1.3
-
hasElements
private static <T> boolean hasElements(T[] array)
-