Skip to content

Commit

Permalink
[COLLECTIONS-543] Do not override equals and hashCode for abstract co…
Browse files Browse the repository at this point in the history
…llections.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1671833 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
netomi committed Apr 7, 2015
1 parent 0f4a98c commit df22e0c
Showing 1 changed file with 0 additions and 36 deletions.
Expand Up @@ -600,42 +600,6 @@ public <T> T[] toArray(T[] a) {
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();
Expand Down

0 comments on commit df22e0c

Please sign in to comment.