You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-dev@portals.apache.org by Eric Dalquist <er...@doit.wisc.edu> on 2008/01/07 19:10:00 UTC
1.1.5 DD objects equals & hashCode
Right now none of the pluto descriptor objects override equals and
hashCode. This makes doing comparison of the value of the objects
difficult. Would the pluto developers be open to me submitting a patch
that adds the methods to all DD objects to do value equality checking
based on the properties of each object? There are several places that I
have to compare DD objects and currently have all of the logic to
compare the entire tree. It would also greatly simplify the descriptor
parsing unit tests.
-Eric
Example:
public class CustomPortletModeDD {
private List descriptions = new ArrayList();
private String portletMode;
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof CustomPortletModeDD)) {
return false;
}
final CustomPortletModeDD other = (CustomPortletModeDD)obj;
return
(this.portletMode == null ? other.portletMode == null :
this.portletMode.equals(other.portletMode)) &&
(this.descriptions == null ? other.descriptions == null :
this.descriptions.equals(other.descriptions));
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
int result = 17;
result = 37 * result + (this.portletMode == null ? 0 :
this.portletMode.hashCode());
result = 37 * result + (this.descriptions == null ? 0 :
this.descriptions.hashCode());
return result;
}
}