default equals again, sorry

Jose jgetino at
Fri Jan 24 02:18:46 PST 2014

Good, it also works. 

I tried refactoring the code to get rid of any implantation of the interface
and everything works using just the interface - and the abstract class in
your approach-, so now I have a working interface with no implementations at
Regarding execution speed I couldn't say any difference between the
statefull/stateless versions, but this might say nothing if the burden of
performing long math computations is much greater that the one of
instantiating a (x,y) or accessing 2 local variables. And regarding memory
overhead I feel it would be difficult to test. 


-----Mensaje original-----
De: Zhong Yu [mailto:zhong.j.yu at] 
Enviado el: viernes, 24 de enero de 2014 6:55
Para: Jose
CC: John Rose; lambda-dev at
Asunto: Re: default equals again, sorry

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> 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),
> 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]
> Enviado el: jueves, 23 de enero de 2014 23:04
> Para: Jose
> CC: lambda-dev at
> Asunto: Re: default equals again, sorry
> On Jan 23, 2014, at 1:02 PM, "Jose" <jgetino at> 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