Ignore:
Timestamp:
2016-06-07T23:56:02+02:00 (8 years ago)
Author:
Don-vip
Message:

fix equals method for BBox class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/BBox.java

    r10001 r10336  
    44import java.awt.geom.Rectangle2D;
    55import java.util.Arrays;
     6import java.util.Objects;
    67
    78import org.openstreetmap.josm.data.coor.LatLon;
     
    266267    @Override
    267268    public int hashCode() {
    268         return (int) (ymin * xmin);
     269        return Objects.hash(xmin, xmax, ymin, ymax);
    269270    }
    270271
    271272    @Override
    272273    public boolean equals(Object o) {
    273         if (o instanceof BBox) {
    274             BBox b = (BBox) o;
    275             return b.xmax == xmax && b.ymax == ymax
    276                     && b.xmin == xmin && b.ymin == ymin;
    277         } else
    278             return false;
     274        if (this == o) return true;
     275        if (o == null || getClass() != o.getClass()) return false;
     276        BBox b = (BBox) o;
     277        return Double.compare(b.xmax, xmax) == 0 && Double.compare(b.ymax, ymax) == 0
     278            && Double.compare(b.xmin, xmin) == 0 && Double.compare(b.ymin, ymin) == 0;
    279279    }
    280280
Note: See TracChangeset for help on using the changeset viewer.