Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [epsilon-dev] EOL collection inheritance redesign

Hi Sina,

That looks good to me. I'd suggest setting up a feature branch for it, so we can review it before it gets merged.

Cheers,
Antonio

On Mon, 20 Apr 2020 at 14:45, Sina Madani <sinadoom@xxxxxxxxxxxxxx> wrote:

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

_______________________________________________
epsilon-dev mailing list
epsilon-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/epsilon-dev


--
Antonio Garcia-Dominguez

Back to the top