Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Provided that new HashSet<>().equals(Collections.emptySet()) it would be great if EqualsBuilder also supports that. Currently it checks that left/right classes are subclasses of each other, however that does not hold for collections.
Suggestion: if either left or right is Collection or Map then delegate equals to
public EqualsBuilder reflectionAppend(final Object lhs, final Object rhs) { if (!isEquals()) { return this; } if (lhs == rhs) { return this; } if (lhs == null || rhs == null) { setEquals(false); return this; } if (lhs instanceof Collection || rhs instanceof Collection || lhs instanceof Map || rhs instanceof Map) { setEquals(lhs.equals(rhs)); return this; } ...
Likely this mode should be additionally controlled (switched on/off), as strictly speaking, it won't be a reflection tree walker starting from that field.