public final class TypeResolver
extends java.lang.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(java.lang.Class<I> initialType,
java.lang.Class<T> targetType)
Returns the raw class representing the type argument for the
targetType resolved
upwards from the initialType. |
static java.lang.Class<?> |
resolveArgument(java.lang.reflect.Type genericType,
java.lang.Class<?> targetType)
Resolves the type argument for the
genericType using type variable information from the
sourceType. |
static <T,I extends T> |
resolveArguments(java.lang.Class<I> initialType,
java.lang.Class<T> targetType)
Returns an array of raw classes representing type arguments for the
targetType resolved
upwards from the initialType. |
static java.lang.Class<?>[] |
resolveArguments(java.lang.reflect.Type genericType,
java.lang.Class<?> targetType)
Resolves the arguments for the
genericType using the type variable information for the
targetType. |
static java.lang.reflect.Type |
resolveBound(java.lang.reflect.TypeVariable<?> typeVariable)
Resolves the first bound for the
typeVariable, returning Unknown.class if none
can be resolved. |
static java.lang.Class<?> |
resolveClass(java.lang.reflect.Type genericType,
java.lang.Class<?> targetType)
Resolves the raw class for the given
genericType, using the type variable information
from the targetType. |
static java.lang.reflect.Type |
resolveGenericType(java.lang.reflect.Type initialType,
java.lang.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> java.lang.Class<?> resolveArgument(java.lang.Class<I> initialType,
java.lang.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
declaredjava.lang.IllegalArgumentException - if more or less than one type argument is resolved for the
give typespublic static java.lang.Class<?> resolveArgument(java.lang.reflect.Type genericType,
java.lang.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
declaredjava.lang.IllegalArgumentException - if more or less than one type argument is resolved for the
give typespublic static <T,I extends T> java.lang.Class<?>[] resolveArguments(java.lang.Class<I> initialType,
java.lang.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 java.lang.Class<?>[] resolveArguments(java.lang.reflect.Type genericType,
java.lang.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 java.lang.reflect.Type resolveGenericType(java.lang.reflect.Type initialType,
java.lang.Class<?> targetType)
targetType by walking the type hierarchy upwards from
the initialType.public static java.lang.Class<?> resolveClass(java.lang.reflect.Type genericType,
java.lang.Class<?> targetType)
genericType, using the type variable information
from the targetType.public static java.lang.reflect.Type resolveBound(java.lang.reflect.TypeVariable<?> typeVariable)
typeVariable, returning Unknown.class if none
can be resolved.Copyright © 2024. All Rights Reserved.