# TypeToken

open class TypeToken<T>
Content copied to clipboard

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
Content copied to clipboard
get
Link copied to clipboard
open fun <T> get(type: Class<T>): TypeToken<T>
Content copied to clipboard
Gets type literal for the given `{@code Class}` instance.
open fun get(type: Type): TypeToken<out Any>
Content copied to clipboard
Gets type literal for the given `{@code Type}` instance.
getArray
Link copied to clipboard
open fun getArray(componentType: Type): TypeToken<out Any>
Content copied to clipboard
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>
Content copied to clipboard
Gets type literal for the parameterized type represented by applying `{@code typeArguments}` to `{@code rawType}`.
hashCode
Link copied to clipboard
fun hashCode(): Int
Content copied to clipboard
isAssignableFrom
Link copied to clipboard
@Deprecated()
open fun isAssignableFrom(token: TypeToken<out Any>): Boolean
Content copied to clipboard
Check if this type is assignable from the given type token.
@Deprecated()
open fun isAssignableFrom(cls: Class<out Any>): Boolean
Content copied to clipboard
Check if this type is assignable from the given class object.
@Deprecated()
open fun isAssignableFrom(from: Type): Boolean
Content copied to clipboard
Check if this type is assignable from the given Type.
toString
Link copied to clipboard
fun toString(): String
Content copied to clipboard

## Properties

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