org.kohsuke.stapler.export
Class TypeUtil

java.lang.Object
  extended by org.kohsuke.stapler.export.TypeUtil

public class TypeUtil
extends java.lang.Object

Type arithmetic code. Taken from the JAXB RI.

Author:
Kohsuke Kawaguchi

Constructor Summary
TypeUtil()
           
 
Method Summary
static
<T> java.lang.Class<T>
erasure(java.lang.reflect.Type t)
          Returns the runtime representation of the given type.
static java.lang.reflect.Type getBaseClass(java.lang.reflect.Type type, java.lang.Class baseType)
          Gets the parameterization of the given base type.
static java.lang.reflect.Type getTypeArgument(java.lang.reflect.Type type, int i)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeUtil

public TypeUtil()
Method Detail

erasure

public static <T> java.lang.Class<T> erasure(java.lang.reflect.Type t)
Returns the runtime representation of the given type. This corresponds to the notion of the erasure in JSR-14.


getBaseClass

public static java.lang.reflect.Type getBaseClass(java.lang.reflect.Type type,
                                                  java.lang.Class baseType)
Gets the parameterization of the given base type.

For example, given the following


 interface Foo<T> extends List<List<T>> {}
 interface Bar extends Foo<String> {}
 
This method works like this:

 getBaseClass( Bar, List ) = List<List<String>
 getBaseClass( Bar, Foo  ) = Foo<String>
 getBaseClass( Foo<? extends Number>, Collection ) = Collection<List<? extends Number>>
 getBaseClass( ArrayList<? extends BigInteger>, List ) = List<? extends BigInteger>
 

Parameters:
type - The type that derives from baseType
baseType - The class whose parameterization we are interested in.
Returns:
The use of baseType in type. or null if the type is not assignable to the base type.

getTypeArgument

public static java.lang.reflect.Type getTypeArgument(java.lang.reflect.Type type,
                                                     int i)


Copyright © 2011. All Rights Reserved.