@GwtCompatible(emulated=true) public final class ObjectArrays extends Object
Static utility methods pertaining to object arrays.
| Modifier and Type | Method and Description |
|---|---|
static <T> T[] |
concat(T[] array,
T element)
Returns a new array that appends
element to array. |
static <T> T[] |
concat(T[] first,
T[] second,
Class<T> type)
Returns a new array that contains the concatenated contents of two arrays.
|
static <T> T[] |
concat(T element,
T[] array)
Returns a new array that prepends
element to array. |
static <T> T[] |
newArray(Class<T> type,
int length)
Returns a new array of the given length with the specified component type.
|
static <T> T[] |
newArray(T[] reference,
int length)
Returns a new array of the given length with the same type as a reference array.
|
@GwtIncompatible(value="Array.newInstance(Class, int)") public static <T> T[] newArray(Class<T> type, int length)
Returns a new array of the given length with the specified component type.
type - the component typelength - the length of the new arraypublic static <T> T[] newArray(T[] reference,
int length)
Returns a new array of the given length with the same type as a reference array.
reference - any array of the desired typelength - the length of the new array@GwtIncompatible(value="Array.newInstance(Class, int)") public static <T> T[] concat(T[] first, T[] second, Class<T> type)
Returns a new array that contains the concatenated contents of two arrays.
first - the first array of elements to concatenatesecond - the second array of elements to concatenatetype - the component type of the returned arraypublic static <T> T[] concat(@Nullable T element, T[] array)
Returns a new array that prepends element to array.
element - the element to prepend to the front of arrayarray - the array of elements to appendarray, with element occupying the first position, and the elements of array occupying the remaining elements.public static <T> T[] concat(T[] array,
@Nullable
T element)
Returns a new array that appends element to array.
array - the array of elements to prependelement - the element to append to the endarray, with the same contents as array, plus element occupying the last position.