Package org.atmosphere.config.managed
Class TypeResolver
- java.lang.Object
-
- org.atmosphere.config.managed.TypeResolver
-
public final class TypeResolver extends java.lang.ObjectEnhanced type resolution utilities. Based on org.springframework.core.GenericTypeResolver.- Author:
- Jonathan Halterman
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTypeResolver.UnknownAn unknown type.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddisableCache()Disables the internal caching of TypeVariables.static voidenableCache()Enables the internal caching of TypeVariables.static <T,I extends T>
java.lang.Class<?>resolveArgument(java.lang.Class<I> initialType, java.lang.Class<T> targetType)Returns the raw class representing the type argument for thetargetTyperesolved upwards from theinitialType.static java.lang.Class<?>resolveArgument(java.lang.reflect.Type genericType, java.lang.Class<?> targetType)Resolves the type argument for thegenericTypeusing type variable information from thesourceType.static <T,I extends T>
java.lang.Class<?>[]resolveArguments(java.lang.Class<I> initialType, java.lang.Class<T> targetType)Returns an array of raw classes representing type arguments for thetargetTyperesolved upwards from theinitialType.static java.lang.Class<?>[]resolveArguments(java.lang.reflect.Type genericType, java.lang.Class<?> targetType)Resolves the arguments for thegenericTypeusing the type variable information for thetargetType.static java.lang.reflect.TyperesolveBound(java.lang.reflect.TypeVariable<?> typeVariable)Resolves the first bound for thetypeVariable, returningUnknown.classif none can be resolved.static java.lang.Class<?>resolveClass(java.lang.reflect.Type genericType, java.lang.Class<?> targetType)Resolves the raw class for the givengenericType, using the type variable information from thetargetType.static java.lang.reflect.TyperesolveGenericType(java.lang.reflect.Type initialType, java.lang.Class<?> targetType)Resolves the generic Type for thetargetTypeby walking the type hierarchy upwards from theinitialType.
-
-
-
Method Detail
-
enableCache
public static void enableCache()
Enables the internal caching of TypeVariables.
-
disableCache
public static void disableCache()
Disables the internal caching of TypeVariables.
-
resolveArgument
public static <T,I extends T> java.lang.Class<?> resolveArgument(java.lang.Class<I> initialType, java.lang.Class<T> targetType)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:
java.lang.IllegalArgumentException- if more or less than one type argument is resolved for the give types
-
resolveArgument
public static java.lang.Class<?> resolveArgument(java.lang.reflect.Type genericType, java.lang.Class<?> targetType)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:
java.lang.IllegalArgumentException- if more or less than one type argument is resolved for the give types
-
resolveArguments
public static <T,I extends T> java.lang.Class<?>[] resolveArguments(java.lang.Class<I> initialType, java.lang.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
public static java.lang.Class<?>[] resolveArguments(java.lang.reflect.Type genericType, java.lang.Class<?> targetType)Resolves the arguments for thegenericTypeusing the type variable information for thetargetType. ReturnsnullifgenericTypeis not parameterized or if arguments cannot be resolved.
-
resolveGenericType
public static java.lang.reflect.Type resolveGenericType(java.lang.reflect.Type initialType, java.lang.Class<?> targetType)Resolves the generic Type for thetargetTypeby walking the type hierarchy upwards from theinitialType.
-
resolveClass
public static java.lang.Class<?> resolveClass(java.lang.reflect.Type genericType, java.lang.Class<?> targetType)Resolves the raw class for the givengenericType, using the type variable information from thetargetType.
-
resolveBound
public static java.lang.reflect.Type resolveBound(java.lang.reflect.TypeVariable<?> typeVariable)
Resolves the first bound for thetypeVariable, returningUnknown.classif none can be resolved.
-
-