Class ArrayMethods

java.lang.Object
org.klojang.util.ArrayMethods

public final class ArrayMethods extends Object
Methods for working with arrays.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int[]
    A zero-length int array.
    static final long[]
    A zero-length long array.
    static final Object[]
    A zero-length Object array.
    static final String[]
    A zero-length String array.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T[]
    append(T[] array, T obj)
    Appends an element to an array.
    static <T> T[]
    append(T[] array, T obj0, T obj1, T... moreObjs)
    Appends multiple elements to an array.
    static List<Boolean>
    asList(boolean[] values)
    Converts a boolean array to a List<Boolean>.
    static List<Byte>
    asList(byte[] values)
    Converts a byte array to a List<Byte>.
    static List<Character>
    asList(char[] values)
    Converts a char array to a List<Character>.
    static List<Double>
    asList(double[] values)
    Converts a double array to a List<Double>.
    static List<Float>
    asList(float[] values)
    Converts a float array to a List<Float>.
    static List<Integer>
    asList(int[] values)
    Converts an int array to a List<Integer>.
    static List<Long>
    asList(long[] values)
    Converts a long array to a List<Long>.
    static List<Short>
    asList(short[] values)
    Converts a short array to a List<Short>.
    static Boolean[]
    box(boolean[] values)
    Converts a boolean array to a Boolean array.
    static Byte[]
    box(byte[] values)
    Converts a byte array to a Byte array.
    static Character[]
    box(char[] values)
    Converts a char array to a Character array.
    static Double[]
    box(double[] values)
    Converts a double array to a Double array.
    static Float[]
    box(float[] values)
    Converts a float array to a Float array.
    static Integer[]
    box(int[] values)
    Converts an int array to an Integer array.
    static Long[]
    box(long[] values)
    Converts a long array to a Long array.
    static Short[]
    box(short[] values)
    Converts a short array to a Short array.
    static char[]
    chars(char... chars)
    Simply returns the specified array, but allows for leaner code when statically imported.
    static <T> T[]
    concat(T[] arr0, T[] arr1)
    Concatenates two arrays.
    static <T> T[]
    concat(T[] arr0, T[] arr1, T[] arr2, T[]... moreArrays)
    Concatenates multiple arrays into a single array.
    static int
    Returns the deep hash code of an array.
    static double[]
    doubles(double... doubles)
    Simply returns the specified array, but allows for leaner code when statically imported.
    find(int[] array, IntPredicate test)
    Returns the first array element that passes the specified test, or an empty OptionalInt if no element passed the test.
    static <T> org.klojang.check.aux.Result<T>
    find(T[] array, Predicate<T> test)
    Returns the first array element that passes the specified test, or Result.notAvailable() if no element passed the test.
    static <T, R> org.klojang.check.aux.Result<R>
    find(T[] array, Predicate<T> test, Function<T,R> property)
    Returns a Result containing a property of the first array element that passes the specified test, or Result.notAvailable() if no element passed the test.
    static float[]
    floats(float... floats)
    Simply returns the specified array, but allows for leaner code when statically imported.
    static int
    Returns the hash code of an array.
    static <T> String
    implode(T[] array)
    PHP-style implode method, concatenating the array elements using ", " (comma+space) as separator.
    static <T> String
    implode(T[] array, int limit)
    PHP-style implode method, concatenating at most limit array elements using ", " (comma+space) as separator.
    static <T> String
    implode(T[] array, String separator)
    PHP-style implode method, concatenating the array elements using the specified separator.
    static <T> String
    implode(T[] array, String separator, int limit)
    PHP-style implode method, concatenating at most limit array elements using the specified separator.
    static <T> String
    implode(T[] array, Function<T,String> stringifier)
    PHP-style implode method, concatenating at most limit array elements using ", " (comma+space) as separator.
    static <T> String
    implode(T[] array, Function<T,String> stringifier, String separator)
    PHP-style implode method, concatenating at most limit array elements using ", " (comma+space) as separator.
    static <T> String
    implode(T[] array, Function<T,String> stringifier, String separator, int from, int to)
    PHP-style implode method.
    static String
    PHP-style implode method, concatenating the array elements using ", " (comma+space) as separator.
    static String
    implodeAny(Object array, int limit)
    PHP-style implode method, concatenating at most limit array elements using ", " (comma+space) as separator.
    static String
    implodeAny(Object array, String separator)
    PHP-style implode method, concatenating the array elements using the specified separator.
    static String
    implodeAny(Object array, String separator, int limit)
    PHP-style implode method, concatenating at most limit array elements using the specified separator.
    static String
    implodeAny(Object array, Function<Object,String> stringifier)
    PHP-style implode method, concatenating the array elements using ", " (comma+space) as separator.
    static String
    implodeAny(Object array, Function<Object,String> stringifier, String separator)
    PHP-style implode method, concatenating the array elements using ", " (comma+space) as separator.
    static String
    implodeAny(Object array, Function<Object,String> stringifier, String separator, int from, int to)
    PHP-style implode method.
    static String
    implodeInts(int[] array)
    PHP-style implode method, concatenating the array elements using ", " (comma+space) as separator.
    static String
    implodeInts(int[] array, int limit)
    PHP-style implode method, concatenating at most limit array elements using ", " (comma+space) as separator.
    static String
    implodeInts(int[] array, String separator)
    PHP-style implode method, concatenating the array elements using the specified separator.
    static String
    implodeInts(int[] array, String separator, int limit)
    PHP-style implode method, concatenating at most limit array elements using the specified separator.
    static String
    implodeInts(int[] array, IntFunction<String> stringifier)
    PHP-style implode method, concatenating at most limit array elements using ", " (comma+space) as separator.
    static String
    implodeInts(int[] array, IntFunction<String> stringifier, String separator, int from, int to)
    PHP-style implode method, optimized for int[] arrays.
    indexOf(int[] array, int value)
    Returns an OptionalInt containing the array index of the first occurrence of the specified value within the specified array.
    static <T> int
    indexOf(T[] array, T value)
    Returns the array index of the first occurrence of the specified value within the specified array.
    static int[]
    ints(int... ints)
    Simply returns the specified array, but allows for leaner code when statically imported.
    static boolean
    isElementOf(int value, int[] array)
    Returns true if the specified array contains the specified value.
    static <T> boolean
    isElementOf(T value, T[] array)
    Returns true if the specified array contains the specified value.
    static boolean
    isOneOf(Object reference, Object... references)
    Returns true if the specified array contains the specified reference.
    lastIndexOf(int[] array, int value)
    Returns an OptionalInt containing the array index of the last occurrence of the specified value within the specified array.
    static <T> int
    lastIndexOf(T[] array, T value)
    Returns the array index of the last occurrence of the specified value within the specified array.
    static long[]
    longs(long... longs)
    Simply returns the specified array, but allows for leaner code when statically imported.
    static <T> T[]
    pack(T... objs)
    Simply returns the specified array, but allows for leaner code when statically imported.
    static <T> T[]
    prefix(T[] array, T obj)
    Prefixes the specified object to the specified array.
    static <T> T[]
    prefix(T[] array, T obj0, T obj1, T... moreObjs)
    Prefixes the specified object to the specified array.
    static int
    refIndexOf(Object[] array, Object reference)
    Returns the array index of the first occurrence of the specified object, using reference comparisons to identify the object.
    static int
    refLastIndexOf(Object[] array, Object reference)
    Returns the array index of the last occurrence of the specified object, using reference comparisons to identify the object.
    static int[]
    reverse(int[] array)
    Reverses the order of the elements in the specified array.
    static int[]
    reverse(int[] array, int from, int to)
    Reverses the order of the elements in the specified array segment
    static <T> T[]
    reverse(T[] array)
    Reverses the order of the elements in the specified array.
    static <T> T[]
    reverse(T[] array, int from, int to)
    Reverses the order of the elements in the specified array segment.
    static int[]
    unbox(Integer[] values)
    Converts an Integer array to an int array.
    static int[]
    unbox(Integer[] values, int dfault)
    Converts an Integer array to an int array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EMPTY_OBJECT_ARRAY

      public static final Object[] EMPTY_OBJECT_ARRAY
      A zero-length Object array.
    • EMPTY_STRING_ARRAY

      public static final String[] EMPTY_STRING_ARRAY
      A zero-length String array.
    • EMPTY_INT_ARRAY

      public static final int[] EMPTY_INT_ARRAY
      A zero-length int array.
    • EMPTY_LONG_ARRAY

      public static final long[] EMPTY_LONG_ARRAY
      A zero-length long array.
  • Method Details

    • append

      public static <T> T[] append(T[] array, T obj)
      Appends an element to an array.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the array to append the object to
      obj - the object to append
      Returns:
      a new array containing the original array plus the extra element
    • append

      @SafeVarargs public static <T> T[] append(T[] array, T obj0, T obj1, T... moreObjs)
      Appends multiple elements to an array.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the array to append the objects to
      obj0 - the 1st object to append
      obj1 - the 2nd object to append
      moreObjs - more objects to append
      Returns:
      a new array containing the original array plus the extra elements
    • concat

      public static <T> T[] concat(T[] arr0, T[] arr1)
      Concatenates two arrays.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      arr0 - The 1st array to go into the new array
      arr1 - The 2nd array to go into the new array
      Returns:
      a new array containing all elements of the specified arrays
    • concat

      @SafeVarargs public static <T> T[] concat(T[] arr0, T[] arr1, T[] arr2, T[]... moreArrays)
      Concatenates multiple arrays into a single array.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      arr0 - The 1st array to go into the new array
      arr1 - The 2nd array to go into the new array
      arr2 - The 3rd array to go into the new array
      moreArrays - More arrays to concatenate
      Returns:
      a new array containing all elements of the specified arrays
    • isElementOf

      public static boolean isElementOf(int value, int[] array)
      Returns true if the specified array contains the specified value.
      Parameters:
      value - the value to search for
      array - the array to search
      Returns:
      whether the array contains the value
      See Also:
    • isElementOf

      public static <T> boolean isElementOf(T value, T[] array)
      Returns true if the specified array contains the specified value.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      value - the value to search for
      array - the array to search
      Returns:
      whether the array contains the value
      See Also:
    • isOneOf

      public static boolean isOneOf(Object reference, Object... references)
      Returns true if the specified array contains the specified reference.
      Parameters:
      reference - the reference to search for
      references - the array to search
      Returns:
      whether the array contains the reference
      See Also:
    • indexOf

      public static OptionalInt indexOf(int[] array, int value)
      Returns an OptionalInt containing the array index of the first occurrence of the specified value within the specified array. Returns an empty OptionalInt if the array does not contain the value.
      Parameters:
      array - the array to search
      value - the value to search for
      Returns:
      an OptionalInt containing the array index of the value
    • lastIndexOf

      public static OptionalInt lastIndexOf(int[] array, int value)
      Returns an OptionalInt containing the array index of the last occurrence of the specified value within the specified array. Returns an empty OptionalInt if the array does not contain the value.
      Parameters:
      array - the array to search
      value - the value to search for
      Returns:
      an OptionalInt containing the array index of the value
    • indexOf

      public static <T> int indexOf(T[] array, T value)
      Returns the array index of the first occurrence of the specified value within the specified array. Returns -1 if the array does not contain the value. Searching for null is allowed.
      Type Parameters:
      T - the type of the elements within the array
      Parameters:
      array - the array to search
      value - the value to search for (may be null)
      Returns:
      the array index of the value
    • lastIndexOf

      public static <T> int lastIndexOf(T[] array, T value)
      Returns the array index of the last occurrence of the specified value within the specified array. Returns -1 if the array does not contain the value. Searching for null is allowed.
      Type Parameters:
      T - the type of the elements within the array
      Parameters:
      array - the array to search
      value - the value to search for (may be null)
      Returns:
      the array index of the value
    • refIndexOf

      public static int refIndexOf(Object[] array, Object reference)
      Returns the array index of the first occurrence of the specified object, using reference comparisons to identify the object. Returns -1 if the array does not contain the specified reference. Searching for null is not allowed.
      Parameters:
      array - the array to search
      reference - The reference to search for (must not be null)
      Returns:
      the array index of the reference
    • refLastIndexOf

      public static int refLastIndexOf(Object[] array, Object reference)
      Returns the array index of the last occurrence of the specified object, using reference comparisons to identify the object. Returns -1 if the array does not contain the specified reference. Searching for null is not allowed.
      Parameters:
      array - the array to search
      reference - The reference to search for (must not be null)
      Returns:
      the array index of the reference
    • find

      public static <T> org.klojang.check.aux.Result<T> find(T[] array, Predicate<T> test)
      Returns the first array element that passes the specified test, or Result.notAvailable() if no element passed the test.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the array
      test - the test
      Returns:
      the first array element that passes the specified test, or Result.notAvailable() if no element passed the test.
    • find

      public static <T, R> org.klojang.check.aux.Result<R> find(T[] array, Predicate<T> test, Function<T,R> property)
      Returns a Result containing a property of the first array element that passes the specified test, or Result.notAvailable() if no element passed the test.
      
       Person[] persons = getPersons();
       find(persons, p -> p.age() < 15, Person::firstName).ifAvailable(
          name -> System.out.printf("And the winner is ..... %s!!!%n, name);
       );
       
      Type Parameters:
      T - the type of the array elements
      R - the type of the value extracted from the array element
      Parameters:
      array - the array
      test - the test
      property - a function that extracts some value from thr array element
      Returns:
      the Result containing the value extracted from the first array element that passed the specified test, or null if no element passed the test
    • find

      public static OptionalInt find(int[] array, IntPredicate test)
      Returns the first array element that passes the specified test, or an empty OptionalInt if no element passed the test.
      Parameters:
      array - the array
      test - the test
      Returns:
      the first array element that passes the specified test, or an empty OptionalInt if no element passed the test
    • reverse

      public static <T> T[] reverse(T[] array)
      Reverses the order of the elements in the specified array.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the array
      Returns:
      the input array
    • reverse

      public static <T> T[] reverse(T[] array, int from, int to)
      Reverses the order of the elements in the specified array segment.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the array
      from - the start index (inclusive) of the array segment
      to - the end index (exclusive) of the array segment
      Returns:
      the input array
    • reverse

      public static int[] reverse(int[] array)
      Reverses the order of the elements in the specified array.
      Parameters:
      array - the array
      Returns:
      the input array
    • reverse

      public static int[] reverse(int[] array, int from, int to)
      Reverses the order of the elements in the specified array segment
      Parameters:
      array - the array
      from - the start index (inclusive) of the array segment
      to - the end index (exclusive) of the array segment
      Returns:
      the input array
    • hashCode

      public static int hashCode(Object array)
      Returns the hash code of an array. Allows you to retrieve the hash code of an array object even if you don't know its exact type. An IllegalArgumentException is thrown if the argument is not an array.
      Parameters:
      array - the array
      Returns:
      Its hash code
    • deepHashCode

      public static int deepHashCode(Object array)
      Returns the deep hash code of an array. Allow you to retrieve the deep hash code of an array object even if you don't know its exact type. An IllegalArgumentException is thrown if the argument is not an array.
      Parameters:
      array - the array
      Returns:
      Its deep hash code
    • implodeInts

      public static String implodeInts(int[] array)
      PHP-style implode method, concatenating the array elements using ", " (comma+space) as separator. Optimized for int[] arrays.
      Parameters:
      array - the array to implode
      Returns:
      a concatenation of the elements in the array.
    • implodeInts

      public static String implodeInts(int[] array, String separator)
      PHP-style implode method, concatenating the array elements using the specified separator. Optimized for int[] arrays.
      Parameters:
      array - the array to implode
      separator - the string used to separate the elements
      Returns:
      a concatenation of the elements in the array.
    • implodeInts

      public static String implodeInts(int[] array, int limit)
      PHP-style implode method, concatenating at most limit array elements using ", " (comma+space) as separator.
      Parameters:
      array - the array to implode
      limit - The maximum number of elements to collect. The specified number will be clamped to array.length (i.e. it's OK to specify a number greater than array.length). You can specify -1 as a shorthand for array.length.
      Returns:
      a concatenation of the elements in the array.
    • implodeInts

      public static String implodeInts(int[] array, IntFunction<String> stringifier)
      PHP-style implode method, concatenating at most limit array elements using ", " (comma+space) as separator.
      Parameters:
      array - the array to implode
      stringifier - A Function that converts the array elements to strings
      Returns:
      a concatenation of the elements in the array.
    • implodeInts

      public static String implodeInts(int[] array, String separator, int limit)
      PHP-style implode method, concatenating at most limit array elements using the specified separator.
      Parameters:
      array - the array to implode
      separator - the string used to separate the elements
      limit - The maximum number of elements to collect. The specified number will be clamped to array.length (i.e. it's OK to specify a number greater than array.length). You can specify -1 as a shorthand for array.length.
      Returns:
      a concatenation of the elements in the array.
    • implodeInts

      public static String implodeInts(int[] array, IntFunction<String> stringifier, String separator, int from, int to)
      PHP-style implode method, optimized for int[] arrays.
      Parameters:
      array - the array to implode
      stringifier - A Function that converts the array elements to strings
      separator - the string used to separate the elements
      from - The index of the element to begin the concatenation with (inclusive)
      to - The index of the element to end the concatenation with (exclusive). The specified number will be clamped to array.length (i.e. it's OK to specify a number greater than array.length). You can specify -1 as a shorthand for array.length.
      Returns:
      a concatenation of the elements in the array.
      See Also:
    • implodeAny

      public static String implodeAny(Object array)
      PHP-style implode method, concatenating the array elements using ", " (comma+space) as separator. This method is primarily meant to implode primitive arrays, but you can use it to implode any type of array. An IllegalArgumentException is thrown if array is not an array.
      Parameters:
      array - the array to implode
      Returns:
      a concatenation of the elements in the array.
      See Also:
    • implodeAny

      public static String implodeAny(Object array, String separator)
      PHP-style implode method, concatenating the array elements using the specified separator. This method is primarily meant to implode primitive arrays, but you can use it to implode any type of array. An IllegalArgumentException is thrown if array is not an array.
      Parameters:
      array - the array to implode
      separator - the string used to separate the elements
      Returns:
      a concatenation of the elements in the array.
      See Also:
    • implodeAny

      public static String implodeAny(Object array, Function<Object,String> stringifier)
      PHP-style implode method, concatenating the array elements using ", " (comma+space) as separator. This method is primarily meant to implode primitive arrays, but you can use it to implode any type of array. An IllegalArgumentException is thrown if array is not an array.
      Parameters:
      array - the array to implode
      stringifier - A Function that converts the array elements to strings
      Returns:
      a concatenation of the elements in the array.
      See Also:
    • implodeAny

      public static String implodeAny(Object array, Function<Object,String> stringifier, String separator)
      PHP-style implode method, concatenating the array elements using ", " (comma+space) as separator. This method is primarily meant to implode primitive arrays, but you can use it to implode any type of array. An IllegalArgumentException is thrown if array is not an array.
      Parameters:
      array - the array to implode
      stringifier - A Function that converts the array elements to strings
      separator - the string used to separate the elements
      Returns:
      a concatenation of the elements in the array.
      See Also:
    • implodeAny

      public static String implodeAny(Object array, int limit)
      PHP-style implode method, concatenating at most limit array elements using ", " (comma+space) as separator. This method is primarily meant to implode primitive arrays, but you can use it to implode any type of array. An IllegalArgumentException is thrown if array is not an array.
      Parameters:
      array - the array to implode
      limit - The maximum number of elements to collect. The specified number will be clamped to array.length (i.e. it's OK to specify a number greater than array.length). You can specify -1 as a shorthand for array.length.
      Returns:
      a concatenation of the elements in the array.
    • implodeAny

      public static String implodeAny(Object array, String separator, int limit)
      PHP-style implode method, concatenating at most limit array elements using the specified separator. This method is primarily meant to implode primitive arrays, but you can use it to implode any type of array. An IllegalArgumentException is thrown if array is not an array.
      Parameters:
      array - the array to implode
      separator - the string used to separate the elements
      limit - The maximum number of elements to collect. The specified number will be clamped to array.length (i.e. it's OK to specify a number greater than array.length). You can specify -1 as a shorthand for array.length.
      Returns:
      a concatenation of the elements in the array.
    • implodeAny

      public static String implodeAny(Object array, Function<Object,String> stringifier, String separator, int from, int to)
      PHP-style implode method. This method is primarily meant to implode primitive arrays, but you can use it to implode any type of array. An IllegalArgumentException is thrown if array is not an array.
      Parameters:
      array - the array to implode
      stringifier - A Function that converts the array elements to strings
      separator - the string used to separate the elements
      from - The index of the element to begin the concatenation with (inclusive)
      to - The index of the element to end the concatenation with (exclusive). The specified number will be clamped to array.length (i.e. it's OK to specify a number greater than array.length). You can specify -1 as a shorthand for array.length.
      Returns:
      a concatenation of the elements in the array.
      See Also:
    • implode

      public static <T> String implode(T[] array)
      PHP-style implode method, concatenating the array elements using ", " (comma+space) as separator.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the collection to implode
      Returns:
      a concatenation of the elements in the collection.
      See Also:
    • implode

      public static <T> String implode(T[] array, String separator)
      PHP-style implode method, concatenating the array elements using the specified separator.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the array to implode
      separator - the string used to separate the elements
      Returns:
      a concatenation of the elements in the array.
      See Also:
    • implode

      public static <T> String implode(T[] array, int limit)
      PHP-style implode method, concatenating at most limit array elements using ", " (comma+space) as separator.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the array to implode
      limit - The maximum number of elements to collect. The specified number will be clamped to array.length (i.e. it's OK to specify a number greater than array.length). You can specify -1 as a shorthand for array.length.
      Returns:
      a concatenation of the elements in the array.
      See Also:
    • implode

      public static <T> String implode(T[] array, Function<T,String> stringifier)
      PHP-style implode method, concatenating at most limit array elements using ", " (comma+space) as separator.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the array to implode
      stringifier - A Function that converts the array elements to strings
      Returns:
      a concatenation of the elements in the array.
      See Also:
    • implode

      public static <T> String implode(T[] array, Function<T,String> stringifier, String separator)
      PHP-style implode method, concatenating at most limit array elements using ", " (comma+space) as separator.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the array to implode
      stringifier - A Function that converts the array elements to strings
      separator - the string used to separate the elements
      Returns:
      a concatenation of the elements in the array.
      See Also:
    • implode

      public static <T> String implode(T[] array, String separator, int limit)
      PHP-style implode method, concatenating at most limit array elements using the specified separator.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the array to implode
      separator - the string used to separate the elements
      limit - The maximum number of elements to collect. The specified number will be clamped to array.length (i.e. it's OK to specify a number greater than array.length). You can specify -1 as a shorthand for array.length.
      Returns:
      a concatenation of the elements in the array.
      See Also:
    • implode

      public static <T> String implode(T[] array, Function<T,String> stringifier, String separator, int from, int to)
      PHP-style implode method.
      Type Parameters:
      T - the type of the array elements
      Parameters:
      array - the array to implode
      stringifier - A Function that converts the array elements to strings
      separator - the string used to separate the elements
      from - The index of the element to begin the concatenation with (inclusive)
      to - The index of the element to end the concatenation with (exclusive). The specified number will be clamped to array.length (i.e. it's OK to specify a number greater than array.length). You can specify -1 as a shorthand for array.length.
      Returns:
      a concatenation of the elements in the array.
      See Also:
    • pack

      @SafeVarargs public static <T> T[] pack(T... objs)
      Simply returns the specified array, but allows for leaner code when statically imported.
      Type Parameters:
      T - the type of the objects to pack
      Parameters:
      objs - the array
      Returns:
      the same array
    • ints

      public static int[] ints(int... ints)
      Simply returns the specified array, but allows for leaner code when statically imported.
      Parameters:
      ints - the array
      Returns:
      the same array
    • chars

      public static char[] chars(char... chars)
      Simply returns the specified array, but allows for leaner code when statically imported.
      Parameters:
      chars - the array
      Returns:
      the same array
    • doubles

      public static double[] doubles(double... doubles)
      Simply returns the specified array, but allows for leaner code when statically imported.
      Parameters:
      doubles - the array
      Returns:
      the same array
    • longs

      public static long[] longs(long... longs)
      Simply returns the specified array, but allows for leaner code when statically imported.
      Parameters:
      longs - the array
      Returns:
      the same array
    • floats

      public static float[] floats(float... floats)
      Simply returns the specified array, but allows for leaner code when statically imported.
      Parameters:
      floats - The array
      Returns:
      the same array
    • prefix

      public static <T> T[] prefix(T[] array, T obj)
      Prefixes the specified object to the specified array.
      Type Parameters:
      T - the type of the array elements and the object to be prefixed
      Parameters:
      array - the array to be prefixed
      obj - the object to prefix
      Returns:
      a new array containing the specified object and the elements of the specified array
    • prefix

      @SafeVarargs public static <T> T[] prefix(T[] array, T obj0, T obj1, T... moreObjs)
      Prefixes the specified object to the specified array.
      Type Parameters:
      T - the type of the array elements and the object to be prefixed
      Parameters:
      array - the array to be prefixed
      obj0 - the 1st object to prefix
      obj1 - the 2nd object to prefix
      moreObjs - more objects to prefix
      Returns:
      a new array containing the specified objects and the elements of the specified array
    • asList

      public static List<Integer> asList(int[] values)
      Converts an int array to a List<Integer>.
      Parameters:
      values - the array elements.
      Returns:
      a List containing the same elements in the same order
    • asList

      public static List<Float> asList(float[] values)
      Converts a float array to a List<Float>.
      Parameters:
      values - the array elements.
      Returns:
      a List containing the same elements in the same order
    • asList

      public static List<Double> asList(double[] values)
      Converts a double array to a List<Double>.
      Parameters:
      values - the array elements.
      Returns:
      a List containing the same elements in the same order
    • asList

      public static List<Long> asList(long[] values)
      Converts a long array to a List<Long>.
      Parameters:
      values - the array elements.
      Returns:
      a List containing the same elements in the same order
    • asList

      public static List<Short> asList(short[] values)
      Converts a short array to a List<Short>.
      Parameters:
      values - the array elements.
      Returns:
      a List containing the same elements in the same order
    • asList

      public static List<Byte> asList(byte[] values)
      Converts a byte array to a List<Byte>.
      Parameters:
      values - the array elements.
      Returns:
      a List containing the same elements in the same order
    • asList

      public static List<Character> asList(char[] values)
      Converts a char array to a List<Character>.
      Parameters:
      values - the array elements.
      Returns:
      a List containing the same elements in the same order
    • asList

      public static List<Boolean> asList(boolean[] values)
      Converts a boolean array to a List<Boolean>.
      Parameters:
      values - the array elements.
      Returns:
      a List containing the same elements in the same order
    • unbox

      public static int[] unbox(Integer[] values, int dfault)
      Converts an Integer array to an int array.
      Parameters:
      values - the Integer array
      dfault - The int value to convert null elements in the source array to
      Returns:
      the int array
    • unbox

      public static int[] unbox(Integer[] values)
      Converts an Integer array to an int array. null elements in the source array are converted to 0 (zero).
      Parameters:
      values - the Integer array
      Returns:
      the int array
    • box

      public static Integer[] box(int[] values)
      Converts an int array to an Integer array.
      Parameters:
      values - the int array
      Returns:
      the Integer array
    • box

      public static Double[] box(double[] values)
      Converts a double array to a Double array.
      Parameters:
      values - the double array
      Returns:
      the Double array
    • box

      public static Long[] box(long[] values)
      Converts a long array to a Long array.
      Parameters:
      values - the long array
      Returns:
      the Long array
    • box

      public static Float[] box(float[] values)
      Converts a float array to a Float array.
      Parameters:
      values - the float array
      Returns:
      the Float array
    • box

      public static Short[] box(short[] values)
      Converts a short array to a Short array.
      Parameters:
      values - the short array
      Returns:
      the Short array
    • box

      public static Byte[] box(byte[] values)
      Converts a byte array to a Byte array.
      Parameters:
      values - the byte array
      Returns:
      the Byte array
    • box

      public static Character[] box(char[] values)
      Converts a char array to a Character array.
      Parameters:
      values - the char array
      Returns:
      the Character array
    • box

      public static Boolean[] box(boolean[] values)
      Converts a boolean array to a Boolean array.
      Parameters:
      values - the boolean array
      Returns:
      the Boolean array