Package org.apache.juneau.internal
Class ArrayUtils
java.lang.Object
org.apache.juneau.internal.ArrayUtils
Quick and dirty utilities for working with arrays.
 
See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic <T> T[]append(T[] array, T... newElements) Appends one or more elements to an array.static <T> Set<T>asSet(T[] array) Converts the specified array to aSet .static <E> E[]combine(E[]... arrays) Combine an arbitrary number of arrays into a single array.static booleanReturnstrue if the specified array contains the specified element using theString.equals(Object)method.static <T> T[]copyOf(T[] array) Makes a copy of the specified array.static ListcopyToList(Object array, List list) Copies the specified array into the specified list.static booleanReturnstrue if the following sorted arrays are equals.static intReturns the index position of the element in the specified array using theString.equals(Object)method.static booleanisEmptyArray(Object[] array) Returnstrue if the specified array is null or has a length of zero.static booleanisEmptyArray(Object[] array1, Object[] array2) Returnstrue if both specified arrays are null or have a length of zero.static booleanisNotEmptyArray(Object[] array) Returnstrue if the specified array is not null and has a length greater than zero.static <E> E[]reverse(E[] array) Reverses the entries in an array.static <E> ObjecttoArray(Collection<?> c, Class<E> elementType) Converts the specified collection to an array.static <E> List<E>Converts the specified array to anArrayList toObjectList(Object array) Recursively converts the specified array into a list of objects.static String[]toStringArray(Collection<?> c) Converts the specified collection to an array of strings.
- 
Constructor Details- 
ArrayUtilspublic ArrayUtils()
 
- 
- 
Method Details- 
appendAppends one or more elements to an array.- Type Parameters:
- T- The element type.
- Parameters:
- array- The array to append to.
- newElements- The new elements to append to the array.
- Returns:
- A new array with the specified elements appended.
 
- 
combineCombine an arbitrary number of arrays into a single array.- Type Parameters:
- E- The element type.
- Parameters:
- arrays- Collection of arrays to combine.
- Returns:
- A new combined array, or null if all arrays arenull .
 
- 
asSetConverts the specified array to aSet .The order of the entries in the set are the same as the array. - Type Parameters:
- T- The entry type of the array.
- Parameters:
- array- The array being wrapped in a- Set interface.
- Returns:
- The new set.
 
- 
toArrayConverts the specified collection to an array.Works on both object and primitive arrays. - Type Parameters:
- E- The element type.
- Parameters:
- c- The collection to convert to an array.
- elementType- The component type of the collection.
- Returns:
- A new array.
 
- 
toListConverts the specified array to anArrayList - Type Parameters:
- E- The element type.
- Parameters:
- array- The array to convert.
- elementType- The type of objects in the array. It must match the actual component type in the array.
- Returns:
- A new ArrayList
 
- 
toObjectListRecursively converts the specified array into a list of objects.- Parameters:
- array- The array to convert.
- Returns:
- A new ArrayList
 
- 
copyToListCopies the specified array into the specified list.Works on both object and primitive arrays. - Parameters:
- array- The array to copy into a list.
- list- The list to copy the values into.
- Returns:
- The same list passed in.
 
- 
containsReturnstrue if the specified array contains the specified element using theString.equals(Object)method.- Parameters:
- element- The element to check for.
- array- The array to check.
- Returns:
- true if the specified array contains the specified element,- false if the array or element is- null .
 
- 
indexOfReturns the index position of the element in the specified array using theString.equals(Object)method.- Parameters:
- element- The element to check for.
- array- The array to check.
- Returns:
- The index position of the element in the specified array, or
   -1 if the array doesn't contain the element, or the array or element isnull .
 
- 
toStringArrayConverts the specified collection to an array of strings.Entries are converted to strings using Object.toString().null values remainnull .- Parameters:
- c- The collection to convert.
- Returns:
- The collection as a string array.
 
- 
equalsReturnstrue if the following sorted arrays are equals.- Parameters:
- a1- Array #1.
- a2- Array #2.
- Returns:
- true if the following sorted arrays are equals.
 
- 
copyOfMakes a copy of the specified array.- Type Parameters:
- T- The element type.
- Parameters:
- array- The array to copy.
- Returns:
- A new copy of the array, or null if the array wasnull .s
 
- 
isNotEmptyArrayReturnstrue if the specified array is not null and has a length greater than zero.- Parameters:
- array- The array to check.
- Returns:
- true if the specified array is not null and has a length greater than zero.
 
- 
isEmptyArrayReturnstrue if the specified array is null or has a length of zero.- Parameters:
- array- The array to check.
- Returns:
- true if the specified array is null or has a length of zero.
 
- 
isEmptyArrayReturnstrue if both specified arrays are null or have a length of zero.- Parameters:
- array1- The array to check.
- array2- The array to check.
- Returns:
- true if the specified array is null or has a length of zero.
 
- 
reverseReverses the entries in an array.- Type Parameters:
- E- The element type.
- Parameters:
- array- The array to reverse.
- Returns:
- The same array.
 
 
-