T. Java doesn't yet provide a way to represent generic types,
so this class does. Forces clients to create a subclass of this class which enables retrieval of
the type information even at runtime.
For example, to create a type literal for List<String>, you can create an empty anonymous
inner class:
TypeLiteral<List<String>> list = new TypeLiteral<List<String>>() {};
org.graalvm.polyglot.Value#as(TypeLiteral)
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| private static Class | |
| public final boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
| private static Type | |
| private static Class | |
| public final Class | |
| public final Type | |
| public final int | |
| public final String |
| rawType | back to summary |
|---|---|
| private final Class<T> rawType | |
| type | back to summary |
|---|---|
| private final Type type | |
| TypeLiteral | back to summary |
|---|---|
| protected TypeLiteral() Constructs a new type literal. Derives represented class from type parameter. 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.
| |
| arrayTypeFromComponentType | back to summary |
|---|---|
| private static Class | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| extractLiteralType | back to summary |
|---|---|
| private static Type extractLiteralType(Class<? extends TypeLiteral<T>> literalClass) | |
| extractRawType | back to summary |
|---|---|
| private static Class | |
| getRawType | back to summary |
|---|---|
| public final Class Returns the raw class type of the literal.
| |
| getType | back to summary |
|---|---|
| public final Type getType() Returns the type literal including generic type information.
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public final String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |