public final class GenericContextAwarePojoGenericTypeModel<T> extends Object implements PojoGenericTypeModel<T>
PojoGenericTypeModel
that take 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) |
PojoRawTypeModel<? super T> |
getRawType() |
Optional<PojoGenericTypeModel<?>> |
getTypeArgument(Class<?> rawSuperType,
int typeParameterIndex) |
String |
toString() |
public String getName()
getName
in interface PojoTypeModel<T>
public PojoRawTypeModel<? super T> getRawType()
getRawType
in interface PojoTypeModel<T>
Class
for this type.public PojoPropertyModel<?> getProperty(String propertyName)
getProperty
in interface PojoTypeModel<T>
public Optional<PojoGenericTypeModel<?>> getTypeArgument(Class<?> rawSuperType, int typeParameterIndex)
getTypeArgument
in interface PojoGenericTypeModel<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>
Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.