Class Arrays


  • public class Arrays
    extends Object
    Utility methods related to arrays.
    Author:
    Alex Ruiz, Joel Costigliola
    • Method Detail

      • isArray

        public static boolean isArray​(Object o)
        Indicates whether the given object is not null and is an array.
        Parameters:
        o - the given object.
        Returns:
        true if the given object is not null and is an array, otherwise false.
      • isNullOrEmpty

        public static <T> boolean isNullOrEmpty​(T[] array)
        Indicates whether the given array is null or empty.
        Type Parameters:
        T - the type of elements of the array.
        Parameters:
        array - the array to check.
        Returns:
        true if the given array is null or empty, otherwise false.
      • array

        @SafeVarargs
        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.
      • array

        public static long[] array​(AtomicLongArray atomicLongArray)
        Returns an long[] from the AtomicLongArray, null if the given atomic array is null.
        Parameters:
        atomicLongArray - the AtomicLongArray to convert to long[].
        Returns:
        an long[].
      • nonNullElementsIn

        public static <T> List<T> nonNullElementsIn​(T[] array)
        Returns all the non-null elements in the given array.
        Type Parameters:
        T - the type of elements of the array.
        Parameters:
        array - the given array.
        Returns:
        all the non-null elements in the given array. An empty list is returned if the given array is null.
      • hasOnlyNullElements

        public static <T> boolean hasOnlyNullElements​(T[] array)
        Returns true if the given array has only null elements, false otherwise. If given array is empty, this method returns true.
        Type Parameters:
        T - the type of elements of the array.
        Parameters:
        array - the given array. It must not be null.
        Returns:
        true if the given array has only null elements or is empty, false otherwise.
        Throws:
        NullPointerException - if the given array is null.
      • isObjectArray

        public static boolean isObjectArray​(Object o)
      • isArrayTypePrimitive

        public static boolean isArrayTypePrimitive​(Object o)