Package org.apache.tapestry5.genericsresolverguava.internal

# Class GuavaGenericsResolver

java.lang.Object
org.apache.tapestry5.genericsresolverguava.internal.GuavaGenericsResolver

All Implemented Interfaces:
  `GenericsResolver`

public class GuavaGenericsResolver extends Object implements GenericsResolver
`GuavaGenericsResolver` implementation 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

  Modifier and Type
  Method
  Description
  `Class`
  `asClass(Type actualType)`
  Get the class represented by the reflected type.
  `Type`
  `extractActualType(Type containingType, Field field)`
  Analyzes the method in the context of containingClass and returns the Class that is represented by the method's generic return type.
  `Type`
  `extractActualType(Type containingType, Method method)`
  Analyzes the method in the context of containingClass and returns the Class that is represented by the method's generic return type.
  `Class`
  `extractGenericFieldType(Class containingClass, Field field)`
  Analyzes the field in the context of containingClass and returns the Class that is represented by the field's generic type.
  `Class<?>`
  `extractGenericReturnType(Class<?> containingClass, Method method)`
  Analyzes the method in the context of containingClass and returns the Class that is represented by the method's generic return type.
  `Type`
  `resolve(Type type, Type containingType)`
  Resolves the type parameter based on the context of the containingType.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### GuavaGenericsResolver

    public GuavaGenericsResolver()

- ## Method Details

  - ### extractGenericReturnType

    public Class<?> extractGenericReturnType(Class<?> containingClass, Method method)
    Description copied from interface: `GenericsResolver`
    Analyzes 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 using `GenericsResolver.extractActualType(java.lang.reflect.Type, java.lang.reflect.Method)`.
    Specified by:
      `extractGenericReturnType` in interface `GenericsResolver`
    Parameters:
      `containingClass` - class which either contains or inherited the method
      `method` - 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 Class extractGenericFieldType(Class containingClass, Field field)
    Description copied from interface: `GenericsResolver`
    Analyzes 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:
      `extractGenericFieldType` in interface `GenericsResolver`
    Parameters:
      `containingClass` - class which either contains or inherited the field
      `field` - 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 Type extractActualType(Type containingType, Method method)
    Description copied from interface: `GenericsResolver`
    Analyzes 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:
      `extractActualType` in interface `GenericsResolver`
    Parameters:
      `containingType` - Type which is/represents the class that either contains or inherited the method
      `method` - 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 Type extractActualType(Type containingType, Field field)
    Description copied from interface: `GenericsResolver`
    Analyzes 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:
      `extractActualType` in interface `GenericsResolver`
    Parameters:
      `containingType` - Type which is/represents the class that either contains or inherited the field
      `field` - 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 Type resolve(Type type, Type containingType)
    Description copied from interface: `GenericsResolver`
    Resolves the type parameter based on the context of the containingType. `TypeVariable` will 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:
      `resolve` in interface `GenericsResolver`
    Parameters:
      `type` - the generic type (ParameterizedType, GenericArrayType, WildcardType, TypeVariable) to be resolved
      `containingType` - the type which his
    Returns:
      the type resolved to the best of our ability.

  - ### asClass

    public Class asClass(Type actualType)
    Description copied from interface: `GenericsResolver`
    Get the class represented by the reflected type. This method is lossy; You cannot recover the type information from the class that is returned. `TypeVariable` the first bound is returned. If your type variable extends multiple interfaces that information is lost. `WildcardType` the first lower bound is returned. If the wildcard is defined with upper bounds then `Object` is returned.
    Specified by:
      `asClass` in interface `GenericsResolver`
    Parameters:
      `actualType` - a Class, ParameterizedType, GenericArrayType
    Returns:
      the un-parameterized class associated with the type.