Ignore:
Timestamp:
2016-01-09T23:20:37+01:00 (8 years ago)
Author:
simon04
Message:

Java 7: use Objects.equals and Objects.hash

Location:
trunk/src/org/openstreetmap/josm/data/conflict
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/conflict/Conflict.java

    r9239 r9371  
    33
    44import java.util.Map;
     5import java.util.Objects;
    56
    67import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    8485    @Override
    8586    public int hashCode() {
    86         final int prime = 31;
    87         int result = 1;
    88         result = prime * result + ((my == null) ? 0 : my.hashCode());
    89         result = prime * result + ((their == null) ? 0 : their.hashCode());
    90         return result;
     87        return Objects.hash(my, their);
    9188    }
    9289
    93     @SuppressWarnings("unchecked")
    9490    @Override
    9591    public boolean equals(Object obj) {
    96         if (this == obj)
    97             return true;
    98         if (obj == null)
    99             return false;
    100         if (getClass() != obj.getClass())
    101             return false;
    102         Conflict<T> other = (Conflict<T>) obj;
    103         if (my != other.my)
    104             return false;
    105         if (their != other.their)
    106             return false;
    107         return true;
     92        if (this == obj) return true;
     93        if (obj == null || getClass() != obj.getClass()) return false;
     94        Conflict<?> conflict = (Conflict<?>) obj;
     95        return Objects.equals(my, conflict.my) &&
     96                Objects.equals(their, conflict.their);
    10897    }
    10998
  • trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java

    r9067 r9371  
    99import java.util.Iterator;
    1010import java.util.List;
     11import java.util.Objects;
    1112import java.util.Set;
    1213import java.util.concurrent.CopyOnWriteArrayList;
     
    386387    @Override
    387388    public int hashCode() {
    388         final int prime = 31;
    389         int result = 1;
    390         result = prime * result + ((conflicts == null) ? 0 : conflicts.hashCode());
    391         result = prime * result + ((listeners == null) ? 0 : listeners.hashCode());
    392         return result;
     389        return Objects.hash(conflicts, listeners);
    393390    }
    394391
    395392    @Override
    396393    public boolean equals(Object obj) {
    397         if (this == obj)
    398             return true;
    399         if (obj == null)
    400             return false;
    401         if (getClass() != obj.getClass())
    402             return false;
    403         ConflictCollection other = (ConflictCollection) obj;
    404         if (conflicts == null) {
    405             if (other.conflicts != null)
    406                 return false;
    407         } else if (!conflicts.equals(other.conflicts))
    408             return false;
    409         if (listeners == null) {
    410             if (other.listeners != null)
    411                 return false;
    412         } else if (!listeners.equals(other.listeners))
    413             return false;
    414         return true;
     394        if (this == obj) return true;
     395        if (obj == null || getClass() != obj.getClass()) return false;
     396        ConflictCollection conflicts1 = (ConflictCollection) obj;
     397        return Objects.equals(conflicts, conflicts1.conflicts) &&
     398                Objects.equals(listeners, conflicts1.listeners);
    415399    }
    416400}
Note: See TracChangeset for help on using the changeset viewer.