Kotlin Type Token
Represents a generic type T.
You must make a subclass with the desired type, for example, for a List<String>
:
var typeToken = new KotlinTypeToken<List<String>>() {};
Content copied to clipboard
However, you cannot create a KotlinTypeToken from a type variable (a generic, if you prefer):
<T> void myMethod() {
// Doesn't work!
var typeToken = new KotlinTypeToken<T>() {};
}
Content copied to clipboard
In other cases, you can create instances for any type using the static factory methods.