TypeReference<T> Class

Definition

A utility for getting a Java Type from a literal generic Class.

public abstract class TypeReference<T>

Type Parameters

T
Inheritance
java.lang.Object
TypeReference<T>

Inherited Members

java.lang.Object.clone() java.lang.Object.equals(java.lang.Object) java.lang.Object.finalize() java.lang.Object.getClass() java.lang.Object.hashCode() java.lang.Object.notify() java.lang.Object.notifyAll() java.lang.Object.toString() java.lang.Object.wait() java.lang.Object.wait(long) java.lang.Object.wait(long,int)

Constructors

TypeReference()

Creates a new instance of TypeReference<T>. This class implements Super Type Tokens (Gafter's Gadget) as a way to get a reference to generic types in spite of type erasure since, sadly, Foo.class is not valid Java. To get the Type of Class Foo, use the following syntax:

Type fooBarType = (new TypeReference>() { }).getType();

To get the Type of class Foo, use a regular Type Token:

Type fooType = Foo.class;

Methods

getType()

Gets the referenced type.

Applies to