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/data/osm/RelationToChildReference.java

    r9067 r9371  
    44import java.util.Collection;
    55import java.util.HashSet;
     6import java.util.Objects;
    67import java.util.Set;
    78
     
    7879
    7980    @Override
    80     public int hashCode() {
    81         final int prime = 31;
    82         int result = 1;
    83         result = prime * result + ((child == null) ? 0 : child.hashCode());
    84         result = prime * result + ((parent == null) ? 0 : parent.hashCode());
    85         result = prime * result + position;
    86         result = prime * result + ((role == null) ? 0 : role.hashCode());
    87         return result;
     81    public boolean equals(Object obj) {
     82        if (this == obj) return true;
     83        if (obj == null || getClass() != obj.getClass()) return false;
     84        RelationToChildReference that = (RelationToChildReference) obj;
     85        return position == that.position &&
     86                Objects.equals(parent, that.parent) &&
     87                Objects.equals(role, that.role) &&
     88                Objects.equals(child, that.child);
    8889    }
    8990
    9091    @Override
    91     public boolean equals(Object obj) {
    92         if (this == obj)
    93             return true;
    94         if (obj == null)
    95             return false;
    96         if (getClass() != obj.getClass())
    97             return false;
    98         RelationToChildReference other = (RelationToChildReference) obj;
    99         if (child == null) {
    100             if (other.child != null)
    101                 return false;
    102         } else if (!child.equals(other.child))
    103             return false;
    104         if (parent == null) {
    105             if (other.parent != null)
    106                 return false;
    107         } else if (!parent.equals(other.parent))
    108             return false;
    109         if (position != other.position)
    110             return false;
    111         if (role == null) {
    112             if (other.role != null)
    113                 return false;
    114         } else if (!role.equals(other.role))
    115             return false;
    116         return true;
     92    public int hashCode() {
     93        return Objects.hash(parent, position, role, child);
    11794    }
    11895}
Note: See TracChangeset for help on using the changeset viewer.