[COLLECTIONS-543] Do not override equals and hashCode for abstract collections.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1671833 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0f4a98cfe1
commit
df22e0c5d2
|
@ -600,42 +600,6 @@ public class AbstractMultiValuedMap<K, V> implements MultiValuedMap<K, V>, Seria
|
|||
return col.toArray(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
final Collection<V> col = getMapping();
|
||||
if (col == null) {
|
||||
return CollectionUtils.EMPTY_COLLECTION.equals(other);
|
||||
}
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
if(!(other instanceof Collection)){
|
||||
return false;
|
||||
}
|
||||
Collection<?> otherCol = (Collection<?>) other;
|
||||
if (CollectionUtils.isEqualCollection(col, otherCol) == false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final Collection<V> col = getMapping();
|
||||
if (col == null) {
|
||||
return CollectionUtils.EMPTY_COLLECTION.hashCode();
|
||||
}
|
||||
int h = 0;
|
||||
Iterator<V> it = col.iterator();
|
||||
while (it.hasNext()) {
|
||||
V val = it.next();
|
||||
if (val != null) {
|
||||
h += val.hashCode();
|
||||
}
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final Collection<V> col = getMapping();
|
||||
|
|
Loading…
Reference in New Issue