Package org.glassfish.admin.amx.util
Class ArrayConversion
- java.lang.Object
-
- org.glassfish.admin.amx.util.ArrayConversion
-
public final class ArrayConversion extends Object
Provides: - methods to convert arrays of primitive types to corresponding arrays of Object types - conversion to/from Set
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Set<T>
arrayToSet(T[] names)
static Object[]
createObjectArrayType(Class elementType, int size)
Create an array whose type is elementType[] of specified size.static boolean
hasIdenticalElementClasses(Object[] a)
static Object[]
setToArray(Set<?> s)
Convert a Set to an Object[].static Object[]
setToArray(Set<?> s, boolean specialize)
Convert a Set to an array.static Object[]
setToArray(Set<?> s, Object[] out)
Convert a Set to an Object[].static Object[]
specializeArray(Object[] a)
Specialize the type of the array (if possible).static Object[]
subArray(Object[] in, int start, int end)
static Object[]
toAppropriateType(Object array)
Convert an an array of primitive types to an array of Objects of non-primitive types eg int to Integer.static Boolean[]
toBooleans(boolean[] array)
static Byte[]
toBytes(byte[] array)
static Character[]
toCharacters(char[] array)
static Double[]
toDoubles(double[] array)
static Float[]
toFloats(float[] array)
static Integer[]
toIntegers(int[] array)
static Long[]
toLongs(long[] array)
static <T> Set<T>
toSet(T[] array)
static Short[]
toShorts(short[] array)
-
-
-
Method Detail
-
toAppropriateType
public static Object[] toAppropriateType(Object array)
Convert an an array of primitive types to an array of Objects of non-primitive types eg int to Integer.- Parameters:
array
- the array to convert
-
toBooleans
public static Boolean[] toBooleans(boolean[] array)
-
toCharacters
public static Character[] toCharacters(char[] array)
-
toBytes
public static Byte[] toBytes(byte[] array)
-
toShorts
public static Short[] toShorts(short[] array)
-
toIntegers
public static Integer[] toIntegers(int[] array)
-
toLongs
public static Long[] toLongs(long[] array)
-
toFloats
public static Float[] toFloats(float[] array)
-
toDoubles
public static Double[] toDoubles(double[] array)
-
createObjectArrayType
public static Object[] createObjectArrayType(Class elementType, int size)
Create an array whose type is elementType[] of specified size.- Parameters:
elementType
- the type of each entry of the arraysize
- the number of elements
-
toSet
public static <T> Set<T> toSet(T[] array)
-
hasIdenticalElementClasses
public static boolean hasIdenticalElementClasses(Object[] a)
-
specializeArray
public static Object[] specializeArray(Object[] a)
Specialize the type of the array (if possible). For example, if the array is an Object[] of Integer, return an Integer[] of Integer.- Parameters:
a
- the array to specialize- Returns:
- a specialized array (if possible) otherwise the original array
-
setToArray
public static Object[] setToArray(Set<?> s, boolean specialize)
Convert a Set to an array. If specialize is true, then provide the most specialized type possible via specializeArray()- Parameters:
s
- the Set to convertspecialize
- decide whether to specialize the type or not
-
setToArray
public static Object[] setToArray(Set<?> s)
Convert a Set to an Object[].- Parameters:
s
- the Set to convert
-
setToArray
public static Object[] setToArray(Set<?> s, Object[] out)
Convert a Set to an Object[].- Parameters:
s
- the Set to convertout
- the output array, must be of size s.size()
-
arrayToSet
public static <T> Set<T> arrayToSet(T[] names)
-
-