LUCENE-6707: Make PhraseQuery.Builder methods return this to allow chaining.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1693448 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrien Grand 2015-07-30 15:56:55 +00:00
parent e513869cd6
commit c75e5c61d7
1 changed files with 6 additions and 4 deletions

View File

@ -81,16 +81,17 @@ public class PhraseQuery extends Query {
* Set the slop.
* @see PhraseQuery#getSlop()
*/
public void setSlop(int slop) {
public Builder setSlop(int slop) {
this.slop = slop;
return this;
}
/**
* Adds a term to the end of the query phrase.
* The relative position of the term is the one immediately after the last term added.
*/
public void add(Term term) {
add(term, positions.isEmpty() ? 0 : 1 + positions.get(positions.size() - 1));
public Builder add(Term term) {
return add(term, positions.isEmpty() ? 0 : 1 + positions.get(positions.size() - 1));
}
/**
@ -100,7 +101,7 @@ public class PhraseQuery extends Query {
* or phrases with gaps (e.g. in connection with stopwords).
*
*/
public void add(Term term, int position) {
public Builder add(Term term, int position) {
term = new Term(term.field(), BytesRef.deepCopyOf(term.bytes())); // be defensive
if (position < 0) {
throw new IllegalArgumentException("Positions must be >= 0, got " + position);
@ -116,6 +117,7 @@ public class PhraseQuery extends Query {
}
terms.add(term);
positions.add(position);
return this;
}
/**