Ignore:
Timestamp:
2016-01-09T23:20:37+01:00 (8 years ago)
Author:
simon04
Message:

Java 7: use Objects.equals and Objects.hash

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/MapImage.java

    r9334 r9371  
    217217    @Override
    218218    public boolean equals(Object obj) {
    219         if (obj == null || getClass() != obj.getClass())
    220             return false;
    221         final MapImage other = (MapImage) obj;
    222         // img changes when image is fully loaded and can't be used for equality check.
    223         return  alpha == other.alpha &&
    224                 Objects.equals(name, other.name) &&
    225                 Objects.equals(source, other.source) &&
    226                 autoRescale == other.autoRescale &&
    227                 width == other.width &&
    228                 height == other.height;
     219        if (this == obj) return true;
     220        if (obj == null || getClass() != obj.getClass()) return false;
     221        MapImage mapImage = (MapImage) obj;
     222        return alpha == mapImage.alpha &&
     223                autoRescale == mapImage.autoRescale &&
     224                width == mapImage.width &&
     225                height == mapImage.height &&
     226                Objects.equals(name, mapImage.name) &&
     227                Objects.equals(source, mapImage.source);
    229228    }
    230229
    231230    @Override
    232231    public int hashCode() {
    233         int hash = 7;
    234         hash = 67 * hash + alpha;
    235         hash = 67 * hash + name.hashCode();
    236         hash = 67 * hash + source.hashCode();
    237         hash = 67 * hash + (autoRescale ? 1 : 0);
    238         hash = 67 * hash + width;
    239         hash = 67 * hash + height;
    240         return hash;
     232        return Objects.hash(alpha, name, source, autoRescale, width, height);
    241233    }
    242234
Note: See TracChangeset for help on using the changeset viewer.