deepEquals
org.apache.commons.lang.ObjectUtils
public boolean deepEquals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ThisClass other = (ThisClass) o;
if(!ObjectUtils.equals(this.getFoo(), other.getFoo())) {
return false;
}
if(!ObjectUtils.equals(this.getBar(), other.getBar())) {
return false;
}
...
return true;
}
Also need to cascade into collections. Pass along a result object to track status and differences for reporting. Don't fail fast because reporting differences is extremely useful for debugging.
public boolean deepEquals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ThisClass other = (ThisClass) o;
if(!ObjectUtils.equals(this.getFoo(), other.getFoo())) {
return false;
}
if(!ObjectUtils.equals(this.getBar(), other.getBar())) {
return false;
}
...
return true;
}
Also need to cascade into collections. Pass along a result object to track status and differences for reporting. Don't fail fast because reporting differences is extremely useful for debugging.
Comments