com.google.common.collect
Class ObjectArrays

java.lang.Object
  extended by com.google.common.collect.ObjectArrays

public final class ObjectArrays
extends Object

Static utility methods pertaining to object arrays.

Author:
Kevin Bourrillion

Field Summary
static Object[] EMPTY_ARRAY
          An empty object array.
 
Method Summary
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[]
emptyArray(T[] array)
          Returns an empty array with the same component type as the specified 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final Object[] EMPTY_ARRAY
An empty object array.

Method Detail

newArray

public static <T> T[] newArray(Class<T> type,
                               int length)
Returns a new array of the given length with the specified component type.

Parameters:
type - the component type
length - the length of the new array

newArray

public static <T> T[] newArray(T[] reference,
                               int length)
Returns a new array of the given length with the same type as a reference array.

Parameters:
reference - any array of the desired type
length - the length of the new array

emptyArray

public static <T> T[] emptyArray(T[] array)
Returns an empty array with the same component type as the specified array.

Parameters:
array - the array from which to infer the component type

concat

public static <T> T[] concat(T[] first,
                             T[] second,
                             Class<T> type)
Returns a new array that contains the concatenated contents of two arrays.

Parameters:
first - the first array of elements to concatenate
second - the second array of elements to concatenate
type - the component type of the returned array