From 132c5fd8990042df836491c20b53fa55ee25f96b Mon Sep 17 00:00:00 2001 From: Mark Harwood Date: Fri, 25 May 2007 23:23:07 +0000 Subject: [PATCH] Added equals/hashcode implementations to enable caching git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@541816 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/lucene/search/TermsFilter.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/contrib/queries/src/java/org/apache/lucene/search/TermsFilter.java b/contrib/queries/src/java/org/apache/lucene/search/TermsFilter.java index 454af991ad7..a2c15469969 100644 --- a/contrib/queries/src/java/org/apache/lucene/search/TermsFilter.java +++ b/contrib/queries/src/java/org/apache/lucene/search/TermsFilter.java @@ -48,4 +48,27 @@ public class TermsFilter extends Filter } return result; } + + public boolean equals(Object obj) + { + if(this == obj) + return true; + if((obj == null) || (obj.getClass() != this.getClass())) + return false; + TermsFilter test = (TermsFilter)obj; + return (termsList == test.termsList|| + (termsList!= null && termsList.equals(test.termsList))); + } + + public int hashCode() + { + int hash=9; + for (Iterator iter = termsList.iterator(); iter.hasNext();) + { + Term term = (Term) iter.next(); + hash = 31 * hash + term.hashCode(); + } + return hash; + } + }