default equals again, sorry
Zhong Yu
zhong.j.yu at gmail.com
Thu Jan 23 21:55:10 PST 2014
Any objection to an intermediary abstract class with default equals()?
abstract class AbsPoint{
public boolean equals(Object)...
...
return new AbsPoint(){
public int x()...
public int y()...
On Thu, Jan 23, 2014 at 10:20 PM, Jose <jgetino at telefonica.net> wrote:
> I see thanks; I have to replicate the code in each factory.
>
> On the other way, do you think that this idiom would lead to a fewer
> overhead than instantiating (x,y) points?.
>
> The scenario is a chain of 2D transforms (over an image for example), every
> step would require a new pair to be created.
>
> Paul, I want to compare this with a stock implementation, but I don't need
> it, I only want a factory to create anonymous classes from the interface.
>
>
>
> -----Mensaje original-----
> De: John Rose [mailto:john.r.rose at oracle.com]
> Enviado el: jueves, 23 de enero de 2014 23:04
> Para: Jose
> CC: lambda-dev at openjdk.java.net
> Asunto: Re: default equals again, sorry
>
> On Jan 23, 2014, at 1:02 PM, "Jose" <jgetino at telefonica.net> wrote:
>
>
> interface Point(){
> int x();
> int y();
> static Point of(int x, int y) {
> return new Point() {
> public int x() {
> return x;
> }
> public int y() {
> return y;
> }
>
>
> + public boolean equals(Object x) { return defaultEquals(x); }
> + public int hashCode() { return defaultHashCode(); }
>
>
> };
> }
>
>
>
>
>
More information about the lambda-dev
mailing list