Hi,
this is my first post ever to a mailing list so please do not mind to tell
me if I do sth. wrong... ;)
I just asked myself why the EqualsBuilder does not support the comparison of
Collections. Personally, I am very often in the situation that I have to
compare Collections. Collections are widely used and there might be other
people out there that need a proper support for this case. As you might know
the problem when just calling .equals(other) on an object is, that both
Collections need to have the same order. But two Collections should
definitely be equal if they contain the same elements, ordering is not
important!
The following code respects this and is my proposal to enhance the
EqualsBuilder.
--snip-->
public EqualsBuilder append(Collection lhs, Collection rhs) {
if (isEquals == false) {
return this;
}
if (lhs == rhs) {
return this;
}
if (lhs == null || rhs == null) {
this.setEquals(false);
return this;
}
if (lhs.size() != rhs.size()) {
this.setEquals(false);
return this;
}
if (lhs.size() == Integer.MAX_VALUE) {
if (!lhs.containsAll(rhs) || !rhs.containsAll(lhs)) {
this.setEquals(false);
}
return this;
}
if (!lhs.containsAll(rhs)) {
this.setEquals(false);
}
return this;
}
<--snap--
Looking forward to your comments!
Kind Regards,
Matthias Pfau
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]