public final class SuperTypeToken
extends java.lang.Object
public class MyAvlHashtable, TValue> extends AvlHashtable { public Class<?> keyClass; public Class<?> valueClass; public Type keyType; public Type valueType; public A_MyAvlHashtable() { // retrieves first generic parameter i.e. class type of TKey keyClass = SuperTypeToken.getClazz(this.getClass()); // retrieves second generic parameter valueClass = SuperTypeToken.getClazz(this.getClass(), 1); keyType = SuperTypeToken.getType(this.getClass()); valueType = SuperTypeToken.getType(this.getClass(), 1); } }
Modifier and Type | Method and Description |
---|---|
static java.lang.Class<?> |
getClazz(java.lang.Class<?> clazz)
Returns the Class of a class's first formal type argument.
|
static java.lang.Class<?> |
getClazz(java.lang.Class<?> clazz,
int pos)
Returns the Class of a class's formal type argument, at a given position.
|
static java.lang.reflect.Type |
getType(java.lang.Class<?> clazz)
Returns the Type of a class's first formal type argument Therefore for Blah
|
static java.lang.reflect.Type |
getType(java.lang.Class<?> clazz,
int pos)
Returns the Type of a class's formal type argument, at a given position.
|
public static java.lang.reflect.Type getType(java.lang.Class<?> clazz)
java.lang.NullPointerException
- An argument is nullSuperTypeTokenException
- The class is not a concrete class, not a generic class or not instantiated using anonymous class
semantics.public static java.lang.reflect.Type getType(java.lang.Class<?> clazz, int pos)
java.lang.NullPointerException
- An argument is nullSuperTypeTokenException
- The class is not a concrete class, not a generic class or not instantiated using anonymous class
semantics.public static java.lang.Class<?> getClazz(java.lang.Class<?> clazz)
java.lang.NullPointerException
- An argument is nullSuperTypeTokenException
- The class is not a concrete class, not a generic class or not instantiated using anonymous class
semantics.public static java.lang.Class<?> getClazz(java.lang.Class<?> clazz, int pos)
java.lang.NullPointerException
- An argument is nullSuperTypeTokenException
- The class is not a concrete class, not a generic class or not instantiated using anonymous class
semantics.