I just found a post in the gwt contributors group but I cannot find it
anywhere in gwt, any ideas?
http://groups.google.com/group/google-web-toolkit-contributors/browse_thread/thread/a5193c6a82eddb5e/b400204dddcc8c64

On Mar 31, 2:20 pm, googelybear <[email protected]> wrote:
> Hi,
>
> this question might seem stupid but how can one implement hashCode()
> and equals() for a simple 2d point class as follows:
>
> public class Point {
>
>         private double fX;
>
>         private double fY;
>
>         public double getX() {
>                 return fX;
>         }
>
>         public void setX(double x) {
>                 this.fX= x;
>         }
>
>         public double getY() {
>                 return fY;
>         }
>
>         public void setY(double y) {
>                 this.fY= y;
>         }
>
> }
>
> The generated equals() and hashCode() methods from Eclipse do NOT work
> with GWT as method Double.doubleToLongBits()  is missing:
>
>         @Override
>         public int hashCode() {
>                 final int prime= 31;
>                 int result= 1;
>                 long temp;
>                 temp= Double.doubleToLongBits(fX);
>                 result= prime * result + (int) (temp ^ (temp >>> 32));
>                 temp= Double.doubleToLongBits(fY);
>                 result= prime * result + (int) (temp ^ (temp >>> 32));
>                 return result;
>         }
>
>         @Override
>         public boolean equals(Object obj) {
>                 if (this == obj)
>                         return true;
>                 if (obj == null)
>                         return false;
>                 if (!(obj instanceof Point))
>                         return false;
>                 Point other= (Point) obj;
>                 if (Double.doubleToLongBits(fX) !=
> Double.doubleToLongBits(other.fX))
>                         return false;
>                 if (Double.doubleToLongBits(fY) !=
> Double.doubleToLongBits(other.fY))
>                         return false;
>                 return true;
>         }
>
> Does anyone have an idea how to implement this?
>
> thanks a bunch,
>
> Dennis

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to