public final class TypeResolver extends Object
Modifier and Type | Class and Description |
---|---|
static class |
TypeResolver.Unknown
An unknown type.
|
Modifier and Type | Method and Description |
---|---|
static void |
disableCache()
Disables the internal caching of TypeVariables.
|
static void |
enableCache()
Enables the internal caching of TypeVariables.
|
static <T,I extends T> |
resolveArgument(Class<I> initialType,
Class<T> targetType)
Returns the raw class representing the type argument for the
targetType resolved
upwards from the initialType . |
static Class<?> |
resolveArgument(Type genericType,
Class<?> targetType)
Resolves the type argument for the
genericType using type variable information from the
sourceType . |
static <T,I extends T> |
resolveArguments(Class<I> initialType,
Class<T> targetType)
Returns an array of raw classes representing type arguments for the
targetType resolved
upwards from the initialType . |
static Class<?>[] |
resolveArguments(Type genericType,
Class<?> targetType)
Resolves the arguments for the
genericType using the type variable information for the
targetType . |
static Type |
resolveBound(TypeVariable<?> typeVariable)
Resolves the first bound for the
typeVariable , returning Unknown.class if none
can be resolved. |
static Class<?> |
resolveClass(Type genericType,
Class<?> targetType)
Resolves the raw class for the given
genericType , using the type variable information
from the targetType . |
static Type |
resolveGenericType(Type initialType,
Class<?> targetType)
Resolves the generic Type for the
targetType by walking the type hierarchy upwards from
the initialType . |
public static void enableCache()
public static void disableCache()
public static <T,I extends T> Class<?> resolveArgument(Class<I> initialType, Class<T> targetType)
targetType
resolved
upwards from the initialType
. If no arguments can be resolved then
Unknown.class
is returned.initialType
- to resolve upwards fromtargetType
- to resolve arguments forinitialType
else null
if no type arguments are
declaredIllegalArgumentException
- if more or less than one type argument is resolved for the
give typespublic static Class<?> resolveArgument(Type genericType, Class<?> targetType)
genericType
using type variable information from the
sourceType
. If genericType
is an instance of class, then genericType
is
returned. If no arguments can be resolved then Unknown.class
is returned.genericType
- to resolve upwards fromtargetType
- to resolve arguments forinitialType
else null
if no type arguments are
declaredIllegalArgumentException
- if more or less than one type argument is resolved for the
give typespublic static <T,I extends T> Class<?>[] resolveArguments(Class<I> initialType, Class<T> targetType)
targetType
resolved
upwards from the initialType
. Arguments for targetType
that cannot be resolved
to a Class are returned as Unknown.class
. If no arguments can be resolved then
null
is returned.initialType
- to resolve upwards fromtargetType
- to resolve arguments forinitialType
else
null
if no type arguments are declaredpublic static Class<?>[] resolveArguments(Type genericType, Class<?> targetType)
genericType
using the type variable information for the
targetType
. Returns null
if genericType
is not parameterized or if
arguments cannot be resolved.public static Type resolveGenericType(Type initialType, Class<?> targetType)
targetType
by walking the type hierarchy upwards from
the initialType
.public static Class<?> resolveClass(Type genericType, Class<?> targetType)
genericType
, using the type variable information
from the targetType
.public static Type resolveBound(TypeVariable<?> typeVariable)
typeVariable
, returning Unknown.class
if none
can be resolved.Copyright © 2015. All Rights Reserved.