Interface ProjectionBindingContext
@Incubating
public interface ProjectionBindingContext
The context passed to
ProjectionBinder.bind(ProjectionBindingContext).- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionorg.hibernate.search.engine.environment.bean.BeanResolver<T> org.hibernate.search.engine.environment.bean.BeanHolder<? extends org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<T>> createCompositeDefinition(Class<T> projectedType) <T> org.hibernate.search.engine.environment.bean.BeanHolder<? extends org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<T>> createObjectDefinition(String fieldPath, Class<T> projectedType, org.hibernate.search.engine.common.tree.TreeFilterDefinition filter) <T> org.hibernate.search.engine.environment.bean.BeanHolder<? extends org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<List<T>>> createObjectDefinitionMulti(String fieldPath, Class<T> projectedType, org.hibernate.search.engine.common.tree.TreeFilterDefinition filter) <P> voiddefinition(Class<P> expectedValueType, org.hibernate.search.engine.environment.bean.BeanHolder<? extends org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<? extends P>> definitionHolder) Binds theconstructorParameter()to the given projection definition.<P> voiddefinition(Class<P> expectedValueType, org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<? extends P> definition) Binds theconstructorParameter()to the given projection definition.booleanisIncluded(String fieldPath) Optional<? extends ProjectionBindingMultiContext> multi()Inspects the type of theconstructorParameter()to determine if it may be bound to a multi-valued projection.default ObjectDeprecated.<T> TparamOptional(String name) Deprecated.UseparamOptional(String, Class)instead.<T> Optional<T> paramOptional(String name, Class<T> paramType)
-
Method Details
-
definition
<P> void definition(Class<P> expectedValueType, org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<? extends P> definition) Binds theconstructorParameter()to the given projection definition.- Type Parameters:
P- The type of values returned by the projection.- Parameters:
expectedValueType- The expected type of theconstructorParameter(), which must be compatible with the given projection definition. Hibernate Search will check that these expectations are met, and throw an exception if they are not.definition- A definition of the projection to bind to theconstructorParameter().
-
definition
<P> void definition(Class<P> expectedValueType, org.hibernate.search.engine.environment.bean.BeanHolder<? extends org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<? extends P>> definitionHolder) Binds theconstructorParameter()to the given projection definition.- Type Parameters:
P- The type of values returned by the projection.- Parameters:
expectedValueType- The expected type of theconstructorParameter(), which must be compatible with the given projection definition. Hibernate Search will check that these expectations are met, and throw an exception if they are not.definitionHolder- ABeanHoldercontaining the definition of the projection to bind to theconstructorParameter().
-
multi
Inspects the type of theconstructorParameter()to determine if it may be bound to a multi-valued projection.- Returns:
- An optional containing a context that can be used to bind a projection
if the type of the
constructorParameter()can be bound to a multi-valued projection; an empty optional otherwise.
-
beanResolver
org.hibernate.search.engine.environment.bean.BeanResolver beanResolver()- Returns:
- A bean provider, allowing the retrieval of beans, including CDI/Spring DI beans when in the appropriate environment.
-
constructorParameter
- Returns:
- An entry point allowing to inspect the constructor parameter being bound to a projection.
-
param
Deprecated.Useparam(String, Class)instead.- Parameters:
name- The name of the parameter.- Returns:
- The value provided for this parameter.
- Throws:
org.hibernate.search.util.common.SearchException- If no value was provided for this parameter.- See Also:
-
param
- Type Parameters:
T- The type of the parameter.- Parameters:
name- The name of the parameter.paramType- The type of the parameter.- Returns:
- The value provided for this parameter.
- Throws:
org.hibernate.search.util.common.SearchException- If no value was provided for this parameter.- See Also:
-
paramOptional
Deprecated.UseparamOptional(String, Class)instead.- Parameters:
name- The name of the parameter.- Returns:
- An optional containing the value provided for this parameter,
or
Optional.empty()if no value was provided for this parameter. - See Also:
-
paramOptional
- Type Parameters:
T- The type of the parameter.- Parameters:
name- The name of the parameter.paramType- The type of the parameter.- Returns:
- An optional containing the value provided for this parameter,
or
Optional.empty()if no value was provided for this parameter. - See Also:
-
createObjectDefinition
@Incubating <T> org.hibernate.search.engine.environment.bean.BeanHolder<? extends org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<T>> createObjectDefinition(String fieldPath, Class<T> projectedType, org.hibernate.search.engine.common.tree.TreeFilterDefinition filter) - Parameters:
fieldPath- The (relative) path to an object field in the indexed document.projectedType- A type expected to have a corresponding projection mapping (e.g. usingProjectionConstructor).filter- The filter to apply to determine which nested index field projections should be included in the projection. SeeObjectProjection.includePaths(),ObjectProjection.excludePaths(),ObjectProjection.includeDepth(), ...- Returns:
- A single-valued object projection definition for the given type.
- Throws:
org.hibernate.search.util.common.SearchException- If mapping the given type to a projection definition fails.- See Also:
-
createObjectDefinitionMulti
@Incubating <T> org.hibernate.search.engine.environment.bean.BeanHolder<? extends org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<List<T>>> createObjectDefinitionMulti(String fieldPath, Class<T> projectedType, org.hibernate.search.engine.common.tree.TreeFilterDefinition filter) - Parameters:
fieldPath- The (relative) path to an object field in the indexed document.projectedType- A type expected to have a corresponding projection mapping (e.g. usingProjectionConstructor).filter- The filter to apply to determine which nested index field projections should be included in the projection. SeeObjectProjection.includePaths(),ObjectProjection.excludePaths(),ObjectProjection.includeDepth(), ...- Returns:
- A multi-valued object projection definition for the given type.
- Throws:
org.hibernate.search.util.common.SearchException- If mapping the given type to a projection definition fails.- See Also:
-
createCompositeDefinition
@Incubating <T> org.hibernate.search.engine.environment.bean.BeanHolder<? extends org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<T>> createCompositeDefinition(Class<T> projectedType) - Parameters:
projectedType- A type expected to have a corresponding projection mapping (e.g. usingProjectionConstructor)- Returns:
- A composite projection definition for the given type.
- Throws:
org.hibernate.search.util.common.SearchException- If mapping the given type to a projection definition fails.- See Also:
-
isIncluded
- Parameters:
fieldPath- The (relative) path to an object field in the indexed document.- Returns:
trueif the field with the given path is included according to surroundingfilters(seeObjectProjection.includePaths(),ObjectProjection.excludePaths(),ObjectProjection.includeDepth(), ...).falseotherwise. Projections on excluded fields should be replaced with a constant projection returningnullor an empty list, as appropriate.
-
param(String, Class)instead.