Class ArrayKit

java.lang.Object
com.iohao.net.common.kit.ArrayKit

public final class ArrayKit extends Object
Array manipulation utilities.
Author:
渔民小镇
date:
2022-01-14
  • Method Summary

    Modifier and Type
    Method
    Description
    static int[]
    copy(int[] cards)
    Create a shallow copy of an int array.
    static boolean
    isEmpty(byte[] array)
    Check whether a byte array is null or empty.
    static boolean
    isEmpty(int[] array)
    Check whether an int array is null or empty.
    static boolean
    isEmpty(long[] array)
    Check whether a long array is null or empty.
    static boolean
    isEmpty(Object[] array)
    Check whether an Object array is null or empty.
    static String
    join(Object[] array, CharSequence delimiter)
    Join the string representations of array elements with a delimiter.
    static boolean
    notEmpty(byte[] array)
    Check whether a byte array is non-null and contains at least one element.
    static boolean
    notEmpty(int[] array)
    Check whether an int array is non-null and contains at least one element.
    static boolean
    notEmpty(long[] array)
    Check whether a long array is non-null and contains at least one element.
    static boolean
    notEmpty(Object[] array)
    Check whether an Object array is non-null and contains at least one element.
    static int[]
    toArrayInt(Collection<Integer> dataCollection)
    Convert a collection of Integer values to a primitive int array.
    static long[]
    toArrayLong(Collection<Long> dataCollection)
    Convert a collection of Long values to a primitive long array.
    static List<Integer>
    toList(int[] dataArray)
    Convert a primitive int array to a mutable list of Integer values.
    static List<Long>
    toList(long[] dataArray)
    Convert a primitive long array to a mutable list of Long values.
    static Set<Integer>
    toSet(int[] dataArray)
    Convert a primitive int array to a mutable set of Integer values.

    Methods inherited from class Object

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

    • copy

      public static int[] copy(int[] cards)
      Create a shallow copy of an int array.
      Parameters:
      cards - the source array to copy
      Returns:
      a new array containing the same elements
    • join

      public static String join(Object[] array, CharSequence delimiter)
      Join the string representations of array elements with a delimiter.
      Parameters:
      array - the array of objects to join
      delimiter - the separator placed between each element
      Returns:
      a single string of all elements separated by the delimiter
    • notEmpty

      public static boolean notEmpty(Object[] array)
      Check whether an Object array is non-null and contains at least one element.
      Parameters:
      array - the array to check, may be null
      Returns:
      true if the array is non-null and non-empty
    • notEmpty

      public static boolean notEmpty(byte[] array)
      Check whether a byte array is non-null and contains at least one element.
      Parameters:
      array - the array to check, may be null
      Returns:
      true if the array is non-null and non-empty
    • notEmpty

      public static boolean notEmpty(int[] array)
      Check whether an int array is non-null and contains at least one element.
      Parameters:
      array - the array to check, may be null
      Returns:
      true if the array is non-null and non-empty
    • notEmpty

      public static boolean notEmpty(long[] array)
      Check whether a long array is non-null and contains at least one element.
      Parameters:
      array - the array to check, may be null
      Returns:
      true if the array is non-null and non-empty
    • isEmpty

      public static boolean isEmpty(byte[] array)
      Check whether a byte array is null or empty.
      Parameters:
      array - the array to check, may be null
      Returns:
      true if the array is null or has zero length
    • isEmpty

      public static boolean isEmpty(int[] array)
      Check whether an int array is null or empty.
      Parameters:
      array - the array to check, may be null
      Returns:
      true if the array is null or has zero length
    • isEmpty

      public static boolean isEmpty(long[] array)
      Check whether a long array is null or empty.
      Parameters:
      array - the array to check, may be null
      Returns:
      true if the array is null or has zero length
    • isEmpty

      public static boolean isEmpty(Object[] array)
      Check whether an Object array is null or empty.
      Parameters:
      array - the array to check, may be null
      Returns:
      true if the array is null or has zero length
    • toArrayLong

      public static long[] toArrayLong(Collection<Long> dataCollection)
      Convert a collection of Long values to a primitive long array.
      Parameters:
      dataCollection - the collection of Long values, may be null or empty
      Returns:
      a primitive long array, or an empty array if the collection is null or empty
    • toArrayInt

      public static int[] toArrayInt(Collection<Integer> dataCollection)
      Convert a collection of Integer values to a primitive int array.
      Parameters:
      dataCollection - the collection of Integer values, may be null or empty
      Returns:
      a primitive int array, or an empty array if the collection is null or empty
    • toList

      public static List<Long> toList(long[] dataArray)
      Convert a primitive long array to a mutable list of Long values.
      Parameters:
      dataArray - the primitive long array, may be null or empty
      Returns:
      a new mutable list containing the boxed values, or an empty list if the array is null or empty
    • toList

      public static List<Integer> toList(int[] dataArray)
      Convert a primitive int array to a mutable list of Integer values.
      Parameters:
      dataArray - the primitive int array, may be null or empty
      Returns:
      a new mutable list containing the boxed values, or an empty list if the array is null or empty
    • toSet

      public static Set<Integer> toSet(int[] dataArray)
      Convert a primitive int array to a mutable set of Integer values.
      Parameters:
      dataArray - the primitive int array, may be null or empty
      Returns:
      a new mutable set containing the boxed values, or an empty set if the array is null or empty