TypeToken

open class TypeToken<T>

Represents a generic type {@code 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 the type information even at runtime.

For example, to create a type literal for {@code List}, you can create an empty anonymous inner class:

{@code TypeToken

This syntax cannot be used to create type literals that have wildcard parameters, such as {@code Class} or {@code List}.

Author

Bob Lee

Sven Mawson

Jesse Wilson

Functions

equals
Link copied to clipboard
fun equals(o: Any): Boolean
get
Link copied to clipboard
open fun <T> get(type: Class<T>): TypeToken<T>
Gets type literal for the given {@code Class} instance.
open fun get(type: Type): TypeToken<out Any>
Gets type literal for the given {@code Type} instance.
getArray
Link copied to clipboard
open fun getArray(componentType: Type): TypeToken<out Any>
Gets type literal for the array type whose elements are all instances of {@code componentType}.
getParameterized
Link copied to clipboard
open fun getParameterized(rawType: Type, typeArguments: Array<Type>): TypeToken<out Any>
Gets type literal for the parameterized type represented by applying {@code typeArguments} to {@code rawType}.
hashCode
Link copied to clipboard
fun hashCode(): Int
toString
Link copied to clipboard
fun toString(): String

Properties

hashCode
Link copied to clipboard
val hashCode: Int
rawType
Link copied to clipboard
val rawType: Class<out Any>
type
Link copied to clipboard
val type: Type