Skip to content

Apache Lucene open-source search software

Added hashcode and equals implementations to enable caching

Mark Harwood336d3e7c58cd
diff --git a/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java b/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java
index 6f3c838b11e..07d35634f1e 100644
--- a/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java
+++ b/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java
@@ -134,4 +134,31 @@ public class BooleanFilter extends Filter
notFilters.add(filterClause.getFilter());
}
}
+
+ public boolean equals(Object obj)
+ {
+ if(this == obj)
+ return true;
+ if((obj == null) || (obj.getClass() != this.getClass()))
+ return false;
+ BooleanFilter test = (BooleanFilter)obj;
+ return (notFilters == test.notFilters||
+ (notFilters!= null && notFilters.equals(test.notFilters)))
+ &&
+ (mustFilters == test.mustFilters||
+ (mustFilters!= null && mustFilters.equals(test.mustFilters)))
+ &&
+ (shouldFilters == test.shouldFilters||
+ (shouldFilters!= null && shouldFilters.equals(test.shouldFilters)));
+ }
+
+ public int hashCode()
+ {
+ int hash=7;
+ hash = 31 * hash + (null == mustFilters ? 0 : mustFilters.hashCode());
+ hash = 31 * hash + (null == notFilters ? 0 : notFilters.hashCode());
+ hash = 31 * hash + (null == shouldFilters ? 0 : shouldFilters.hashCode());
+ return hash;
+ }
+
}
\ No newline at end of file