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/conflict/tags/RelationMemberConflictDecision.java

    r9078 r9371  
    44import static org.openstreetmap.josm.gui.conflict.tags.RelationMemberConflictDecisionType.UNDECIDED;
    55import static org.openstreetmap.josm.tools.I18n.tr;
     6
     7import java.util.Objects;
    68
    79import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    7274    @Override
    7375    public int hashCode() {
    74         final int prime = 31;
    75         int result = 1;
    76         result = prime * result + ((decision == null) ? 0 : decision.hashCode());
    77         result = prime * result + ((originalPrimitive == null) ? 0 : originalPrimitive.hashCode());
    78         result = prime * result + pos;
    79         result = prime * result + ((relation == null) ? 0 : relation.hashCode());
    80         result = prime * result + ((role == null) ? 0 : role.hashCode());
    81         return result;
     76        return Objects.hash(relation, pos, originalPrimitive, role, decision);
    8277    }
    8378
    8479    @Override
    8580    public boolean equals(Object obj) {
    86         if (this == obj)
    87             return true;
    88         if (obj == null)
    89             return false;
    90         if (getClass() != obj.getClass())
    91             return false;
    92         RelationMemberConflictDecision other = (RelationMemberConflictDecision) obj;
    93         if (decision == null) {
    94             if (other.decision != null)
    95                 return false;
    96         } else if (!decision.equals(other.decision))
    97             return false;
    98         if (originalPrimitive == null) {
    99             if (other.originalPrimitive != null)
    100                 return false;
    101         } else if (!originalPrimitive.equals(other.originalPrimitive))
    102             return false;
    103         if (pos != other.pos)
    104             return false;
    105         if (relation == null) {
    106             if (other.relation != null)
    107                 return false;
    108         } else if (!relation.equals(other.relation))
    109             return false;
    110         if (role == null) {
    111             if (other.role != null)
    112                 return false;
    113         } else if (!role.equals(other.role))
    114             return false;
    115         return true;
     81        if (this == obj) return true;
     82        if (obj == null || getClass() != obj.getClass()) return false;
     83        RelationMemberConflictDecision that = (RelationMemberConflictDecision) obj;
     84        return pos == that.pos &&
     85                Objects.equals(relation, that.relation) &&
     86                Objects.equals(originalPrimitive, that.originalPrimitive) &&
     87                Objects.equals(role, that.role) &&
     88                decision == that.decision;
    11689    }
    11790
Note: See TracChangeset for help on using the changeset viewer.