public abstract class Types extends Object
| Constructor and Description |
|---|
Types() |
| Modifier and Type | Method and Description |
|---|---|
static <T,E> Class<T> |
arrayTypeOf(Class<E> elementType)
Returns array type for the specified type of array elements.
|
static <T> T |
cast(Object obj)
Casts an object.
|
static <T> T |
defaultValueOf(Class<T> type)
Returns default value for the specified type.
|
static <T> Class<T> |
elementTypeOf(Type type)
Returns raw element (value) type for the specified generic array,
collection or map type.
|
static int |
hashCode(Class<?>... types)
Returns a hash code value for the specified array of types.
|
static boolean |
isBoolean(Class<?> type)
Determines if the specified type is a boolean type (either primitive or
object).
|
static boolean |
isByte(Class<?> type)
Determines if the specified type is a byte type (either primitive or
object).
|
static boolean |
isDouble(Class<?> type)
Determines if the specified type is a double type (either primitive or
object).
|
static boolean |
isFloat(Class<?> type)
Determines if the specified type is a float type (either primitive or
object).
|
static boolean |
isInteger(Class<?> type)
Determines if the specified type is an integer type (either primitive or
object).
|
static boolean |
isLong(Class<?> type)
Determines if the specified type is a long type (either primitive or
object).
|
static boolean |
isObject(Class<?> type)
Determines if the specified type is an object type (not a primitive,
array, enum or annotation).
|
static boolean |
isShort(Class<?> type)
Determines if the specified type is a short type (either primitive or
object).
|
static <T> Class<T> |
keyTypeOf(Type type)
Returns raw key type for the specified generic map type.
|
static <T,E> T |
newArray(Class<E> elementType,
int length)
Creates a new array for the specified type of array elements.
|
static <T extends Collection<E>,E> |
newCollection(Class<T> type,
int size)
Creates a new collection of the specified type.
|
static <T> T |
newInstance(Class<T> type)
Creates a new object instance of the specified type.
|
static <T extends List<E>,E> |
newList(Class<T> type,
int size)
Creates a new list of the specified type.
|
static <T extends Map<K,V>,K,V> |
newMap(Class<T> type,
int size)
Creates a new map of the specified type.
|
static <T extends Queue<E>,E> |
newQueue(Class<T> type,
int size)
Creates a new queue of the specified type.
|
static <T extends Set<E>,E> |
newSet(Class<T> type,
int size)
Creates a new set of the specified type.
|
static Class<?> |
parameterTypeOf(Class<?> type,
Class<?> base,
int index)
Returns the type of parameter with the specified index for the specified
type.
|
static Class<?> |
primitiveTypeOf(Class<?> type)
Returns corresponding primitive type for the specified wrapper type.
|
static <T> Class<T> |
rawTypeOf(Type type)
Returns raw type for the specified generic type.
|
static Class<?> |
superTypeOf(Class<?>... types)
Returns super type for the specified array of types.
|
static Class<?> |
superTypeOf(Class<?> type)
Returns super type for the specified type.
|
static Class<?> |
superTypeOf(Class<?> type1,
Class<?> type2)
Returns super type for the specified two types.
|
static Class<?>[] |
typesOf(Object... objs)
Returns array of types for the specified array of objects.
|
static <T> Class<T> |
wrapperTypeOf(Class<T> type)
Returns corresponding wrapper type for the specified primitive type.
|
public static <T> T cast(Object obj)
obj - The object to be cast.public static Class<?>[] typesOf(Object... objs)
null elements is java.lang.Object
type.objs - Array of objects.public static boolean isBoolean(Class<?> type)
type - The type to test.true if the specified type is a boolean type;
false otherwise.public static boolean isByte(Class<?> type)
type - The type to test.true if the specified type is a byte type;
false otherwise.public static boolean isShort(Class<?> type)
type - The type to test.true if the specified type is a short type;
false otherwise.public static boolean isInteger(Class<?> type)
type - The type to test.true if the specified type is an integer type;
false otherwise.public static boolean isLong(Class<?> type)
type - The type to test.true if the specified type is a long type;
false otherwise.public static boolean isFloat(Class<?> type)
type - The type to test.true if the specified type is a float type;
false otherwise.public static boolean isDouble(Class<?> type)
type - The type to test.true if the specified type is a double type;
false otherwise.public static boolean isObject(Class<?> type)
type - The type to test.true if the specified type is an object type;
false otherwise.public static <T> Class<T> wrapperTypeOf(Class<T> type)
type - Primitive type.public static Class<?> primitiveTypeOf(Class<?> type)
type - Wrapper type.public static <T> T defaultValueOf(Class<T> type)
null.type - The type for which default value should be returned.public static Class<?> superTypeOf(Class<?> type)
null and returns
java.lang.Object type if so.type - The type to test.public static Class<?> superTypeOf(Class<?> type1, Class<?> type2)
type1 - First type.type2 - Second type.public static Class<?> superTypeOf(Class<?>... types)
types - Array of types.public static <T> Class<T> rawTypeOf(Type type)
type - Generic type.public static <T,E> Class<T> arrayTypeOf(Class<E> elementType)
elementType - Type of array elements.public static <T> Class<T> elementTypeOf(Type type)
null
if the specified type is not array, collection or map type.type - Generic array, collection or map type.public static <T> Class<T> keyTypeOf(Type type)
null if the specified type is not map type.type - Generic map type.public static Class<?> parameterTypeOf(Class<?> type, Class<?> base, int index)
type - Subtype.base - Base super type.index - Parameter index.public static <T> T newInstance(Class<T> type)
type - The type of object to be created.RuntimeException - if object instantiation fails.public static <T,E> T newArray(Class<E> elementType, int length)
elementType - The type of array elements.length - Length of the new array.public static <T extends Collection<E>,E> T newCollection(Class<T> type, int size)
type - The type of collection to be created.size - Initial size of the new collection.public static <T extends List<E>,E> T newList(Class<T> type, int size)
type - The type of list to be created.size - Initial size of the new list.public static <T extends Set<E>,E> T newSet(Class<T> type, int size)
type - The type of set to be created.size - Initial size of the new set.public static <T extends Queue<E>,E> T newQueue(Class<T> type, int size)
type - The type of queue to be created.size - Initial size of the new queue.public static <T extends Map<K,V>,K,V> T newMap(Class<T> type, int size)
type - The type of map to be created.size - Initial size of the new map.public static int hashCode(Class<?>... types)
types - Array of types.Copyright © 2010-2012 FoxLabs. All Rights Reserved.