1 package org.apache.lucene.search;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import org.apache.lucene.search.BooleanClause.Occur;
21 import org.apache.lucene.search.Filter;
24 * A Filter that wrapped with an indication of how that filter
25 * is used when composed with another filter.
26 * (Follows the boolean logic in BooleanClause for composition
29 public final class FilterClause {
31 private final Occur occur;
32 private final Filter filter;
35 * Create a new FilterClause
36 * @param filter A Filter object containing a BitSet
37 * @param occur A parameter implementation indicating SHOULD, MUST or MUST NOT
40 public FilterClause(Filter filter, Occur occur) {
46 * Returns this FilterClause's filter
47 * @return A Filter object
49 public Filter getFilter() {
54 * Returns this FilterClause's occur parameter
55 * @return An Occur object
57 public Occur getOccur() {
62 public boolean equals(Object o) {
65 if (o == null || !(o instanceof FilterClause))
67 final FilterClause other = (FilterClause)o;
68 return this.filter.equals(other.filter)
69 && this.occur == other.occur;
73 public int hashCode() {
74 return filter.hashCode() ^ occur.hashCode();
78 public String toString() {
79 return occur.toString() + filter.toString();