org.springframework.core
Class GenericTypeResolver

java.lang.Object
  extended by org.springframework.core.GenericTypeResolver

public abstract class GenericTypeResolver
extends java.lang.Object

Helper class for resolving generic types against type variables.

Mainly intended for usage within the framework, resolving method parameter types even when they are declared generically.

Since:
2.5.2
Author:
Juergen Hoeller, Rob Harrop
See Also:
GenericCollectionTypeResolver, JdkVersion

Constructor Summary
GenericTypeResolver()
           
 
Method Summary
static java.lang.reflect.Type getTargetType(MethodParameter methodParam)
          Determine the target type for the given parameter specification.
static java.lang.Class resolveParameterType(MethodParameter methodParam, java.lang.Class clazz)
          Determine the target type for the given generic parameter type.
static java.lang.Class resolveReturnType(java.lang.reflect.Method method, java.lang.Class clazz)
          Determine the target type for the generic return type of the given method.
static java.lang.reflect.Type resolveTypeVariable(java.lang.reflect.TypeVariable tv, java.lang.Class clazz)
          Resolve the given type variable against the given class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericTypeResolver

public GenericTypeResolver()
Method Detail

getTargetType

public static java.lang.reflect.Type getTargetType(MethodParameter methodParam)
Determine the target type for the given parameter specification.

Parameters:
methodParam - the method parameter specification
Returns:
the corresponding generic parameter type

resolveParameterType

public static java.lang.Class resolveParameterType(MethodParameter methodParam,
                                                   java.lang.Class clazz)
Determine the target type for the given generic parameter type.

Parameters:
methodParam - the method parameter specification
clazz - the class to resolve type variables against
Returns:
the corresponding generic parameter or return type

resolveReturnType

public static java.lang.Class resolveReturnType(java.lang.reflect.Method method,
                                                java.lang.Class clazz)
Determine the target type for the generic return type of the given method.

Parameters:
method - the method to introspect
clazz - the class to resolve type variables against
Returns:
the corresponding generic parameter or return type

resolveTypeVariable

public static java.lang.reflect.Type resolveTypeVariable(java.lang.reflect.TypeVariable tv,
                                                         java.lang.Class clazz)
Resolve the given type variable against the given class.

Parameters:
tv - the type variable to resolve
clazz - the class that defines the type variable somewhere in its inheritance hierarchy
Returns:
the resolved type that the variable can get replaced with, or null if none found