jp.develop.common.util
Class TypeUtil

java.lang.Object
  extended by jp.develop.common.util.TypeUtil

public final class TypeUtil
extends Object

Utilities for Type information. This class is aimed to support generics operation.

Author:
Waki Takeya

Method Summary
static
<T extends Collection<?>>
ParameterizedType
getCollectionType(Class<T> collection, Type elementType)
          Get the type having collection's actual class and element's actual class.
static GenericArrayType getGenericArrayType(Type genericComponentType)
          General purpose method to get GenericArrayType.
static
<T extends Map<?,?>>
ParameterizedType
getMapType(Class<T> map, Type keyType, Type valueType)
          Get the type having map's actual class and key and value's actual class.
static ParameterizedType getParameterizedType(Class<?> rawType, Type... actualTypeArguments)
          General purpose method to get ParameterizedType.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCollectionType

public static <T extends Collection<?>> ParameterizedType getCollectionType(Class<T> collection,
                                                                            Type elementType)
Get the type having collection's actual class and element's actual class. Basically, it is same as the method getParameterizedType(). But I believe this is helpful to understand the purpose.

Type Parameters:
T - Class implements Collection.
Parameters:
collection - Class of Collection.
elementType - Class of Elements.
Returns:
Parameterized Type for specified collection and element class.

getMapType

public static <T extends Map<?,?>> ParameterizedType getMapType(Class<T> map,
                                                                Type keyType,
                                                                Type valueType)
Get the type having map's actual class and key and value's actual class. Basically, it is same as the method getParameterizedType(). But I believe this is helpful to understand the purpose.

Type Parameters:
T - Class implements Map.
Parameters:
map - Class of Map.
keyType - Class of Key.
valueType - Class of Value.
Returns:
Parameterized Type for specified map and key and value class.

getParameterizedType

public static ParameterizedType getParameterizedType(Class<?> rawType,
                                                     Type... actualTypeArguments)
General purpose method to get ParameterizedType.

Parameters:
rawType - Raw type of parameterizedType.
actualTypeArguments - Actual type arguments of parameterizedType.
Returns:
Parameterized type.

getGenericArrayType

public static GenericArrayType getGenericArrayType(Type genericComponentType)
General purpose method to get GenericArrayType.

Parameters:
genericComponentType - Type of array elements.
Returns:
Generic Array Type