类 ParameterizedTypeReference<T>
java.lang.Object
cn.taketoday.core.ParameterizedTypeReference<T>
- 类型参数:
T- the referenced type
The purpose of this class is to enable capturing and passing a generic
Type. In order to capture the generic type and retain it at runtime,
you need to create a subclass (ideally as anonymous inline class) as follows:
ParameterizedTypeReference<List<String>> typeRef = new ParameterizedTypeReference<List<String>>() {};
The resulting typeRef instance can then be used to obtain a Type
instance that carries the captured parameterized type information at runtime.
For more information on "super type tokens" see the link to Neal Gafter's blog post.
- 从以下版本开始:
- 3.0 2021/1/6 22:11
- 作者:
- Arjen Poutsma, Rossen Stoyanchev, Harry Yang
- 另请参阅:
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明booleanprivate static Class<?>findTypeReferenceSubclass(Class<?> child) static <T> ParameterizedTypeReference<T>Build aTypeReferencewrapping the given type.final ResolvableTypefinal TypegetType()inthashCode()toString()
-
字段详细资料
-
type
-
-
构造器详细资料
-
ParameterizedTypeReference
protected ParameterizedTypeReference() -
ParameterizedTypeReference
-
-
方法详细资料
-
getResolvableType
-
getType
-
equals
-
hashCode
public int hashCode() -
toString
-
forType
Build aTypeReferencewrapping the given type.- 参数:
type- a generic type (possibly obtained via reflection, e.g. fromMethod.getGenericReturnType())- 返回:
- a corresponding reference which may be passed into
TypeReference-accepting methods
-
findTypeReferenceSubclass
-