类 TypeReference<T>

java.lang.Object
cn.taketoday.core.TypeReference<T>
类型参数:
T - the referenced type

public abstract class TypeReference<T> extends Object
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:
 TypeReference<List<String>> typeRef = new TypeReference<List<String>>() {};
 
从以下版本开始:
3.0
作者:
TODAY 2021/1/6 22:11
  • 构造器详细资料

    • TypeReference

      protected TypeReference()
  • 方法详细资料

    • getResolvableType

      public final ResolvableType getResolvableType()
    • getType

      public final Type getType()
    • equals

      public boolean equals(Object other)
      覆盖:
      equals 在类中 Object
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object
    • fromType

      public static <T> TypeReference<T> fromType(Type type)
      Build a TypeReference wrapping the given type.
      参数:
      type - a generic type (possibly obtained via reflection, e.g. from Method.getGenericReturnType())
      返回:
      a corresponding reference which may be passed into TypeReference-accepting methods