Changeset 629 in josm for trunk


Ignore:
Timestamp:
2008-05-11T01:00:31+02:00 (17 years ago)
Author:
framm
Message:
  • clean up OsmPrimitive.equals / patch originally by DH but used version from Petr Nejedly
File:
1 edited

Legend:

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

    r627 r629  
    161161
    162162        /**
    163          * Equal, if the id (and class) is equal. If both ids are 0, use the super classes
    164          * equal instead.
     163         * Equal, if the id (and class) is equal.
    165164         *
    166165         * An primitive is equal to its incomplete counter part.
    167166         */
    168         @Override public final boolean equals(Object obj) {
    169                 if (obj == null || getClass() != obj.getClass() || id == 0 || ((OsmPrimitive)obj).id == 0)
    170                         return super.equals(obj);
    171                 return id == ((OsmPrimitive)obj).id;
    172         }
     167    @Override public boolean equals(Object obj) {
     168        if (id == 0) return obj == this;
     169        if (obj instanceof OsmPrimitive) { // not null too
     170            return ((OsmPrimitive)obj).id == id && obj.getClass() == getClass();
     171        }
     172        return false;
     173    }
    173174
    174175        /**
Note: See TracChangeset for help on using the changeset viewer.