Hi everyone,
Following the discussion on concurrent collections, I thought perhaps a better design in allowing for more flexibility of underlying EOL collection types was needed. My proposal is as follows:
All EOL collection types extend EolBag, which already implements Collection and delegates to a wrapped Collection. Extensions, such as EolSet, only need to change the wrapped type. Everything else can be handled automatically by the wrapped implementation. Of course, the equals method needs rethinking. Here is what I have in EolBag, which seems to be working (all tests passing):
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Collection)) return false;
return obj instanceof EolBag ?
Objects.equals(this.wrapped, ((EolBag<?>) obj).wrapped) :
obj.equals(wrapped);
}
@Override
public int hashCode() {
return wrapped.hashCode();
}
@Override
public String toString() {
return getClass().getSimpleName()+" "+wrapped.toString();
}
Does this seem reasonable?
Thanks,
Sina