Class ObjectProjectionBinder
- java.lang.Object
-
- org.hibernate.search.mapper.pojo.search.definition.binding.builtin.ObjectProjectionBinder
-
- All Implemented Interfaces:
ProjectionBinder
public final class ObjectProjectionBinder extends Object implements ProjectionBinder
Binds a constructor parameter to an object projection bound to a specific object field in the indexed document.The content of the object projection is defined in the constructor parameter type by another
ProjectionConstructor.Compared to the basic
composite projection, an object projection is bound to a specific object field, and thus it yields zero, one or many values, as many as there are objects in the targeted object field. Therefore, you must take care of using aList<...>as your constructor parameter type if the object field is multi-valued.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(ProjectionBindingContext context)Binds a constructor parameter to a projection.static ObjectProjectionBindercreate()Creates anObjectProjectionBinderto be passed toMethodParameterMappingStep.projection(ProjectionBinder).static ObjectProjectionBindercreate(String fieldPath)Creates anObjectProjectionBinderto be passed toMethodParameterMappingStep.projection(ProjectionBinder).ObjectProjectionBinderfilter(TreeFilterDefinition filter)StringtoString()
-
-
-
Method Detail
-
create
public static ObjectProjectionBinder create()
Creates anObjectProjectionBinderto be passed toMethodParameterMappingStep.projection(ProjectionBinder).This method requires the projection constructor class to be compiled with the
-parametersflag to infer the field path from the name of the constructor parameter being bound. If this compiler flag is not used, usecreate(String)instead and pass the field path explicitly.- Returns:
- The binder.
-
create
public static ObjectProjectionBinder create(String fieldPath)
Creates anObjectProjectionBinderto be passed toMethodParameterMappingStep.projection(ProjectionBinder).- Parameters:
fieldPath- The path to the index field whose value will be extracted. Whennull, defaults to the name of the constructor parameter being bound, if it can be retrieved (requires the class to be compiled with the-parametersflag; otherwise a nullfieldPathwill lead to a failure).- Returns:
- The binder.
-
filter
public ObjectProjectionBinder filter(TreeFilterDefinition filter)
- Parameters:
filter- The filter to apply to determine which nested index field projections should be included in the projection.- Returns:
this, for method chaining.- See Also:
ObjectProjection.includePaths(),ObjectProjection.excludePaths(),ObjectProjection.includeDepth()
-
bind
public void bind(ProjectionBindingContext context)
Description copied from interface:ProjectionBinderBinds a constructor parameter to a projection.The context passed in parameter provides various information about the constructor parameter being bound. Implementations are expected to take advantage of that information and to call one of the
definition*(...)methods on the context to set the projection.- Specified by:
bindin interfaceProjectionBinder- Parameters:
context- A context object providing information about the constructor parameter being bound, and expecting a call to one of itsdefinition*(...)methods.
-
-