Class GuavaGenericsResolver
- java.lang.Object
-
- org.apache.tapestry5.genericsresolverguava.internal.GuavaGenericsResolver
-
- All Implemented Interfaces:
GenericsResolver
public class GuavaGenericsResolver extends java.lang.Object implements GenericsResolver
GuavaGenericsResolverimplementation using Guava.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.tapestry5.commons.services.GenericsResolver
GenericsResolver.Provider
-
-
Constructor Summary
Constructors Constructor Description GuavaGenericsResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ClassasClass(java.lang.reflect.Type actualType)Get the class represented by the reflected type.java.lang.reflect.TypeextractActualType(java.lang.reflect.Type containingType, java.lang.reflect.Field field)Analyzes the method in the context of containingClass and returns the Class that is represented by the method's generic return type.java.lang.reflect.TypeextractActualType(java.lang.reflect.Type containingType, java.lang.reflect.Method method)Analyzes the method in the context of containingClass and returns the Class that is represented by the method's generic return type.java.lang.ClassextractGenericFieldType(java.lang.Class containingClass, java.lang.reflect.Field field)Analyzes the field in the context of containingClass and returns the Class that is represented by the field's generic type.java.lang.Class<?>extractGenericReturnType(java.lang.Class<?> containingClass, java.lang.reflect.Method method)Analyzes the method in the context of containingClass and returns the Class that is represented by the method's generic return type.java.lang.reflect.Typeresolve(java.lang.reflect.Type type, java.lang.reflect.Type containingType)Resolves the type parameter based on the context of the containingType.
-
-
-
Constructor Detail
-
GuavaGenericsResolver
public GuavaGenericsResolver()
-
-
Method Detail
-
extractGenericReturnType
public java.lang.Class<?> extractGenericReturnType(java.lang.Class<?> containingClass, java.lang.reflect.Method method)
Description copied from interface:GenericsResolverAnalyzes the method in the context of containingClass and returns the Class that is represented by the method's generic return type. Any parameter information in the generic return type is lost. If you want to preserve the type parameters of the return type consider usingGenericsResolver.extractActualType(java.lang.reflect.Type, java.lang.reflect.Method).- Specified by:
extractGenericReturnTypein interfaceGenericsResolver- Parameters:
containingClass- class which either contains or inherited the methodmethod- method from which to extract the return type- Returns:
- the class represented by the methods generic return type, resolved based on the context .
- See Also:
GenericsResolver.resolve(java.lang.reflect.Type,java.lang.reflect.Type),GenericsResolver.asClass(java.lang.reflect.Type)
-
extractGenericFieldType
public java.lang.Class extractGenericFieldType(java.lang.Class containingClass, java.lang.reflect.Field field)
Description copied from interface:GenericsResolverAnalyzes the field in the context of containingClass and returns the Class that is represented by the field's generic type. Any parameter information in the generic type is lost, if you want to preserve the type parameters of the return type consider using #getTypeVariableIndex(java.lang.reflect.TypeVariable).- Specified by:
extractGenericFieldTypein interfaceGenericsResolver- Parameters:
containingClass- class which either contains or inherited the fieldfield- field from which to extract the type- Returns:
- the class represented by the field's generic type, resolved based on the containingClass.
- See Also:
GenericsResolver.extractActualType(java.lang.reflect.Type, java.lang.reflect.Field),GenericsResolver.resolve(java.lang.reflect.Type,java.lang.reflect.Type),GenericsResolver.asClass(java.lang.reflect.Type)
-
extractActualType
public java.lang.reflect.Type extractActualType(java.lang.reflect.Type containingType, java.lang.reflect.Method method)
Description copied from interface:GenericsResolverAnalyzes the method in the context of containingClass and returns the Class that is represented by the method's generic return type. Any parameter information in the generic return type is lost.- Specified by:
extractActualTypein interfaceGenericsResolver- Parameters:
containingType- Type which is/represents the class that either contains or inherited the methodmethod- method from which to extract the generic return type- Returns:
- the generic type represented by the methods generic return type, resolved based on the containingType.
- See Also:
GenericsResolver.resolve(java.lang.reflect.Type,java.lang.reflect.Type)
-
extractActualType
public java.lang.reflect.Type extractActualType(java.lang.reflect.Type containingType, java.lang.reflect.Field field)
Description copied from interface:GenericsResolverAnalyzes the method in the context of containingClass and returns the Class that is represented by the method's generic return type. Any parameter information in the generic return type is lost.- Specified by:
extractActualTypein interfaceGenericsResolver- Parameters:
containingType- Type which is/represents the class that either contains or inherited the fieldfield- field from which to extract the generic return type- Returns:
- the generic type represented by the methods generic return type, resolved based on the containingType.
- See Also:
GenericsResolver.resolve(java.lang.reflect.Type,java.lang.reflect.Type)
-
resolve
public java.lang.reflect.Type resolve(java.lang.reflect.Type type, java.lang.reflect.Type containingType)
Description copied from interface:GenericsResolverResolves the type parameter based on the context of the containingType.TypeVariablewill be unwrapped to the type argument resolved form the class hierarchy. This may be something other than a simple Class if the type argument is a ParameterizedType for instance (e.g.List<E>; List<Map<Long, String>>, E would be returned as a ParameterizedType with the raw type Map and type arguments Long and String.- Specified by:
resolvein interfaceGenericsResolver- Parameters:
type- the generic type (ParameterizedType, GenericArrayType, WildcardType, TypeVariable) to be resolvedcontainingType- the type which his- Returns:
- the type resolved to the best of our ability.
-
asClass
public java.lang.Class asClass(java.lang.reflect.Type actualType)
Description copied from interface:GenericsResolverGet the class represented by the reflected type. This method is lossy; You cannot recover the type information from the class that is returned.TypeVariablethe first bound is returned. If your type variable extends multiple interfaces that information is lost.WildcardTypethe first lower bound is returned. If the wildcard is defined with upper bounds thenObjectis returned.- Specified by:
asClassin interfaceGenericsResolver- Parameters:
actualType- a Class, ParameterizedType, GenericArrayType- Returns:
- the un-parameterized class associated with the type.
-
-