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
This commit is contained in:
Mark Harwood 2007-05-11 07:14:18 +00:00
parent d759ee642d
commit 336d3e7c58
1 changed files with 27 additions and 0 deletions

View File

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