Added must/should/mustNot method variants that accepts vararg FilterBuilder instances.

This commit is contained in:
Martijn van Groningen 2012-11-06 14:23:03 +01:00
parent 31a8e92b8e
commit 4a9faac470
1 changed files with 30 additions and 0 deletions

View File

@ -55,6 +55,36 @@ public class BoolFilterBuilder extends BaseFilterBuilder {
return this;
}
/**
* Adds multiple <i>should</i> filters.
*/
public BoolFilterBuilder should(FilterBuilder... filterBuilders) {
for (FilterBuilder filterBuilder : filterBuilders) {
clauses.add(new Clause(filterBuilder, BooleanClause.Occur.SHOULD));
}
return this;
}
/**
* Adds multiple <i>must</i> filters.
*/
public BoolFilterBuilder must(FilterBuilder... filterBuilders) {
for (FilterBuilder filterBuilder : filterBuilders) {
clauses.add(new Clause(filterBuilder, BooleanClause.Occur.MUST));
}
return this;
}
/**
* Adds multiple <i>must not</i> filters.
*/
public BoolFilterBuilder mustNot(FilterBuilder... filterBuilders) {
for (FilterBuilder filterBuilder : filterBuilders) {
clauses.add(new Clause(filterBuilder, BooleanClause.Occur.MUST_NOT));
}
return this;
}
/**
* Adds a filter that <i>should</i> appear in the matching documents. For a boolean filter
* with no <tt>MUST</tt> clauses one or more <code>SHOULD</code> clauses must match a document