Class ArrayKit
java.lang.Object
com.iohao.net.common.kit.ArrayKit
Array manipulation utilities.
- Author:
- 渔民小镇
- date:
- 2022-01-14
-
Method Summary
Modifier and TypeMethodDescriptionstatic int[]copy(int[] cards) Create a shallow copy of an int array.static booleanisEmpty(byte[] array) Check whether a byte array is null or empty.static booleanisEmpty(int[] array) Check whether an int array is null or empty.static booleanisEmpty(long[] array) Check whether a long array is null or empty.static booleanCheck whether an Object array is null or empty.static Stringjoin(Object[] array, CharSequence delimiter) Join the string representations of array elements with a delimiter.static booleannotEmpty(byte[] array) Check whether a byte array is non-null and contains at least one element.static booleannotEmpty(int[] array) Check whether an int array is non-null and contains at least one element.static booleannotEmpty(long[] array) Check whether a long array is non-null and contains at least one element.static booleanCheck 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.toList(int[] dataArray) Convert a primitive int array to a mutable list of Integer values.toList(long[] dataArray) Convert a primitive long array to a mutable list of Long values.toSet(int[] dataArray) Convert a primitive int array to a mutable set of Integer values.
-
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
Join the string representations of array elements with a delimiter.- Parameters:
array- the array of objects to joindelimiter- the separator placed between each element- Returns:
- a single string of all elements separated by the delimiter
-
notEmpty
Check whether an Object array is non-null and contains at least one element.- Parameters:
array- the array to check, may be null- Returns:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif the array is null or has zero length
-
isEmpty
Check whether an Object array is null or empty.- Parameters:
array- the array to check, may be null- Returns:
trueif the array is null or has zero length
-
toArrayLong
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
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
-
toList
-
toSet
-