public class GenericTypeReflector
extends java.lang.Object
Constructor and Description |
---|
GenericTypeReflector() |
Modifier and Type | Method and Description |
---|---|
static java.lang.reflect.Type |
addWildcardParameters(java.lang.Class<?> clazz)
Returns a type representing the class, with all type parameters the unbound wildcard ("?").
|
static java.lang.reflect.Type |
capture(java.lang.reflect.Type type)
Applies capture conversion to the given type.
|
static java.lang.Class<?> |
erase(java.lang.reflect.Type type)
Returns the erasure of the given type.
|
static java.lang.reflect.Type |
getArrayComponentType(java.lang.reflect.Type type)
If type is an array type, returns the type of the component of the array.
|
static java.lang.reflect.Type |
getExactFieldType(java.lang.reflect.Field f,
java.lang.reflect.Type type)
Returns the exact type of the given field in the given type.
|
static java.lang.reflect.Type[] |
getExactParameterTypes(java.lang.reflect.Method m,
java.lang.reflect.Type type) |
static java.lang.reflect.Type |
getExactReturnType(java.lang.reflect.Method m,
java.lang.reflect.Type type)
Returns the exact return type of the given method in the given type.
|
static java.lang.reflect.Type |
getExactSuperType(java.lang.reflect.Type type,
java.lang.Class<?> searchClass)
With type a supertype of searchClass, returns the exact supertype of the given class, including type parameters.
|
static java.lang.String |
getTypeName(java.lang.reflect.Type type)
Returns the display name of a Type.
|
static java.lang.reflect.Type |
getTypeParameter(java.lang.reflect.Type type,
java.lang.reflect.TypeVariable<? extends java.lang.Class<?>> variable)
Gets the type parameter for a given type that is the value for a given type variable.
|
static java.util.List<java.lang.Class<?>> |
getUpperBoundClassAndInterfaces(java.lang.reflect.Type type)
Returns list of classes and interfaces that are supertypes of the given type.
|
static boolean |
isSuperType(java.lang.reflect.Type superType,
java.lang.reflect.Type subType)
Checks if the capture of subType is a subtype of superType
|
public static java.lang.Class<?> erase(java.lang.reflect.Type type)
public static java.lang.reflect.Type addWildcardParameters(java.lang.Class<?> clazz)
public static java.lang.reflect.Type getExactSuperType(java.lang.reflect.Type type, java.lang.Class<?> searchClass)
ParameterizedType
representing Collection<String>.
Class
if type if it is a raw type, or has no type parametersParameterizedType
if the type does have parametersGenericArrayType
if searchClass is an array type, and the actual type has type parameterspublic static java.lang.reflect.Type getTypeParameter(java.lang.reflect.Type type, java.lang.reflect.TypeVariable<? extends java.lang.Class<?>> variable)
type
- The type to inspect.variable
- The type variable to find the value for.public static boolean isSuperType(java.lang.reflect.Type superType, java.lang.reflect.Type subType)
public static java.lang.reflect.Type getArrayComponentType(java.lang.reflect.Type type)
public static java.lang.reflect.Type[] getExactParameterTypes(java.lang.reflect.Method m, java.lang.reflect.Type type)
public static java.lang.reflect.Type getExactReturnType(java.lang.reflect.Method m, java.lang.reflect.Type type)
public static java.lang.reflect.Type getExactFieldType(java.lang.reflect.Field f, java.lang.reflect.Type type)
public static java.lang.reflect.Type capture(java.lang.reflect.Type type)
public static java.lang.String getTypeName(java.lang.reflect.Type type)
public static java.util.List<java.lang.Class<?>> getUpperBoundClassAndInterfaces(java.lang.reflect.Type type)
This is mostly useful if you get a type from one of the other methods in GenericTypeReflector, but you don't want to deal with all the different sorts of types, and you are only really interested in concrete classes and interfaces.
Copyright © 2016. All rights reserved