public abstract class TypeRef<T> extends Object implements Comparator<T>
该类主要用于传递泛型的类型,避免在运行时期找不到泛型的实际类型。 具体用法:由于本类是一个抽象类,所以需要子类去实现。比如下面的代码实现String的泛型传递。
TypeReference ref = new TypeReference<List<String>>() { };
| 限定符 | 构造器和说明 |
|---|---|
protected |
TypeRef() |
| 限定符和类型 | 方法和说明 |
|---|---|
int |
compare(T o1,
T o2)
Compares its two arguments for order.
|
Class<? super T> |
getRawType()
Returns the raw (non-generic) type for this type.
|
Type |
getType()
Gets underlying
Type instance. |
public Class<? super T> getRawType()
public int compare(T o1, T o2)
compare 在接口中 Comparator<T>Copyright © 2017. All rights reserved.