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/AreaElement.java

    r9341 r9371  
    117117    @Override
    118118    public boolean equals(Object obj) {
    119         if (obj == null || getClass() != obj.getClass())
    120             return false;
    121         if (!super.equals(obj))
    122             return false;
    123         AreaElement other = (AreaElement) obj;
    124         // we should get the same image object due to caching
    125         if (!Objects.equals(fillImage, other.fillImage))
    126             return false;
    127         if (!Objects.equals(color, other.color))
    128             return false;
    129         if (!Objects.equals(extent, other.extent))
    130             return false;
    131         if (!Objects.equals(extentThreshold, other.extentThreshold))
    132             return false;
    133         if (!Objects.equals(text, other.text))
    134             return false;
    135         return true;
     119        if (this == obj) return true;
     120        if (obj == null || getClass() != obj.getClass()) return false;
     121        if (!super.equals(obj)) return false;
     122        AreaElement that = (AreaElement) obj;
     123        return Objects.equals(color, that.color) &&
     124                Objects.equals(fillImage, that.fillImage) &&
     125                Objects.equals(text, that.text) &&
     126                Objects.equals(extent, that.extent) &&
     127                Objects.equals(extentThreshold, that.extentThreshold);
    136128    }
    137129
    138130    @Override
    139131    public int hashCode() {
    140         int hash = super.hashCode();
    141         hash = 61 * hash + color.hashCode();
    142         hash = 61 * hash + (extent != null ? Float.floatToIntBits(extent) : 0);
    143         hash = 61 * hash + (extentThreshold != null ? Float.floatToIntBits(extentThreshold) : 0);
    144         hash = 61 * hash + (fillImage != null ? fillImage.hashCode() : 0);
    145         hash = 61 * hash + (text != null ? text.hashCode() : 0);
    146         return hash;
     132        return Objects.hash(super.hashCode(), color, fillImage, text, extent, extentThreshold);
    147133    }
    148134
Note: See TracChangeset for help on using the changeset viewer.