public class Types
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.reflect.Type[] |
EMPTY_TYPE_ARRAY |
Constructor and Description |
---|
Types() |
Modifier and Type | Method and 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.Class |
getArgumentType(java.lang.reflect.ParameterizedType pType,
int index)
Gets the index-th type argument.
|
static java.lang.Class |
getCollectionBaseType(java.lang.Class type,
java.lang.reflect.Type genericType) |
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.
|
static java.lang.Class |
getMapKeyType(java.lang.reflect.Type genericType) |
static java.lang.Class |
getMapValueType(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.Class |
getTemplateParameterOfInterface(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 type
|
static boolean |
isA(java.lang.Class clazz,
java.lang.reflect.ParameterizedType pType)
Is the genericType of a certain class?
|
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
|
private 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.Type |
resolveTypeVariable(java.lang.Class<?> root,
java.lang.reflect.TypeVariable<?> typeVariable)
Finds an actual value of a type variable.
|
static java.lang.reflect.Type |
resolveTypeVariables(java.lang.Class<?> root,
java.lang.reflect.Type type) |
private static java.lang.Object |
searchForInterfaceTemplateParameter(java.lang.Class base,
java.lang.Class desiredInterface) |
public static boolean isA(java.lang.Class clazz, java.lang.reflect.ParameterizedType pType)
public static java.lang.Class getArgumentType(java.lang.reflect.ParameterizedType pType, int index)
public static java.lang.Class getTemplateParameterOfInterface(java.lang.Class base, java.lang.Class desiredInterface)
private static java.lang.Object searchForInterfaceTemplateParameter(java.lang.Class base, java.lang.Class desiredInterface)
public static boolean isCompatible(java.lang.reflect.Method method, java.lang.reflect.Method intfMethod)
method
- intfMethod
- public static java.lang.reflect.Method getImplementingMethod(java.lang.Class clazz, java.lang.reflect.Method intfMethod)
clazz
- intfMethod
- public static java.lang.Class<?> getRawType(java.lang.reflect.Type type)
public static java.lang.Class<?> getRawTypeNoException(java.lang.reflect.Type type)
public static java.lang.Class<?> getTypeArgument(java.lang.reflect.Type genericType)
genericType
- public static java.lang.Class getCollectionBaseType(java.lang.Class type, java.lang.reflect.Type genericType)
public static java.lang.Class getMapKeyType(java.lang.reflect.Type genericType)
public static java.lang.Class getMapValueType(java.lang.reflect.Type genericType)
public static java.lang.reflect.Type resolveTypeVariables(java.lang.Class<?> root, java.lang.reflect.Type type)
public static java.lang.reflect.Type resolveTypeVariable(java.lang.Class<?> root, java.lang.reflect.TypeVariable<?> typeVariable)
root
- typeVariable
- public static java.lang.reflect.Type[] getActualTypeArgumentsOfAnInterface(java.lang.Class<?> classToSearch, java.lang.Class<?> interfaceToFind)
classToSearch
- interfaceToFind
- public static java.lang.reflect.Type[] findParameterizedTypes(java.lang.Class<?> root, java.lang.Class<?> searchedFor)
root
- searchedFor
- public static java.lang.reflect.Type[] findClassParameterizedTypes(java.lang.Class<?> root, java.lang.reflect.ParameterizedType rootType, java.lang.Class<?> searchedForClass)
private static java.util.Map<java.lang.String,java.lang.reflect.Type> populateParameterizedMap(java.lang.Class<?> root, java.lang.reflect.ParameterizedType rootType)
public static java.lang.reflect.Type[] findInterfaceParameterizedTypes(java.lang.Class<?> root, java.lang.reflect.ParameterizedType rootType, java.lang.Class<?> searchedForInterface)
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)
private static java.lang.reflect.Type[] extractTypeVariables(java.util.Map<java.lang.String,java.lang.reflect.Type> typeVarMap, java.lang.reflect.Type[] types)
private static java.lang.reflect.Type[] extractTypes(java.util.Map<java.lang.String,java.lang.reflect.Type> typeVarMap, java.lang.reflect.Type genericSub)