From 336d3e7c58cd9fa9324001328aac77ec9d03a408 Mon Sep 17 00:00:00 2001 From: Mark Harwood Date: Fri, 11 May 2007 07:14:18 +0000 Subject: [PATCH] Added hashcode and equals implementations to enable caching git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@537123 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/search/BooleanFilter.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) 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