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

    r9341 r9371  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint.styleelement;
     3
     4import java.util.Objects;
    35
    46import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    6668    @Override
    6769    public boolean equals(Object obj) {
    68         if (obj == null || getClass() != obj.getClass())
    69             return false;
    70         if (!super.equals(obj))
    71             return false;
    72         final RepeatImageElement other = (RepeatImageElement) obj;
    73         if (!this.pattern.equals(other.pattern)) return false;
    74         if (this.offset != other.offset) return false;
    75         if (this.spacing != other.spacing) return false;
    76         if (this.phase != other.phase) return false;
    77         if (this.align != other.align) return false;
    78         return true;
     70        if (this == obj) return true;
     71        if (obj == null || getClass() != obj.getClass()) return false;
     72        if (!super.equals(obj)) return false;
     73        RepeatImageElement that = (RepeatImageElement) obj;
     74        return Float.compare(that.offset, offset) == 0 &&
     75                Float.compare(that.spacing, spacing) == 0 &&
     76                Float.compare(that.phase, phase) == 0 &&
     77                Objects.equals(pattern, that.pattern) &&
     78                align == that.align;
    7979    }
    8080
    8181    @Override
    8282    public int hashCode() {
    83         int hash = super.hashCode();
    84         hash = 83 * hash + this.pattern.hashCode();
    85         hash = 83 * hash + Float.floatToIntBits(this.offset);
    86         hash = 83 * hash + Float.floatToIntBits(this.spacing);
    87         hash = 83 * hash + Float.floatToIntBits(this.phase);
    88         hash = 83 * hash + this.align.hashCode();
    89         return hash;
     83        return Objects.hash(super.hashCode(), pattern, offset, spacing, phase, align);
    9084    }
    9185
Note: See TracChangeset for help on using the changeset viewer.