java.lang.Object
io.hypersistence.utils.hibernate.type.array.internal.ArrayUtil

public class ArrayUtil extends Object
ArrayUtil - Array utilities holder.
Author:
Vlad Mihalcea
  • Constructor Details

    • ArrayUtil

      public ArrayUtil()
  • Method Details

    • deepCopy

      public static <T> T deepCopy(Object originalArray)
      Clone an array.
      Type Parameters:
      T - array element type
      Parameters:
      originalArray - original array
      Returns:
      cloned array
    • wrapArray

      public static Object[] wrapArray(Object originalArray)
      Wrap a given array so that primitives become wrapper objects.
      Parameters:
      originalArray - original array
      Returns:
      wrapped array
    • unwrapArray

      public static <T> T unwrapArray(Object[] originalArray, Class<T> arrayClass)
      Unwrap Object array to an array of the provided type
      Type Parameters:
      T - array element type
      Parameters:
      originalArray - original array
      arrayClass - array class
      Returns:
      unwrapped array
    • fromString

      public static <T> T fromString(String string, Class<T> arrayClass)
      Create array from its String representation.
      Type Parameters:
      T - array element type
      Parameters:
      string - string representation
      arrayClass - array class
      Returns:
      array
    • isEquals

      public static boolean isEquals(Object firstArray, Object secondArray)
      Check if two arrays are equal.
      Parameters:
      firstArray - first array
      secondArray - second array
      Returns:
      arrays are equal
    • toArrayClass

      public static <T> Class<T[]> toArrayClass(Class<T> arrayElementClass)
      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

      public static <T> List<T> asList(T[] array)
      Transforms an array to a 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.
      Type Parameters:
      T - array element type
      Parameters:
      array - array to transform
      Returns:
      the List representation of the array
    • asSet

      public static <T> Set<T> asSet(T[] array)
      Type Parameters:
      T - array element type
      Parameters:
      array - array to transform
      Returns:
      the Set representation of the array