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
This commit is contained in:
Mark Harwood 2007-05-25 23:23:07 +00:00
parent 304884c660
commit 132c5fd899
1 changed files with 23 additions and 0 deletions

View File

@ -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;
}
}