org.jboss.resteasy.util
Class Types

java.lang.Object
  extended by org.jboss.resteasy.util.Types

public class Types
extends Object

Type conversions and generic type manipulations

Version:
$Revision: 1 $
Author:
Bill Burke

Nested Class Summary
static class Types.TypeInfo
           
 
Constructor Summary
Types()
           
 
Method Summary
static Type[] getActualTypeArgumentsOfAnInterface(Class<?> classToSearch, Class<?> interfaceToFind)
          Given a class and an interfaces, go through the class hierarchy to find the interface and return its type arguments.
static Type getActualValueOfTypeVariable(Class<?> clazz, TypeVariable<?> typeVariable)
          Finds an actual value of a type variable.
static Class getCollectionBaseType(Class type, Type genericType)
           
static Type[] getGenericParameterTypesOfGenericInterfaceMethod(Class clazz, Method method)
          Given an interface Method, look in the implementing class for the method that implements the interface's method to obtain generic type information.
static Type getGenericReturnTypeOfGenericInterfaceMethod(Class clazz, Method method)
          Given an interface Method, look in the implementing class for the method that implements the interface's method to obtain generic type information.
static Class getMapKeyType(Type genericType)
           
static Class getMapValueType(Type genericType)
           
static Class<?> getRawType(Type type)
           
static Class<?> getRawTypeNoException(Type type)
           
static Class getTemplateParameterOfInterface(Class base, Class desiredInterface)
           
static Class<?> getTypeArgument(Type genericType)
          Returns the type argument from a parameterized type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Types

public Types()
Method Detail

getTemplateParameterOfInterface

public static Class getTemplateParameterOfInterface(Class base,
                                                    Class desiredInterface)

getGenericReturnTypeOfGenericInterfaceMethod

public static Type getGenericReturnTypeOfGenericInterfaceMethod(Class clazz,
                                                                Method method)
Given an interface Method, look in the implementing class for the method that implements the interface's method to obtain generic type information. This is useful for templatized interfaces like:

 interface Foo {

Parameters:
clazz -
method - interface method
Returns:

getGenericParameterTypesOfGenericInterfaceMethod

public static Type[] getGenericParameterTypesOfGenericInterfaceMethod(Class clazz,
                                                                      Method method)
Given an interface Method, look in the implementing class for the method that implements the interface's method to obtain generic type information. This is useful for templatized interfaces like:

 interface Foo {

Parameters:
clazz -
method - interface method
Returns:

getRawType

public static Class<?> getRawType(Type type)

getRawTypeNoException

public static Class<?> getRawTypeNoException(Type type)

getTypeArgument

public static Class<?> getTypeArgument(Type genericType)
Returns the type argument from a parameterized type

Parameters:
genericType -
Returns:
null if there is no type parameter

getCollectionBaseType

public static Class getCollectionBaseType(Class type,
                                          Type genericType)

getMapKeyType

public static Class getMapKeyType(Type genericType)

getMapValueType

public static Class getMapValueType(Type genericType)

getActualValueOfTypeVariable

public static Type getActualValueOfTypeVariable(Class<?> clazz,
                                                TypeVariable<?> typeVariable)
Finds an actual value of a type variable. The method looks in a class hierarchy for a class defining the variable and returns the value if present.

Parameters:
clazz -
typeVariable -
Returns:
actual type of the type variable

getActualTypeArgumentsOfAnInterface

public static Type[] getActualTypeArgumentsOfAnInterface(Class<?> classToSearch,
                                                         Class<?> interfaceToFind)
Given a class and an interfaces, go through the class hierarchy to find the interface and return its type arguments.

Parameters:
classToSearch -
interfaceToFind -
Returns:
type arguments of the interface


Copyright © 2011. All Rights Reserved.