FacetField and Count : Override equals() and hashCode()
-------------------------------------------------------
Key: SOLR-3136
URL: https://issues.apache.org/jira/browse/SOLR-3136
Project: Solr
Issue Type: Improvement
Components: clients - java
Affects Versions: 3.5
Reporter: Chantal Ackermann
Priority: Trivial
Overriding equals() and hashCode() of FacetField and Count to provide equality
based on content (on their properties) would allow using these classes in sets
and as keys in maps.
Implementation via commons-lang (which is already a dependency) should be
fairly straight forward?
For FacetFields, compare name, gap and end but not the list of counts:
public boolean equals(Object o) {
if (o != null && o instanceof FacetField) {
FacetField ff = (FacetField)o;
return new EqualsBuilder().append(_name, ff._name).append(_gap,
ff._gap).append(_end, ff._end).isEquals();
}
return false;
}
public int hashCode() {
return new
HashCodeBuilder(33,11).append(_name).append(_gap).append(_end).toHashCode();
}
For Count compare FacetField, name and count:
public boolean equals(Object o) {
if (o != null && o instanceof Count) {
Count c = (Count)o;
return new EqualsBuilder().append(_ff, c._ff).append(_name,
c._name).append(_count, c._count).isEquals();
}
return false;
}
public int hashCode() {
return new
HashCodeBuilder(35,17).append(_ff).append(_name).append(_count).toHashCode();
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]