public class ArrayUtil extends Object
ArrayUtil
- Array utilities holder.Constructor and Description |
---|
ArrayUtil() |
Modifier and Type | Method and Description |
---|---|
static <T> List<T> |
asList(T[] array)
Transforms an array to a
List . |
static <T> T |
deepCopy(Object originalArray)
Clone an array.
|
static <T> T |
fromString(String string,
Class<T> arrayClass)
Create array from its
String representation. |
static boolean |
isEquals(Object firstArray,
Object secondArray)
Check if two arrays are equal.
|
static <T> Class<T[]> |
toArrayClass(Class<T> arrayElementClass)
Get the array class for the provided array element class.
|
static <T> T |
unwrapArray(Object[] originalArray,
Class<T> arrayClass)
Unwarp
Object[] array to an array of the provided type |
static Object[] |
wrapArray(Object originalArray)
Wrap a given array so that primitives become wrapper objects.
|
public static <T> T deepCopy(Object originalArray)
T
- array element typeoriginalArray
- original arraypublic static Object[] wrapArray(Object originalArray)
originalArray
- original arraypublic static <T> T unwrapArray(Object[] originalArray, Class<T> arrayClass)
Object[]
array to an array of the provided typeT
- array element typeoriginalArray
- original arrayarrayClass
- array classpublic static <T> T fromString(String string, Class<T> arrayClass)
String
representation.T
- array element typestring
- string representationarrayClass
- array classpublic static boolean isEquals(Object firstArray, Object secondArray)
firstArray
- first arraysecondArray
- second arraypublic static <T> Class<T[]> toArrayClass(Class<T> arrayElementClass)
T
- array element typearrayElementClass
- array element classpublic static <T> List<T> asList(T[] array)
List
. The reason why Arrays.asList(Object[])
is not used is because on Java 6 it wraps the List
so we end up
with two nested List
objects.T
- array element typearray
- array to transformList
representation of the arrayCopyright © 2021. All rights reserved.