public class TypeReference<T> extends Object
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 List<String>, you can
create an empty anonymous inner class:
TypeReference<List<String>> list = new TypeReference<List<String>>() {};
This syntax cannot be used to create type literals that have wildcard
parameters, such as Class<?> or List<? extends CharSequence>.| Modifier and Type | Field and Description |
|---|---|
static Type |
LIST_STRING |
| Modifier and Type | Method and Description |
|---|---|
Type |
getType()
Gets underlying
Type instance. |
static Type |
intern(ParameterizedTypeImpl type) |
public static final Type LIST_STRING
public static Type intern(ParameterizedTypeImpl type)
public Type getType()
Type instance.Copyright © 2012–2022 Alibaba Group. All rights reserved.