Package org.assertj.core.util
Class Arrays
java.lang.Object
org.assertj.core.util.Arrays
Utility methods related to arrays.
- Author:
- Alex Ruiz, Joel Costigliola, Florent Biville
-
Method Summary
Modifier and TypeMethodDescriptionstatic int[]array(AtomicIntegerArray atomicIntegerArray) Returns an int[] from theAtomicIntegerArray, null if the given atomic array is null.static long[]array(AtomicLongArray atomicLongArray) Returns an long[] from theAtomicLongArray, null if the given atomic array is null.static <T> T[]array(AtomicReferenceArray<T> atomicReferenceArray) Returns an T[] from theAtomicReferenceArray, null if the given atomic array is null.static <T> T[]array(T... values) Returns an array containing the given arguments.Get the values of any array (primitive or not) into aList<Object>.static Object[]asObjectArray(Object array) Get the values of any array (primitive or not) into aObject[].static <T> booleanhasOnlyNullElements(T[] array) Returnstrueif the given array has onlynullelements,falseotherwise.static booleanIndicates whether the given object is notnulland is an array.static booleanisArrayEmpty(Object array) static booleanstatic <T> booleanisNullOrEmpty(T[] array) Indicates whether the given array isnullor empty.static booleanstatic <T> List<T> nonNullElementsIn(T[] array) Returns all the non-nullelements in the given array.static IllegalArgumentExceptionstatic <T> T[]prepend(T first, T... rest) static int
-
Method Details
-
isArray
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.
-
asObjectArray
Get the values of any array (primitive or not) into aObject[].- Parameters:
array- array passed as an object to support both primitive and Object array- Returns:
- the values of the given Object as a
Object[]. - Throws:
IllegalArgumentException- it the given Object is not an array.
-
asList
Get the values of any array (primitive or not) into aList<Object>.- Parameters:
array- array passed as an object to support both primitive and Object array- Returns:
- the values of the given Object as a
List<Object>. - Throws:
IllegalArgumentException- it the given Object is not an array.
-
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
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.
-
array
Returns an int[] from theAtomicIntegerArray, null if the given atomic array is null.- Parameters:
atomicIntegerArray- theAtomicIntegerArrayto convert to int[].- Returns:
- an int[].
-
array
Returns an long[] from theAtomicLongArray, null if the given atomic array is null.- Parameters:
atomicLongArray- theAtomicLongArrayto convert to long[].- Returns:
- an long[].
-
array
Returns an T[] from theAtomicReferenceArray, null if the given atomic array is null.- Type Parameters:
T- the type of elements of the array.- Parameters:
atomicReferenceArray- theAtomicReferenceArrayto convert to T[].- Returns:
- an T[].
-
nonNullElementsIn
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.
-
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.
-
isObjectArray
-
isArrayTypePrimitive
-
notAnArrayOfPrimitives
-
prepend
public static <T> T[] prepend(T first, T... rest) -
sizeOf
-
isArrayEmpty
-