Class GenericContextAwarePojoGenericTypeModel<T>
- java.lang.Object
-
- org.hibernate.search.mapper.pojo.model.spi.AbstractPojoGenericTypeModel<T>
-
- org.hibernate.search.mapper.pojo.model.spi.GenericContextAwarePojoGenericTypeModel<T>
-
- All Implemented Interfaces:
PojoGenericTypeModel<T>,PojoTypeModel<T>
public final class GenericContextAwarePojoGenericTypeModel<T> extends AbstractPojoGenericTypeModel<T> implements PojoGenericTypeModel<T>
An implementation ofPojoGenericTypeModelthat 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:
... if an instance of this implementation was used to model the type ofclass A<T extends C> { GenericType<T> propertyOfA; } class B extends A<D> { } class C { } class D extends C { } class GenericType<T> { T propertyOfGenericType; }B.propertyOfA, then the propertyB.propertyOfAwould appear to have typeList<D>as one would expect, instead of typeT extends Cif we inferred the type solely based on generics information from typeA. This will also be true for more deeply nested references to a type variable, for instance the type of propertyB.propertyOfA.propertyOfGenericTypewill correctly be inferred as D.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGenericContextAwarePojoGenericTypeModel.Helperstatic classGenericContextAwarePojoGenericTypeModel.RawTypeDeclaringContext<T>
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<PojoGenericTypeModel<?>>arrayElementType()Stringname()PojoPropertyModel<?>property(String propertyName)Optional<PojoGenericTypeModel<?>>typeArgument(Class<?> rawSuperType, int typeParameterIndex)-
Methods inherited from class org.hibernate.search.mapper.pojo.model.spi.AbstractPojoGenericTypeModel
rawType, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.hibernate.search.mapper.pojo.model.spi.PojoTypeModel
rawType
-
-
-
-
Method Detail
-
name
public String name()
- Specified by:
namein interfacePojoTypeModel<T>- Returns:
- A human-readable name for this type.
-
property
public PojoPropertyModel<?> property(String propertyName)
- Specified by:
propertyin interfacePojoTypeModel<T>- Overrides:
propertyin classAbstractPojoGenericTypeModel<T>
-
typeArgument
public Optional<PojoGenericTypeModel<?>> typeArgument(Class<?> rawSuperType, int typeParameterIndex)
- Specified by:
typeArgumentin interfacePojoGenericTypeModel<T>- Overrides:
typeArgumentin classAbstractPojoGenericTypeModel<T>- Parameters:
rawSuperType- The supertype to resolve type parameters fortypeParameterIndex- The index of the type parameter to resolve- Returns:
- The model for the type argument for the type parameter defined in
rawSuperTypeat indextypeParameterIndex, or an empty optional if the current type does not extendrawSuperType. Implementations may decide to return a model of the raw type argument, or to retain generics information.
-
arrayElementType
public Optional<PojoGenericTypeModel<?>> arrayElementType()
- Specified by:
arrayElementTypein interfacePojoGenericTypeModel<T>- Overrides:
arrayElementTypein classAbstractPojoGenericTypeModel<T>- Returns:
- The model for the array element type, or an empty optional if the current type is not an array type. Implementations may decide to return a model of the raw array element type, or to retain generics information.
-
-