Class ArrayUtil
java.lang.Object
io.hypersistence.utils.hibernate.type.array.internal.ArrayUtil
ArrayUtil - Array utilities holder.- Author:
- Vlad Mihalcea
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>asList(T[] array) Transforms an array to aList.static <T> Set<T>asSet(T[] array) static <T> SortedSet<T>asSortedSet(T[] array) static <T> TClone an array.static <T> TfromString(String string, Class<T> arrayClass) Create array from itsStringrepresentation.static booleanCheck 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> TunwrapArray(Object[] originalArray, Class<T> arrayClass) UnwrapObjectarray to an array of the provided typestatic Object[]Wrap a given array so that primitives become wrapper objects.
-
Constructor Details
-
ArrayUtil
public ArrayUtil()
-
-
Method Details
-
deepCopy
Clone an array.- Type Parameters:
T- array element type- Parameters:
originalArray- original array- Returns:
- cloned array
-
wrapArray
Wrap a given array so that primitives become wrapper objects.- Parameters:
originalArray- original array- Returns:
- wrapped array
-
unwrapArray
UnwrapObjectarray to an array of the provided type- Type Parameters:
T- array element type- Parameters:
originalArray- original arrayarrayClass- array class- Returns:
- unwrapped array
-
fromString
Create array from itsStringrepresentation.- Type Parameters:
T- array element type- Parameters:
string- string representationarrayClass- array class- Returns:
- array
-
isEquals
Check if two arrays are equal.- Parameters:
firstArray- first arraysecondArray- second array- Returns:
- arrays are equal
-
toArrayClass
Get the array class for the provided array element class.- Type Parameters:
T- array element type- Parameters:
arrayElementClass- array element class- Returns:
- array class
-
asList
Transforms an array to aList. The reason whyArrays.asList(Object[])is not used is because on Java 6 it wraps theListso we end up with two nestedListobjects.- Type Parameters:
T- array element type- Parameters:
array- array to transform- Returns:
- the
Listrepresentation of the array
-
asSet
- Type Parameters:
T- array element type- Parameters:
array- array to transform- Returns:
- the
Setrepresentation of the array
-
asSortedSet
- Type Parameters:
T- array element type- Parameters:
array- array to transform- Returns:
- the
SortedSetrepresentation of the array
-