org.jboss.resteasy.util
Class Types

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

public class Types
extends java.lang.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 java.lang.reflect.Type getActualValueOfTypeVariable(java.lang.Class<?> clazz, java.lang.reflect.TypeVariable<?> typeVariable)
          Finds an actual value of a type variable.
static java.lang.Class getCollectionBaseType(java.lang.Class type, java.lang.reflect.Type genericType)
           
static java.lang.reflect.Type[] getGenericParameterTypesOfGenericInterfaceMethod(java.lang.Class clazz, java.lang.reflect.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 java.lang.reflect.Type getGenericReturnTypeOfGenericInterfaceMethod(java.lang.Class clazz, java.lang.reflect.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 java.lang.Class getMapKeyType(java.lang.reflect.Type genericType)
           
static java.lang.Class getMapValueType(java.lang.reflect.Type genericType)
           
static java.lang.Class<?> getRawType(java.lang.reflect.Type type)
           
static java.lang.Class<?> getRawTypeNoException(java.lang.reflect.Type type)
           
static java.lang.Class getTemplateParameterOfInterface(java.lang.Class base, java.lang.Class desiredInterface)
           
static java.lang.Class<?> getTypeArgument(java.lang.reflect.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 java.lang.Class getTemplateParameterOfInterface(java.lang.Class base,
                                                              java.lang.Class desiredInterface)

getGenericReturnTypeOfGenericInterfaceMethod

public static java.lang.reflect.Type getGenericReturnTypeOfGenericInterfaceMethod(java.lang.Class clazz,
                                                                                  java.lang.reflect.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 java.lang.reflect.Type[] getGenericParameterTypesOfGenericInterfaceMethod(java.lang.Class clazz,
                                                                                        java.lang.reflect.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 java.lang.Class<?> getRawType(java.lang.reflect.Type type)

getRawTypeNoException

public static java.lang.Class<?> getRawTypeNoException(java.lang.reflect.Type type)

getTypeArgument

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

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

getCollectionBaseType

public static java.lang.Class getCollectionBaseType(java.lang.Class type,
                                                    java.lang.reflect.Type genericType)

getMapKeyType

public static java.lang.Class getMapKeyType(java.lang.reflect.Type genericType)

getMapValueType

public static java.lang.Class getMapValueType(java.lang.reflect.Type genericType)

getActualValueOfTypeVariable

public static java.lang.reflect.Type getActualValueOfTypeVariable(java.lang.Class<?> clazz,
                                                                  java.lang.reflect.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


Copyright © 2010. All Rights Reserved.