public class TypeUtil
extends java.lang.Object
Constructor and Description |
---|
TypeUtil() |
Modifier and Type | Method and Description |
---|---|
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) |
public static <T> java.lang.Class<T> erasure(java.lang.reflect.Type t)
public static java.lang.reflect.Type getBaseClass(java.lang.reflect.Type type, java.lang.Class baseType)
For example, given the following
This method works like this:interface Foo extends List > {} interface Bar extends Foo
{}
getBaseClass( Bar, List ) = List getBaseClass( Bar, Foo ) = Foo
getBaseClass( Foo extends Number>, Collection ) = Collection > getBaseClass( ArrayList extends BigInteger>, List ) = List extends BigInteger>
type
- The type that derives from baseType
baseType
- The class whose parameterization we are interested in.baseType
in type
.
or null if the type is not assignable to the base type.public static java.lang.reflect.Type getTypeArgument(java.lang.reflect.Type type, int i)
Copyright © 2013. All Rights Reserved.