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/command/RotateCommand.java

    r9243 r9371  
    55
    66import java.util.Collection;
     7import java.util.Objects;
    78
    89import org.openstreetmap.josm.data.coor.EastNorth;
     
    9394    @Override
    9495    public int hashCode() {
    95         final int prime = 31;
    96         int result = super.hashCode();
    97         result = prime * result + ((pivot == null) ? 0 : pivot.hashCode());
    98         long temp;
    99         temp = Double.doubleToLongBits(rotationAngle);
    100         result = prime * result + (int) (temp ^ (temp >>> 32));
    101         temp = Double.doubleToLongBits(startAngle);
    102         result = prime * result + (int) (temp ^ (temp >>> 32));
    103         return result;
     96        return Objects.hash(super.hashCode(), pivot, startAngle, rotationAngle);
    10497    }
    10598
    10699    @Override
    107100    public boolean equals(Object obj) {
    108         if (this == obj)
    109             return true;
    110         if (!super.equals(obj))
    111             return false;
    112         if (getClass() != obj.getClass())
    113             return false;
    114         RotateCommand other = (RotateCommand) obj;
    115         if (pivot == null) {
    116             if (other.pivot != null)
    117                 return false;
    118         } else if (!pivot.equals(other.pivot))
    119             return false;
    120         if (Double.doubleToLongBits(rotationAngle) != Double.doubleToLongBits(other.rotationAngle))
    121             return false;
    122         if (Double.doubleToLongBits(startAngle) != Double.doubleToLongBits(other.startAngle))
    123             return false;
    124         return true;
     101        if (this == obj) return true;
     102        if (obj == null || getClass() != obj.getClass()) return false;
     103        if (!super.equals(obj)) return false;
     104        RotateCommand that = (RotateCommand) obj;
     105        return Double.compare(that.startAngle, startAngle) == 0 &&
     106                Double.compare(that.rotationAngle, rotationAngle) == 0 &&
     107                Objects.equals(pivot, that.pivot);
    125108    }
    126109}
Note: See TracChangeset for help on using the changeset viewer.