@@ -0,0 +1,2357 @@
+/*%0A * Copyright 2013 The greplin-lucene-utils Authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.greplin.lucene.filter;%0A%0Aimport org.apache.lucene.search.BooleanClause;%0Aimport org.apache.lucene.search.BooleanFilter;%0Aimport org.apache.lucene.search.Filter;%0A%0A/**%0A * Builder patterns for boolean filters.%0A */%0Apublic class BooleanFilterBuilder %7B%0A%0A  /**%0A   * The filter being built.%0A   */%0A  private BooleanFilter result;%0A%0A%0A  /**%0A   * Constructs a filter builder.%0A   */%0A  public BooleanFilterBuilder() %7B%0A    this.result = new BooleanFilter();%0A  %7D%0A%0A%0A  /**%0A   * Static method that returns a new filter builder.%0A   * @return a new filter builder%0A   */%0A  public static BooleanFilterBuilder builder() %7B%0A    return new BooleanFilterBuilder();%0A  %7D%0A%0A%0A  /**%0A   * Builds the filter builder in to a BooleanFilter.%0A   * @return the built BooleanFilter%0A   */%0A  public final BooleanFilter build() %7B%0A    return this.result;%0A  %7D%0A%0A%0A  /**%0A   * Adds a should clause to the filter.%0A   * @param filter the filter that should match%0A   * @return this object%0A   */%0A  public final BooleanFilterBuilder should(final Filter filter) %7B%0A    if (filter != null) %7B%0A      this.result.add(filter, BooleanClause.Occur.SHOULD);%0A    %7D%0A    return this;%0A  %7D%0A%0A  /**%0A   * Adds a must clause to the filter.%0A   * @param filter the filter that must match%0A   * @return this object%0A   */%0A  public final BooleanFilterBuilder must(final Filter filter) %7B%0A    if (filter != null) %7B%0A      this.result.add(filter, BooleanClause.Occur.MUST);%0A    %7D%0A    return this;%0A  %7D%0A%0A  /**%0A   * Adds a must not clause to the filter.%0A   * @param filter the filter that must not match%0A   * @return this object%0A   */%0A  public final BooleanFilterBuilder mustNot(final Filter filter) %7B%0A    if (filter != null) %7B%0A      this.result.add(filter, BooleanClause.Occur.MUST_NOT);%0A    %7D%0A    return this;%0A  %7D%0A%0A%7D%0A

add BooleanFilterBuilder