Package org.atmosphere.config.managed
Class TypeResolver
java.lang.Object
org.atmosphere.config.managed.TypeResolver
Enhanced type resolution utilities. Based on org.springframework.core.GenericTypeResolver.
- Author:
- Jonathan Halterman
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic voidDisables the internal caching of TypeVariables.static voidEnables the internal caching of TypeVariables.static <T,I extends T>
Class<?> resolveArgument(Class<I> initialType, Class<T> targetType) Returns the raw class representing the type argument for thetargetTyperesolved upwards from theinitialType.static Class<?> resolveArgument(Type genericType, Class<?> targetType) Resolves the type argument for thegenericTypeusing type variable information from thesourceType.static <T,I extends T>
Class<?>[]resolveArguments(Class<I> initialType, Class<T> targetType) Returns an array of raw classes representing type arguments for thetargetTyperesolved upwards from theinitialType.static Class<?>[]resolveArguments(Type genericType, Class<?> targetType) Resolves the arguments for thegenericTypeusing the type variable information for thetargetType.static TyperesolveBound(TypeVariable<?> typeVariable) Resolves the first bound for thetypeVariable, returningUnknown.classif none can be resolved.static Class<?> resolveClass(Type genericType, Class<?> targetType) Resolves the raw class for the givengenericType, using the type variable information from thetargetType.static TyperesolveGenericType(Type initialType, Class<?> targetType) Resolves the generic Type for thetargetTypeby walking the type hierarchy upwards from theinitialType.
-
Method Details
-
enableCache
public static void enableCache()Enables the internal caching of TypeVariables. -
disableCache
public static void disableCache()Disables the internal caching of TypeVariables. -
resolveArgument
Returns the raw class representing the type argument for thetargetTyperesolved upwards from theinitialType. If no arguments can be resolved thenUnknown.classis returned.- Parameters:
initialType- to resolve upwards fromtargetType- to resolve arguments for- Returns:
- type argument for
initialTypeelsenullif no type arguments are declared - Throws:
IllegalArgumentException- if more or less than one type argument is resolved for the give types
-
resolveArgument
Resolves the type argument for thegenericTypeusing type variable information from thesourceType. IfgenericTypeis an instance of class, thengenericTypeis returned. If no arguments can be resolved thenUnknown.classis returned.- Parameters:
genericType- to resolve upwards fromtargetType- to resolve arguments for- Returns:
- type argument for
initialTypeelsenullif no type arguments are declared - Throws:
IllegalArgumentException- if more or less than one type argument is resolved for the give types
-
resolveArguments
public static <T,I extends T> Class<?>[] resolveArguments(Class<I> initialType, Class<T> targetType) Returns an array of raw classes representing type arguments for thetargetTyperesolved upwards from theinitialType. Arguments fortargetTypethat cannot be resolved to a Class are returned asUnknown.class. If no arguments can be resolved thennullis returned.- Parameters:
initialType- to resolve upwards fromtargetType- to resolve arguments for- Returns:
- array of raw classes representing type arguments for
initialTypeelsenullif no type arguments are declared
-
resolveArguments
Resolves the arguments for thegenericTypeusing the type variable information for thetargetType. ReturnsnullifgenericTypeis not parameterized or if arguments cannot be resolved. -
resolveGenericType
Resolves the generic Type for thetargetTypeby walking the type hierarchy upwards from theinitialType. -
resolveClass
Resolves the raw class for the givengenericType, using the type variable information from thetargetType. -
resolveBound
Resolves the first bound for thetypeVariable, returningUnknown.classif none can be resolved.
-