Package org.kohsuke.stapler.export
Class TypeUtil
- java.lang.Object
-
- org.kohsuke.stapler.export.TypeUtil
-
public class TypeUtil extends Object
Type arithmetic code. Taken from the JAXB RI.- Author:
- Kohsuke Kawaguchi
-
-
Constructor Summary
Constructors Constructor Description TypeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Class<T>
erasure(Type t)
Returns the runtime representation of the given type.static Type
getBaseClass(Type type, Class baseType)
Gets the parameterization of the given base type.static Type
getTypeArgument(Type type, int i)
-
-
-
Method Detail
-
erasure
public static <T> Class<T> erasure(Type t)
Returns the runtime representation of the given type. This corresponds to the notion of the erasure in JSR-14.
-
getBaseClass
public static Type getBaseClass(Type type, Class baseType)
Gets the parameterization of the given base type.For example, given the following
This method works like this:interface Foo<T> extends List<List<T>> {} interface Bar extends Foo<String> {}
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 frombaseType
baseType
- The class whose parameterization we are interested in.- Returns:
- The use of
baseType
intype
. or null if the type is not assignable to the base type.
-
-