Interface BooleanPredicateOptionsCollector<S extends BooleanPredicateOptionsCollector<?>>
- Type Parameters:
S
- The "self" type (the actual exposed type of this collector).
- All Known Subinterfaces:
BooleanPredicateClausesStep<S>
,GenericBooleanPredicateClausesStep<S,
C>
boolean predicate
can be set.
Different types of clauses have different effects, see below.
"must" clauses
"must" clauses are required to match: if they don't match, then the boolean predicate will not match.
Matching "must" clauses are taken into account during score computation.
"must not" clauses
"must not" clauses are required to not match: if they match, then the boolean predicate will not match.
"must not" clauses are ignored during score computation.
"filter" clauses
"filter" clauses are required to match: if they don't match, then the boolean predicate will not match.
"filter" clauses are ignored during score computation, and so are any clauses of boolean predicates contained in the filter clause (even "must" or "should" clauses).
"should" clauses
"should" clauses may optionally match, and are required to match depending on the context.
Matching "should" clauses are taken into account during score computation.
The exact behavior of `should` clauses is as follows:
- When there isn't any "must" clause nor any "filter" clause in the boolean predicate, then at least one "should" clause is required to match. Simply put, in this case, the "should" clauses behave as if there was an "OR" operator between each of them.
- When there is at least one "must" clause or one "filter" clause in the boolean predicate, then the "should" clauses are not required to match, and are simply used for scoring.
- This behavior can be changed by specifying "minimumShouldMatch" constraints.
-
Method Summary
Modifier and TypeMethodDescriptionfilter
(Function<? super SearchPredicateFactory, ? extends PredicateFinalStep> clauseContributor) Add a "filter" clause to be defined by the given function.default S
filter
(PredicateFinalStep dslFinalStep) Add a "filter" clause based on an almost-builtSearchPredicate
.filter
(SearchPredicate searchPredicate) Add a "filter" clause based on a previously-builtSearchPredicate
.boolean
Checks if this predicate contains at least one clause.MinimumShouldMatchConditionStep<? extends S>
Start defining the minimum number of "should" constraints that have to match in order for the boolean predicate to match.minimumShouldMatch
(Consumer<? super MinimumShouldMatchConditionStep<?>> constraintContributor) Start defining the minimum number of "should" constraints that have to match in order for the boolean predicate to match.default S
minimumShouldMatchNumber
(int matchingClausesNumber) Add a default "minimumShouldMatch" constraint.default S
minimumShouldMatchPercent
(int matchingClausesPercent) Add a default "minimumShouldMatch" constraint.must
(Function<? super SearchPredicateFactory, ? extends PredicateFinalStep> clauseContributor) Add a "must" clause to be defined by the given function.default S
must
(PredicateFinalStep dslFinalStep) Add a "must" clause based on an almost-builtSearchPredicate
.must
(SearchPredicate searchPredicate) Add a "must" clause based on a previously-builtSearchPredicate
.mustNot
(Function<? super SearchPredicateFactory, ? extends PredicateFinalStep> clauseContributor) Add a "must not" clause to be defined by the given function.default S
mustNot
(PredicateFinalStep dslFinalStep) Add a "must not" clause based on an almost-builtSearchPredicate
.mustNot
(SearchPredicate searchPredicate) Add a "must not" clause based on a previously-builtSearchPredicate
.should
(Function<? super SearchPredicateFactory, ? extends PredicateFinalStep> clauseContributor) Add a "should" clause to be defined by the given function.default S
should
(PredicateFinalStep dslFinalStep) Add a "should" clause based on an almost-builtSearchPredicate
.should
(SearchPredicate searchPredicate) Add a "should" clause based on a previously-builtSearchPredicate
.Delegates setting clauses and options to a given consumer.
-
Method Details
-
with
Delegates setting clauses and options to a given consumer.Best used with lambda expressions.
- Parameters:
contributor
- A consumer that will add clauses and options to the collector that it consumes. Should generally be a lambda expression.- Returns:
this
, for method chaining.
-
must
Add a "must" clause based on a previously-builtSearchPredicate
.- Parameters:
searchPredicate
- The predicate that must match.- Returns:
this
, for method chaining.
-
mustNot
Add a "must not" clause based on a previously-builtSearchPredicate
.- Parameters:
searchPredicate
- The predicate that must not match.- Returns:
this
, for method chaining.
-
should
Add a "should" clause based on a previously-builtSearchPredicate
.- Parameters:
searchPredicate
- The predicate that should match.- Returns:
this
, for method chaining.
-
filter
Add a "filter" clause based on a previously-builtSearchPredicate
.- Parameters:
searchPredicate
- The predicate that must match.- Returns:
this
, for method chaining.
-
must
Add a "must" clause based on an almost-builtSearchPredicate
.- Parameters:
dslFinalStep
- A final step in the predicate DSL allowing the retrieval of aSearchPredicate
.- Returns:
this
, for method chaining.
-
mustNot
Add a "must not" clause based on an almost-builtSearchPredicate
.- Parameters:
dslFinalStep
- A final step in the predicate DSL allowing the retrieval of aSearchPredicate
.- Returns:
this
, for method chaining.
-
should
Add a "should" clause based on an almost-builtSearchPredicate
.- Parameters:
dslFinalStep
- A final step in the predicate DSL allowing the retrieval of aSearchPredicate
.- Returns:
this
, for method chaining.
-
filter
Add a "filter" clause based on an almost-builtSearchPredicate
.- Parameters:
dslFinalStep
- A final step in the predicate DSL allowing the retrieval of aSearchPredicate
.- Returns:
this
, for method chaining.
-
must
Add a "must" clause to be defined by the given function.Best used with lambda expressions.
- Parameters:
clauseContributor
- A function that will use the factory passed in parameter to create a predicate, returning the final step in the predicate DSL. Should generally be a lambda expression.- Returns:
this
, for method chaining.
-
mustNot
Add a "must not" clause to be defined by the given function.Best used with lambda expressions.
- Parameters:
clauseContributor
- A function that will use the factory passed in parameter to create a predicate, returning the final step in the predicate DSL. Should generally be a lambda expression.- Returns:
this
, for method chaining.
-
should
Add a "should" clause to be defined by the given function.Best used with lambda expressions.
- Parameters:
clauseContributor
- A function that will use the factory passed in parameter to create a predicate, returning the final step in the predicate DSL. Should generally be a lambda expression.- Returns:
this
, for method chaining.
-
filter
Add a "filter" clause to be defined by the given function.Best used with lambda expressions.
- Parameters:
clauseContributor
- A function that will use the factory passed in parameter to create a predicate, returning the final step in the predicate DSL. Should generally be a lambda expression.- Returns:
this
, for method chaining.
-
minimumShouldMatchNumber
Add a default "minimumShouldMatch" constraint.- Parameters:
matchingClausesNumber
- A definition of the number of "should" clauses that have to match. If positive, it is the number of clauses that have to match. See Definition of the minimum for details and possible values, in particular negative values.- Returns:
this
, for method chaining.
-
minimumShouldMatchPercent
Add a default "minimumShouldMatch" constraint.- Parameters:
matchingClausesPercent
- A definition of the number of "should" clauses that have to match, as a percentage. If positive, it is the percentage of the total number of "should" clauses that have to match. See Definition of the minimum for details and possible values, in particular negative values.- Returns:
this
, for method chaining.
-
minimumShouldMatch
MinimumShouldMatchConditionStep<? extends S> minimumShouldMatch()Start defining the minimum number of "should" constraints that have to match in order for the boolean predicate to match.- Returns:
- A
MinimumShouldMatchConditionStep
where constraints can be defined.
-
minimumShouldMatch
Start defining the minimum number of "should" constraints that have to match in order for the boolean predicate to match.- Parameters:
constraintContributor
- A consumer that will add constraints to the DSL step passed in parameter. Should generally be a lambda expression.- Returns:
this
, for method chaining.
-
hasClause
boolean hasClause()Checks if this predicate contains at least one clause.- Returns:
true
if any clauses were added, i.e. any of themust(..)
/should(..)
/mustNot(..)
/filter(..)
were called at least once,false
otherwise.
-