Interface ProjectionBindingContext


@Incubating public interface ProjectionBindingContext
See Also:
  • Method Details

    • definition

      <P,C> void definition(Class<P> expectedValueType, org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<? extends C> definition)
      Binds the constructorParameter() to the given projection definition.
      Type Parameters:
      P - The type of single projected value.
      C - The type of values returned by the projection. It may be the same as P, if it is a simple single-valued projection, or a type of the container if the P values are wrapped in some type of container (e.g. Optional<..>, Collection<..>..).
      Parameters:
      expectedValueType - The expected type of the constructorParameter(), 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 the constructorParameter().
    • definition

      <P,C> void definition(Class<P> expectedValueType, org.hibernate.search.engine.environment.bean.BeanHolder<? extends org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<? extends C>> definitionHolder)
      Binds the constructorParameter() to the given projection definition.
      Type Parameters:
      P - The type of single projected value.
      C - The type of values returned by the projection. It may be the same as P, if it is a simple single-valued projection, or a type of the container if the P values are wrapped in some type of container (e.g. Optional<..>, Collection<..>..).
      Parameters:
      expectedValueType - The expected type of the constructorParameter(), 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 - A BeanHolder containing the definition of the projection to bind to the constructorParameter().
    • multi

      @Deprecated(since="8.0") @Incubating Optional<? extends ProjectionBindingMultiContext> multi()
      Deprecated.
      Use containerElement() and various bind methods of this context instead.
      Inspects the type of the constructorParameter() 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

      @Incubating PojoModelConstructorParameter constructorParameter()
      Returns:
      An entry point allowing to inspect the constructor parameter being bound to a projection.
    • containerElement

      @Incubating Optional<PojoModelValue<?>> containerElement()
      Returns:
      An entry point allowing to inspect the constructor parameter container element being bound to a projection. Returns non-empty optional only if a constructorParameter() can be bound to a container-wrapped projection (be it a single-valued optional, or some multi-valued collection).
    • param

      @Deprecated(since="7.0") default Object param(String name)
      Deprecated.
      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

      <T> T param(String name, Class<T> paramType)
      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(since="7.0") default Optional<Object> paramOptional(String name)
      Deprecated.
      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

      <T> Optional<T> paramOptional(String name, Class<T> paramType)
      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 default <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. using ProjectionConstructor).
      filter - The filter to apply to determine which nested index field projections should be included in the projection. See ObjectProjection.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:
      • SearchProjectionFactory.object(String)
      • CompositeProjectionInnerStep.as(Class)
    • createObjectDefinitionMulti

      @Deprecated(since="8.0") @Incubating default <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. using ProjectionConstructor).
      filter - The filter to apply to determine which nested index field projections should be included in the projection. See ObjectProjection.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:
      • SearchProjectionFactory.object(String)
      • CompositeProjectionInnerStep.as(Class)
    • createObjectDefinition

      @Incubating <C,T> org.hibernate.search.engine.environment.bean.BeanHolder<? extends org.hibernate.search.engine.search.projection.definition.ProjectionDefinition<C>> createObjectDefinition(String fieldPath, Class<T> projectedType, org.hibernate.search.engine.common.tree.TreeFilterDefinition filter, org.hibernate.search.engine.search.projection.ProjectionCollector.Provider<T,C> collector)
      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. using ProjectionConstructor).
      filter - The filter to apply to determine which nested index field projections should be included in the projection. See ObjectProjection.includePaths(), ObjectProjection.excludePaths(), ObjectProjection.includeDepth(), ...
      Returns:
      A container-wrapped 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:
      • SearchProjectionFactory.object(String)
      • CompositeProjectionInnerStep.as(Class)
    • 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. using ProjectionConstructor)
      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:
      • SearchProjectionFactory.composite()
      • CompositeProjectionInnerStep.as(Class)
    • isIncluded

      boolean isIncluded(String fieldPath)
      Parameters:
      fieldPath - The (relative) path to an object field in the indexed document.
      Returns:
      true if the field with the given path is included according to surrounding filters (see ObjectProjection.includePaths(), ObjectProjection.excludePaths(), ObjectProjection.includeDepth(), ...). false otherwise. Projections on excluded fields should be replaced with a constant projection returning null or an empty list, as appropriate.
    • projectionCollectorProviderFactory

      @Incubating org.hibernate.search.engine.search.projection.ProjectionCollectorProviderFactory projectionCollectorProviderFactory()
      Returns:
      An instance of a projection collector provider factory capable of supplying a collector provider based on a container and component types.