public final class GenericContextAwarePojoGenericTypeModel<T> extends AbstractPojoGenericTypeModel<T> implements PojoGenericTypeModel<T>
PojoGenericTypeModel that takes advantage of the context
in which a given property appears to derive more precise type information.
Instances wrap a PojoRawTypeModel, and propagate generics information to properties
and their type by wrapping the property models as well.
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.| Modifier and Type | Class and Description |
|---|---|
static interface |
GenericContextAwarePojoGenericTypeModel.Helper |
static class |
GenericContextAwarePojoGenericTypeModel.RawTypeDeclaringContext<T> |
| Modifier and Type | Method and Description |
|---|---|
Optional<PojoGenericTypeModel<?>> |
getArrayElementType() |
String |
getName() |
PojoPropertyModel<?> |
getProperty(String propertyName) |
Optional<PojoGenericTypeModel<?>> |
getTypeArgument(Class<?> rawSuperType,
int typeParameterIndex) |
getRawType, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetRawTypepublic String getName()
getName in interface PojoTypeModel<T>public PojoPropertyModel<?> getProperty(String propertyName)
getProperty in interface PojoTypeModel<T>getProperty in class AbstractPojoGenericTypeModel<T>public Optional<PojoGenericTypeModel<?>> getTypeArgument(Class<?> rawSuperType, int typeParameterIndex)
getTypeArgument in interface PojoGenericTypeModel<T>getTypeArgument in class AbstractPojoGenericTypeModel<T>rawSuperType - The supertype to resolve type parameters fortypeParameterIndex - The index of the type parameter to resolverawSuperType
at index typeParameterIndex, or an empty optional if the current type
does not extend rawSuperType.
Implementations may decide to return a model of the raw type argument, or to retain generics information.public Optional<PojoGenericTypeModel<?>> getArrayElementType()
getArrayElementType in interface PojoGenericTypeModel<T>getArrayElementType in class AbstractPojoGenericTypeModel<T>Copyright © 2006-2020 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.