public class TypeMath extends Object
Static Methods | |
---|---|
<T1,T2> ClassType<T2> |
doCaptureConversion(ClassType<T1> type)
Perform capture conversion.
|
boolean |
isSubType(ReferenceType<?> typeA,
ReferenceType<?> typeB)
Test whether `typeA` is a subtype of `typeB`.
|
ClassType<?> |
getSuperType(ClassType<?> type,
Class<?> superClass)
Get the supertype of `type` at the specified `superClass`.
|
ClassType<?> |
diamondInfer(ClassType<?> targetType,
Class<?> genericClass)
Do diamond inference.
|
public static <T1,T2> ClassType<T2> doCaptureConversion(ClassType<T1> type)
public static boolean isSubType(ReferenceType<?> typeA, ReferenceType<?> typeB)
public static ClassType<?> getSuperType(ClassType<?> type, Class<?> superClass)
For example,
getSuperType( ArrayList<String> , Collection.class) => Collection<String>
`type` must not contain wildcard; if necessary, caller should do wildcard capture first.
public static ClassType<?> diamondInfer(ClassType<?> targetType, Class<?> genericClass) throws RuntimeException
For example
diamondInfer( List<? extends String> , ArrayList.class ) => ArrayList<String> // as how javac performs diamond inference on List<? extends String> list = new ArrayList<>();
RuntimeException
- if inference fails