Class GenericTypeContext
Currently only used as a representation of type variables of a given type and its supertypes,
in order to retrieve the type arguments of its supertypes.
For instance this class, given the type ArrayList<? extends Map<String, Integer>>,
is able to determine that the type argument for List<?> is ? extends Map<String, Integer>.
This class is able to take into account the declaring context when performing resolution. For instance, given the following model:
class A<T extends C> {
GenericType<T> propertyOfA;
}
class B extends A<D> {
}
class C {
}
class D extends C {
}
class GenericType<T> {
T propertyOfGenericType;
}
... if an instance of this implementation was used to model the type of B.propertyOfA,
then the property B.propertyOfA would appear to have type List<D> as one would expect,
instead of type T extends C if we inferred the type solely based on generics information from type A.
This will also be true for more deeply nested references to a type variable,
for instance the type of property B.propertyOfA.propertyOfGenericType will correctly be inferred as D.
Note that "type resolution" here only covers the resolution of a type parameter to the corresponding argument,
i.e. "shallow" resolution. This class will not build new ParameterizedType instances to recursively
replace type variables with their known value, unlike other libraries such as Guava.
-
Constructor Summary
ConstructorsConstructorDescriptionGenericTypeContext(Type type) GenericTypeContext(GenericTypeContext declaringContext, Type type) GenericTypeContext(GenericTypeContext declaringContext, GenericTypeContext castBase, Type type) -
Method Summary
-
Constructor Details
-
GenericTypeContext
-
GenericTypeContext
-
GenericTypeContext
public GenericTypeContext(GenericTypeContext declaringContext, GenericTypeContext castBase, Type type)
-
-
Method Details