+ add equals/hashcode contract to Redis collections

This commit is contained in:
Costin Leau
2010-11-10 20:08:54 +02:00
parent fdee35f462
commit 73ced03eae

View File

@@ -92,4 +92,26 @@ public abstract class AbstractRedisCollection<E> extends AbstractCollection<E> i
public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object o) {
if (o == this)
return true;
if (o instanceof RedisStore) {
return key.equals(((RedisStore) o).getKey());
}
if (o instanceof AbstractRedisCollection) {
return o.hashCode() == hashCode();
}
return false;
}
@Override
public int hashCode() {
int result = 17 + getClass().hashCode();
result = result * 31 + key.hashCode();
return result;
}
}