|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.pivot.util.TypeLiteral<T>
T - note that in Tree the type parameter currently it's not usedpublic class TypeLiteral<T>
Represents a generic type T. Java doesn't yet provide a way to
represent generic types, so this class does. Clients create a subclass
of this class, which enables retrieval the type information even at runtime.
For example, to get a reference to a generic type List<String>, you
create an empty anonymous inner class, like so:
Type genericType = (new TypeLiteral<List<String>>() {}).getType();
This class is a drastically reduced derivation from
Google Guice's
TypeLiteral class, written by Bob Lee and Jesse Wilson.
| Constructor Summary | |
|---|---|
protected |
TypeLiteral()
Constructs a new type literal. |
| Method Summary | |
|---|---|
Type |
getType()
Gets underlying Type instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected TypeLiteral()
Clients create an empty anonymous subclass. Doing so embeds the type parameter in the anonymous class's type hierarchy so we can reconstitute it at runtime despite erasure.
| Method Detail |
|---|
public final Type getType()
Type instance.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||