public class VariableTypeInheritanceSearch extends Object
| Constructor | Description |
|---|---|
VariableTypeInheritanceSearch() |
| Modifier and Type | Method | Description |
|---|---|---|
Type |
searchParametrizedType(Type typeToSearch,
TypeVariable<?> typeVar) |
Searches the hierarchy of classes to resolve a type variable.
|
public Type searchParametrizedType(Type typeToSearch, TypeVariable<?> typeVar)
Example 1: typevar is resolved
class GenericClass <T> {
private T genericField;
}
class ConcreteClass extends GenericClass<MyPojo> {
//...
}
In above case when ConcreteClass type is passed as runtime type and <T> as type variable, T is resolved to MyPojo.
Example 2: typevar is resolved to another propagated typevar
class WrapperGenericClass<X> {
private GenericClass<X> propagatedGenericField
}
class AnotherClass extends WrapperGenericClass<MyPojo> {
}
In second case when GenericClass ParameterizedType is passed as runtime type and <T> as type variable,
T is resolved to propagated <X> by WrapperGenericClass.
Resolution on <X> must be performed thereafter with AnotherClass runtime type.
typeToSearch - runtime type to search for typevar in, not nulltypeVar - type variable to resolve, not nullCopyright © 2018 Oracle Corporation. All rights reserved.