Package org.jboss.resteasy.util
Class Types
- java.lang.Object
-
- org.jboss.resteasy.util.Types
-
public class Types extends java.lang.ObjectType conversions and generic type manipulations- Version:
- $Revision: 1 $
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.reflect.Type[]EMPTY_TYPE_ARRAY
-
Constructor Summary
Constructors Constructor Description Types()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.reflect.Type[]extractTypes(java.util.Map<java.lang.String,java.lang.reflect.Type> typeVarMap, java.lang.reflect.Type genericSub)private static java.lang.reflect.Type[]extractTypeVariables(java.util.Map<java.lang.String,java.lang.reflect.Type> typeVarMap, java.lang.reflect.Type[] types)static java.lang.reflect.Type[]findClassParameterizedTypes(java.lang.Class<?> root, java.lang.reflect.ParameterizedType rootType, java.lang.Class<?> searchedForClass)static java.lang.reflect.Type[]findInterfaceParameterizedTypes(java.lang.Class<?> root, java.lang.reflect.ParameterizedType rootType, java.lang.Class<?> searchedForInterface)static java.lang.reflect.Type[]findParameterizedTypes(java.lang.Class<?> root, java.lang.Class<?> searchedFor)Search for the given interface or class within the root's class/interface hierarchy.static java.lang.reflect.Type[]getActualTypeArgumentsOfAnInterface(java.lang.Class<?> classToSearch, java.lang.Class<?> interfaceToFind)Given a class and an interfaces, go through the class hierarchy to find the interface and return its type arguments.static java.lang.ClassgetArgumentType(java.lang.reflect.ParameterizedType pType, int index)Gets the index-th type argument.static java.lang.ClassgetCollectionBaseType(java.lang.Class type, java.lang.reflect.Type genericType)static java.lang.reflect.MethodgetImplementingMethod(java.lang.Class clazz, java.lang.reflect.Method intfMethod)Given a method and a root class, find the actual method declared in the root that implements the method.static java.lang.ClassgetMapKeyType(java.lang.reflect.Type genericType)static java.lang.ClassgetMapValueType(java.lang.reflect.Type genericType)static java.lang.Class<?>getRawType(java.lang.reflect.Type type)static java.lang.Class<?>getRawTypeNoException(java.lang.reflect.Type type)static java.lang.ClassgetTemplateParameterOfInterface(java.lang.Class base, java.lang.Class desiredInterface)static java.lang.Class<?>getTypeArgument(java.lang.reflect.Type genericType)Returns the type argument from a parameterized typestatic booleanisA(java.lang.Class clazz, java.lang.reflect.ParameterizedType pType)Is the genericType of a certain class?static booleanisCompatible(java.lang.reflect.Method method, java.lang.reflect.Method intfMethod)See if the two methods are compatible, that is they have the same relative signatureprivate static java.util.Map<java.lang.String,java.lang.reflect.Type>populateParameterizedMap(java.lang.Class<?> root, java.lang.reflect.ParameterizedType rootType)private static java.lang.reflect.Type[]recurseSuperclassForInterface(java.lang.Class<?> searchedForInterface, java.util.Map<java.lang.String,java.lang.reflect.Type> typeVarMap, java.lang.reflect.Type genericSub, java.lang.Class<?> sub)static java.lang.reflect.TyperesolveTypeVariable(java.lang.Class<?> root, java.lang.reflect.TypeVariable<?> typeVariable)Finds an actual value of a type variable.static java.lang.reflect.TyperesolveTypeVariables(java.lang.Class<?> root, java.lang.reflect.Type type)private static java.lang.ObjectsearchForInterfaceTemplateParameter(java.lang.Class base, java.lang.Class desiredInterface)
-
-
-
Method Detail
-
isA
public static boolean isA(java.lang.Class clazz, java.lang.reflect.ParameterizedType pType)Is the genericType of a certain class?
-
getArgumentType
public static java.lang.Class getArgumentType(java.lang.reflect.ParameterizedType pType, int index)Gets the index-th type argument.
-
getTemplateParameterOfInterface
public static java.lang.Class getTemplateParameterOfInterface(java.lang.Class base, java.lang.Class desiredInterface)
-
searchForInterfaceTemplateParameter
private static java.lang.Object searchForInterfaceTemplateParameter(java.lang.Class base, java.lang.Class desiredInterface)
-
isCompatible
public static boolean isCompatible(java.lang.reflect.Method method, java.lang.reflect.Method intfMethod)See if the two methods are compatible, that is they have the same relative signature- Parameters:
method-intfMethod-- Returns:
-
getImplementingMethod
public static java.lang.reflect.Method getImplementingMethod(java.lang.Class clazz, java.lang.reflect.Method intfMethod)Given a method and a root class, find the actual method declared in the root that implements the method.- Parameters:
clazz-intfMethod-- Returns:
-
getRawType
public static java.lang.Class<?> getRawType(java.lang.reflect.Type type)
-
getRawTypeNoException
public static java.lang.Class<?> getRawTypeNoException(java.lang.reflect.Type type)
-
getTypeArgument
public static java.lang.Class<?> getTypeArgument(java.lang.reflect.Type genericType)
Returns the type argument from a parameterized type- Parameters:
genericType-- Returns:
- null if there is no type parameter
-
getCollectionBaseType
public static java.lang.Class getCollectionBaseType(java.lang.Class type, java.lang.reflect.Type genericType)
-
getMapKeyType
public static java.lang.Class getMapKeyType(java.lang.reflect.Type genericType)
-
getMapValueType
public static java.lang.Class getMapValueType(java.lang.reflect.Type genericType)
-
resolveTypeVariables
public static java.lang.reflect.Type resolveTypeVariables(java.lang.Class<?> root, java.lang.reflect.Type type)
-
resolveTypeVariable
public static java.lang.reflect.Type resolveTypeVariable(java.lang.Class<?> root, java.lang.reflect.TypeVariable<?> typeVariable)Finds an actual value of a type variable. The method looks in a class hierarchy for a class defining the variable and returns the value if present.- Parameters:
root-typeVariable-- Returns:
- actual type of the type variable
-
getActualTypeArgumentsOfAnInterface
public static java.lang.reflect.Type[] getActualTypeArgumentsOfAnInterface(java.lang.Class<?> classToSearch, java.lang.Class<?> interfaceToFind)Given a class and an interfaces, go through the class hierarchy to find the interface and return its type arguments.- Parameters:
classToSearch-interfaceToFind-- Returns:
- type arguments of the interface
-
findParameterizedTypes
public static java.lang.reflect.Type[] findParameterizedTypes(java.lang.Class<?> root, java.lang.Class<?> searchedFor)Search for the given interface or class within the root's class/interface hierarchy. If the searched for class/interface is a generic return an array of real types that fill it out.- Parameters:
root-searchedFor-- Returns:
-
findClassParameterizedTypes
public static java.lang.reflect.Type[] findClassParameterizedTypes(java.lang.Class<?> root, java.lang.reflect.ParameterizedType rootType, java.lang.Class<?> searchedForClass)
-
populateParameterizedMap
private static java.util.Map<java.lang.String,java.lang.reflect.Type> populateParameterizedMap(java.lang.Class<?> root, java.lang.reflect.ParameterizedType rootType)
-
findInterfaceParameterizedTypes
public static java.lang.reflect.Type[] findInterfaceParameterizedTypes(java.lang.Class<?> root, java.lang.reflect.ParameterizedType rootType, java.lang.Class<?> searchedForInterface)
-
recurseSuperclassForInterface
private static java.lang.reflect.Type[] recurseSuperclassForInterface(java.lang.Class<?> searchedForInterface, java.util.Map<java.lang.String,java.lang.reflect.Type> typeVarMap, java.lang.reflect.Type genericSub, java.lang.Class<?> sub)
-
extractTypeVariables
private static java.lang.reflect.Type[] extractTypeVariables(java.util.Map<java.lang.String,java.lang.reflect.Type> typeVarMap, java.lang.reflect.Type[] types)
-
extractTypes
private static java.lang.reflect.Type[] extractTypes(java.util.Map<java.lang.String,java.lang.reflect.Type> typeVarMap, java.lang.reflect.Type genericSub)
-
-