-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-3200 Extract common min should match options into reused inte…
…rface
- Loading branch information
1 parent
1b7d671
commit ebec41f
Showing
3 changed files
with
66 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...org/hibernate/search/engine/search/predicate/dsl/CommonMinimumShouldMatchOptionsStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.engine.search.predicate.dsl; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import org.hibernate.search.engine.search.common.BooleanOperator; | ||
|
||
/** | ||
* The step in a predicate definition, where optional minimum should match parameters can be set. | ||
* | ||
* @param <S> The "self" type (the actual exposed type of this step). | ||
*/ | ||
public interface CommonMinimumShouldMatchOptionsStep<S extends CommonMinimumShouldMatchOptionsStep<?>> { | ||
|
||
/** | ||
* Add a default <a href="MinimumShouldMatchConditionStep.html#minimumshouldmatch">"minimumShouldMatch" constraint</a>. | ||
* | ||
* @param 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 <a href="MinimumShouldMatchConditionStep.html#minimumshouldmatch-minimum">Definition of the minimum</a> | ||
* for details and possible values, in particular negative values. | ||
* @return {@code this}, for method chaining. | ||
*/ | ||
default S minimumShouldMatchNumber(int matchingClausesNumber) { | ||
return minimumShouldMatch() | ||
.ifMoreThan( 0 ).thenRequireNumber( matchingClausesNumber ) | ||
.end(); | ||
} | ||
|
||
/** | ||
* Add a default <a href="MinimumShouldMatchConditionStep.html#minimumshouldmatch">"minimumShouldMatch" constraint</a>. | ||
* | ||
* @param 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 <a href="MinimumShouldMatchConditionStep.html#minimumshouldmatch-minimum">Definition of the minimum</a> | ||
* for details and possible values, in particular negative values. | ||
* @return {@code this}, for method chaining. | ||
*/ | ||
default S minimumShouldMatchPercent(int matchingClausesPercent) { | ||
return minimumShouldMatch() | ||
.ifMoreThan( 0 ).thenRequirePercent( matchingClausesPercent ) | ||
.end(); | ||
} | ||
|
||
MinimumShouldMatchConditionStep<? extends S> minimumShouldMatch(); | ||
|
||
/** | ||
* Start defining the minimum number of "should" constraints that have to match | ||
* in order for the boolean predicate to match. | ||
* <p> | ||
* See {@link MinimumShouldMatchConditionStep}. | ||
* | ||
* @return A {@link MinimumShouldMatchConditionStep} where constraints can be defined. | ||
*/ | ||
S minimumShouldMatch( | ||
Consumer<? super MinimumShouldMatchConditionStep<?>> constraintContributor); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters