Changeset 9371 in josm


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
Files:
83 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java

    r9070 r9371  
    1616import java.util.List;
    1717import java.util.Map;
     18import java.util.Objects;
    1819import java.util.Set;
    1920import java.util.Stack;
     
    343344        @Override
    344345        public int hashCode() {
    345             final int prime = 31;
    346             int result = 1;
    347             result = prime * result + ((a == null) ? 0 : a.hashCode());
    348             result = prime * result + ((b == null) ? 0 : b.hashCode());
    349             return result;
     346            return Objects.hash(a, b);
    350347        }
    351348
    352349        @Override
    353350        public boolean equals(Object obj) {
    354             if (this == obj)
    355                 return true;
    356             if (obj == null)
    357                 return false;
    358             if (getClass() != obj.getClass())
    359                 return false;
    360             NodePair other = (NodePair) obj;
    361             if (a == null) {
    362                 if (other.a != null)
    363                     return false;
    364             } else if (!a.equals(other.a))
    365                 return false;
    366             if (b == null) {
    367                 if (other.b != null)
    368                     return false;
    369             } else if (!b.equals(other.b))
    370                 return false;
    371             return true;
     351            if (this == obj) return true;
     352            if (obj == null || getClass() != obj.getClass()) return false;
     353            NodePair nodePair = (NodePair) obj;
     354            return Objects.equals(a, nodePair.a) &&
     355                    Objects.equals(b, nodePair.b);
    372356        }
    373357    }
  • trunk/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java

    r8895 r9371  
    1111import java.util.LinkedList;
    1212import java.util.List;
     13import java.util.Objects;
    1314import java.util.ServiceConfigurationError;
    1415
     
    350351    @Override
    351352    public int hashCode() {
    352         final int prime = 31;
    353         int result = 1;
    354         result = prime * result + ((defaultExtension == null) ? 0 : defaultExtension.hashCode());
    355         result = prime * result + ((description == null) ? 0 : description.hashCode());
    356         result = prime * result + ((extensions == null) ? 0 : extensions.hashCode());
    357         return result;
     353        return Objects.hash(extensions, description, defaultExtension);
    358354    }
    359355
    360356    @Override
    361357    public boolean equals(Object obj) {
    362         if (this == obj)
    363             return true;
    364         if (obj == null)
    365             return false;
    366         if (getClass() != obj.getClass())
    367             return false;
    368         ExtensionFileFilter other = (ExtensionFileFilter) obj;
    369         if (defaultExtension == null) {
    370             if (other.defaultExtension != null)
    371                 return false;
    372         } else if (!defaultExtension.equals(other.defaultExtension))
    373             return false;
    374         if (description == null) {
    375             if (other.description != null)
    376                 return false;
    377         } else if (!description.equals(other.description))
    378             return false;
    379         if (extensions == null) {
    380             if (other.extensions != null)
    381                 return false;
    382         } else if (!extensions.equals(other.extensions))
    383             return false;
    384         return true;
     358        if (this == obj) return true;
     359        if (obj == null || getClass() != obj.getClass()) return false;
     360        ExtensionFileFilter that = (ExtensionFileFilter) obj;
     361        return Objects.equals(extensions, that.extensions) &&
     362                Objects.equals(description, that.description) &&
     363                Objects.equals(defaultExtension, that.defaultExtension);
    385364    }
    386365}
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r9295 r9371  
    1717import java.util.List;
    1818import java.util.Map;
     19import java.util.Objects;
    1920import java.util.Set;
    2021import java.util.TreeMap;
     
    9293        @Override
    9394        public int hashCode() {
    94             return rel.hashCode();
     95            return Objects.hash(rel, role);
    9596        }
    9697
    9798        @Override
    9899        public boolean equals(Object other) {
    99             if (!(other instanceof RelationRole)) return false;
    100             RelationRole otherMember = (RelationRole) other;
    101             return otherMember.role.equals(role) && otherMember.rel.equals(rel);
     100            if (this == other) return true;
     101            if (other == null || getClass() != other.getClass()) return false;
     102            RelationRole that = (RelationRole) other;
     103            return Objects.equals(rel, that.rel) &&
     104                    Objects.equals(role, that.role);
    102105        }
    103106    }
     
    120123        @Override
    121124        public int hashCode() {
    122             return way.hashCode();
     125            return Objects.hash(way, insideToTheRight);
    123126        }
    124127
    125128        @Override
    126129        public boolean equals(Object other) {
    127             if (!(other instanceof WayInPolygon)) return false;
    128             WayInPolygon otherMember = (WayInPolygon) other;
    129             return otherMember.way.equals(this.way) && otherMember.insideToTheRight == this.insideToTheRight;
     130            if (this == other) return true;
     131            if (other == null || getClass() != other.getClass()) return false;
     132            WayInPolygon that = (WayInPolygon) other;
     133            return insideToTheRight == that.insideToTheRight &&
     134                    Objects.equals(way, that.way);
    130135        }
    131136    }
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r9079 r9371  
    2424import java.util.List;
    2525import java.util.Map;
     26import java.util.Objects;
    2627import java.util.Set;
    2728
     
    677678        @Override
    678679        public boolean equals(Object other) {
    679             if (!(other instanceof SearchSetting))
    680                 return false;
    681             SearchSetting o = (SearchSetting) other;
    682             return o.caseSensitive == this.caseSensitive
    683                     && o.regexSearch == this.regexSearch
    684                     && o.mapCSSSearch == this.mapCSSSearch
    685                     && o.allElements == this.allElements
    686                     && o.mode.equals(this.mode)
    687                     && o.text.equals(this.text);
     680            if (this == other) return true;
     681            if (other == null || getClass() != other.getClass()) return false;
     682            SearchSetting that = (SearchSetting) other;
     683            return caseSensitive == that.caseSensitive &&
     684                    regexSearch == that.regexSearch &&
     685                    mapCSSSearch == that.mapCSSSearch &&
     686                    allElements == that.allElements &&
     687                    Objects.equals(text, that.text) &&
     688                    mode == that.mode;
    688689        }
    689690
    690691        @Override
    691692        public int hashCode() {
    692             return text.hashCode();
     693            return Objects.hash(text, mode, caseSensitive, regexSearch, mapCSSSearch, allElements);
    693694        }
    694695
  • trunk/src/org/openstreetmap/josm/command/AddCommand.java

    r8510 r9371  
    77import java.util.Collection;
    88import java.util.Collections;
     9import java.util.Objects;
    910
    1011import javax.swing.Icon;
     
    99100    @Override
    100101    public int hashCode() {
    101         final int prime = 31;
    102         int result = super.hashCode();
    103         result = prime * result + ((osm == null) ? 0 : osm.hashCode());
    104         return result;
     102        return Objects.hash(super.hashCode(), osm);
    105103    }
    106104
    107105    @Override
    108106    public boolean equals(Object obj) {
    109         if (this == obj)
    110             return true;
    111         if (!super.equals(obj))
    112             return false;
    113         if (getClass() != obj.getClass())
    114             return false;
    115         AddCommand other = (AddCommand) obj;
    116         if (osm == null) {
    117             if (other.osm != null)
    118                 return false;
    119         } else if (!osm.equals(other.osm))
    120             return false;
    121         return true;
     107        if (this == obj) return true;
     108        if (obj == null || getClass() != obj.getClass()) return false;
     109        if (!super.equals(obj)) return false;
     110        AddCommand that = (AddCommand) obj;
     111        return Objects.equals(osm, that.osm);
    122112    }
    123113}
  • trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java

    r8840 r9371  
    88import java.util.HashSet;
    99import java.util.List;
     10import java.util.Objects;
    1011
    1112import javax.swing.Icon;
     
    176177    @Override
    177178    public int hashCode() {
    178         final int prime = 31;
    179         int result = super.hashCode();
    180         result = prime * result + ((createdPrimitives == null) ? 0 : createdPrimitives.hashCode());
    181         result = prime * result + ((createdPrimitivesToSelect == null) ? 0 : createdPrimitivesToSelect.hashCode());
    182         result = prime * result + ((data == null) ? 0 : data.hashCode());
    183         result = prime * result + ((toSelect == null) ? 0 : toSelect.hashCode());
    184         return result;
     179        return Objects.hash(super.hashCode(), data, toSelect, createdPrimitives, createdPrimitivesToSelect);
    185180    }
    186181
    187182    @Override
    188183    public boolean equals(Object obj) {
    189         if (this == obj)
    190             return true;
    191         if (!super.equals(obj))
    192             return false;
    193         if (getClass() != obj.getClass())
    194             return false;
    195         AddPrimitivesCommand other = (AddPrimitivesCommand) obj;
    196         if (createdPrimitives == null) {
    197             if (other.createdPrimitives != null)
    198                 return false;
    199         } else if (!createdPrimitives.equals(other.createdPrimitives))
    200             return false;
    201         if (createdPrimitivesToSelect == null) {
    202             if (other.createdPrimitivesToSelect != null)
    203                 return false;
    204         } else if (!createdPrimitivesToSelect.equals(other.createdPrimitivesToSelect))
    205             return false;
    206         if (data == null) {
    207             if (other.data != null)
    208                 return false;
    209         } else if (!data.equals(other.data))
    210             return false;
    211         if (toSelect == null) {
    212             if (other.toSelect != null)
    213                 return false;
    214         } else if (!toSelect.equals(other.toSelect))
    215             return false;
    216         return true;
     184        if (this == obj) return true;
     185        if (obj == null || getClass() != obj.getClass()) return false;
     186        if (!super.equals(obj)) return false;
     187        AddPrimitivesCommand that = (AddPrimitivesCommand) obj;
     188        return Objects.equals(data, that.data) &&
     189                Objects.equals(toSelect, that.toSelect) &&
     190                Objects.equals(createdPrimitives, that.createdPrimitives) &&
     191                Objects.equals(createdPrimitivesToSelect, that.createdPrimitivesToSelect);
    217192    }
    218193}
  • trunk/src/org/openstreetmap/josm/command/ChangeCommand.java

    r8510 r9371  
    66
    77import java.util.Collection;
     8import java.util.Objects;
    89
    910import javax.swing.Icon;
     
    9192    @Override
    9293    public int hashCode() {
    93         final int prime = 31;
    94         int result = super.hashCode();
    95         result = prime * result + ((newOsm == null) ? 0 : newOsm.hashCode());
    96         result = prime * result + ((osm == null) ? 0 : osm.hashCode());
    97         return result;
     94        return Objects.hash(super.hashCode(), osm, newOsm);
    9895    }
    9996
    10097    @Override
    10198    public boolean equals(Object obj) {
    102         if (this == obj)
    103             return true;
    104         if (!super.equals(obj))
    105             return false;
    106         if (getClass() != obj.getClass())
    107             return false;
    108         ChangeCommand other = (ChangeCommand) obj;
    109         if (newOsm == null) {
    110             if (other.newOsm != null)
    111                 return false;
    112         } else if (!newOsm.equals(other.newOsm))
    113             return false;
    114         if (osm == null) {
    115             if (other.osm != null)
    116                 return false;
    117         } else if (!osm.equals(other.osm))
    118             return false;
    119         return true;
     99        if (this == obj) return true;
     100        if (obj == null || getClass() != obj.getClass()) return false;
     101        if (!super.equals(obj)) return false;
     102        ChangeCommand that = (ChangeCommand) obj;
     103        return Objects.equals(osm, that.osm) &&
     104                Objects.equals(newOsm, that.newOsm);
    120105    }
    121106}
  • trunk/src/org/openstreetmap/josm/command/ChangeNodesCommand.java

    r8456 r9371  
    66import java.util.Collection;
    77import java.util.List;
     8import java.util.Objects;
    89
    910import javax.swing.Icon;
     
    6465    @Override
    6566    public int hashCode() {
    66         final int prime = 31;
    67         int result = super.hashCode();
    68         result = prime * result + ((newNodes == null) ? 0 : newNodes.hashCode());
    69         result = prime * result + ((way == null) ? 0 : way.hashCode());
    70         return result;
     67        return Objects.hash(super.hashCode(), way, newNodes);
    7168    }
    7269
    7370    @Override
    7471    public boolean equals(Object obj) {
    75         if (this == obj)
    76             return true;
    77         if (!super.equals(obj))
    78             return false;
    79         if (getClass() != obj.getClass())
    80             return false;
    81         ChangeNodesCommand other = (ChangeNodesCommand) obj;
    82         if (newNodes == null) {
    83             if (other.newNodes != null)
    84                 return false;
    85         } else if (!newNodes.equals(other.newNodes))
    86             return false;
    87         if (way == null) {
    88             if (other.way != null)
    89                 return false;
    90         } else if (!way.equals(other.way))
    91             return false;
    92         return true;
     72        if (this == obj) return true;
     73        if (obj == null || getClass() != obj.getClass()) return false;
     74        if (!super.equals(obj)) return false;
     75        ChangeNodesCommand that = (ChangeNodesCommand) obj;
     76        return Objects.equals(way, that.way) &&
     77                Objects.equals(newNodes, that.newNodes);
    9378    }
    9479}
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java

    r8975 r9371  
    1414import java.util.List;
    1515import java.util.Map;
     16import java.util.Objects;
    1617
    1718import javax.swing.Icon;
     
    249250    @Override
    250251    public int hashCode() {
    251         final int prime = 31;
    252         int result = super.hashCode();
    253         result = prime * result + ((objects == null) ? 0 : objects.hashCode());
    254         result = prime * result + ((tags == null) ? 0 : tags.hashCode());
    255         return result;
     252        return Objects.hash(super.hashCode(), objects, tags);
    256253    }
    257254
    258255    @Override
    259256    public boolean equals(Object obj) {
    260         if (this == obj)
    261             return true;
    262         if (!super.equals(obj))
    263             return false;
    264         if (getClass() != obj.getClass())
    265             return false;
    266         ChangePropertyCommand other = (ChangePropertyCommand) obj;
    267         if (objects == null) {
    268             if (other.objects != null)
    269                 return false;
    270         } else if (!objects.equals(other.objects))
    271             return false;
    272         if (tags == null) {
    273             if (other.tags != null)
    274                 return false;
    275         } else if (!tags.equals(other.tags))
    276             return false;
    277         return true;
     257        if (this == obj) return true;
     258        if (obj == null || getClass() != obj.getClass()) return false;
     259        if (!super.equals(obj)) return false;
     260        ChangePropertyCommand that = (ChangePropertyCommand) obj;
     261        return Objects.equals(objects, that.objects) &&
     262                Objects.equals(tags, that.tags);
    278263    }
    279264}
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyKeyCommand.java

    r8846 r9371  
    1010import java.util.LinkedList;
    1111import java.util.List;
     12import java.util.Objects;
    1213
    1314import javax.swing.Icon;
     
    129130    @Override
    130131    public int hashCode() {
    131         final int prime = 31;
    132         int result = super.hashCode();
    133         result = prime * result + ((key == null) ? 0 : key.hashCode());
    134         result = prime * result + ((newKey == null) ? 0 : newKey.hashCode());
    135         result = prime * result + ((objects == null) ? 0 : objects.hashCode());
    136         return result;
     132        return Objects.hash(super.hashCode(), objects, key, newKey);
    137133    }
    138134
    139135    @Override
    140136    public boolean equals(Object obj) {
    141         if (this == obj)
    142             return true;
    143         if (!super.equals(obj))
    144             return false;
    145         if (getClass() != obj.getClass())
    146             return false;
    147         ChangePropertyKeyCommand other = (ChangePropertyKeyCommand) obj;
    148         if (key == null) {
    149             if (other.key != null)
    150                 return false;
    151         } else if (!key.equals(other.key))
    152             return false;
    153         if (newKey == null) {
    154             if (other.newKey != null)
    155                 return false;
    156         } else if (!newKey.equals(other.newKey))
    157             return false;
    158         if (objects == null) {
    159             if (other.objects != null)
    160                 return false;
    161         } else if (!objects.equals(other.objects))
    162             return false;
    163         return true;
     137        if (this == obj) return true;
     138        if (obj == null || getClass() != obj.getClass()) return false;
     139        if (!super.equals(obj)) return false;
     140        ChangePropertyKeyCommand that = (ChangePropertyKeyCommand) obj;
     141        return Objects.equals(objects, that.objects) &&
     142                Objects.equals(key, that.key) &&
     143                Objects.equals(newKey, that.newKey);
    164144    }
    165145}
  • trunk/src/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommand.java

    r9067 r9371  
    55
    66import java.util.Collection;
     7import java.util.Objects;
    78
    89import javax.swing.Icon;
     
    8485    @Override
    8586    public int hashCode() {
    86         final int prime = 31;
    87         int result = super.hashCode();
    88         result = prime * result + ((newRole == null) ? 0 : newRole.hashCode());
    89         result = prime * result + ((oldModified == null) ? 0 : oldModified.hashCode());
    90         result = prime * result + ((oldRole == null) ? 0 : oldRole.hashCode());
    91         result = prime * result + position;
    92         result = prime * result + ((relation == null) ? 0 : relation.hashCode());
    93         return result;
     87        return Objects.hash(super.hashCode(), relation, position, newRole, oldRole, oldModified);
    9488    }
    9589
    9690    @Override
    9791    public boolean equals(Object obj) {
    98         if (this == obj)
    99             return true;
    100         if (!super.equals(obj))
    101             return false;
    102         if (getClass() != obj.getClass())
    103             return false;
    104         ChangeRelationMemberRoleCommand other = (ChangeRelationMemberRoleCommand) obj;
    105         if (newRole == null) {
    106             if (other.newRole != null)
    107                 return false;
    108         } else if (!newRole.equals(other.newRole))
    109             return false;
    110         if (oldModified == null) {
    111             if (other.oldModified != null)
    112                 return false;
    113         } else if (!oldModified.equals(other.oldModified))
    114             return false;
    115         if (oldRole == null) {
    116             if (other.oldRole != null)
    117                 return false;
    118         } else if (!oldRole.equals(other.oldRole))
    119             return false;
    120         if (position != other.position)
    121             return false;
    122         if (relation == null) {
    123             if (other.relation != null)
    124                 return false;
    125         } else if (!relation.equals(other.relation))
    126             return false;
    127         return true;
     92        if (this == obj) return true;
     93        if (obj == null || getClass() != obj.getClass()) return false;
     94        if (!super.equals(obj)) return false;
     95        ChangeRelationMemberRoleCommand that = (ChangeRelationMemberRoleCommand) obj;
     96        return position == that.position &&
     97                Objects.equals(relation, that.relation) &&
     98                Objects.equals(newRole, that.newRole) &&
     99                Objects.equals(oldRole, that.oldRole) &&
     100                Objects.equals(oldModified, that.oldModified);
    128101    }
    129102}
  • trunk/src/org/openstreetmap/josm/command/Command.java

    r8945 r9371  
    99import java.util.Map;
    1010import java.util.Map.Entry;
     11import java.util.Objects;
    1112
    1213import javax.swing.JOptionPane;
     
    105106        @Override
    106107        public int hashCode() {
    107             final int prime = 31;
    108             int result = 1;
    109             result = prime * result + ((eastNorth == null) ? 0 : eastNorth.hashCode());
    110             result = prime * result + ((latlon == null) ? 0 : latlon.hashCode());
    111             result = prime * result + (modified ? 1231 : 1237);
    112             return result;
     108            return Objects.hash(latlon, eastNorth, modified);
    113109        }
    114110
    115111        @Override
    116112        public boolean equals(Object obj) {
    117             if (this == obj)
    118                 return true;
    119             if (obj == null)
    120                 return false;
    121             if (getClass() != obj.getClass())
    122                 return false;
    123             OldNodeState other = (OldNodeState) obj;
    124             if (eastNorth == null) {
    125                 if (other.eastNorth != null)
    126                     return false;
    127             } else if (!eastNorth.equals(other.eastNorth))
    128                 return false;
    129             if (latlon == null) {
    130                 if (other.latlon != null)
    131                     return false;
    132             } else if (!latlon.equals(other.latlon))
    133                 return false;
    134             if (modified != other.modified)
    135                 return false;
    136             return true;
     113            if (this == obj) return true;
     114            if (obj == null || getClass() != obj.getClass()) return false;
     115            OldNodeState that = (OldNodeState) obj;
     116            return modified == that.modified &&
     117                    Objects.equals(latlon, that.latlon) &&
     118                    Objects.equals(eastNorth, that.eastNorth);
    137119        }
    138120    }
     
    306288    @Override
    307289    public int hashCode() {
    308         final int prime = 31;
    309         int result = 1;
    310         result = prime * result + ((cloneMap == null) ? 0 : cloneMap.hashCode());
    311         result = prime * result + ((layer == null) ? 0 : layer.hashCode());
    312         return result;
     290        return Objects.hash(cloneMap, layer);
    313291    }
    314292
    315293    @Override
    316294    public boolean equals(Object obj) {
    317         if (this == obj)
    318             return true;
    319         if (obj == null)
    320             return false;
    321         if (getClass() != obj.getClass())
    322             return false;
    323         Command other = (Command) obj;
    324         if (cloneMap == null) {
    325             if (other.cloneMap != null)
    326                 return false;
    327         } else if (!cloneMap.equals(other.cloneMap))
    328             return false;
    329         if (layer == null) {
    330             if (other.layer != null)
    331                 return false;
    332         } else if (!layer.equals(other.layer))
    333             return false;
    334         return true;
     295        if (this == obj) return true;
     296        if (obj == null || getClass() != obj.getClass()) return false;
     297        Command command = (Command) obj;
     298        return Objects.equals(cloneMap, command.cloneMap) &&
     299                Objects.equals(layer, command.layer);
    335300    }
    336301}
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r9072 r9371  
    1818import java.util.Map;
    1919import java.util.Map.Entry;
     20import java.util.Objects;
    2021import java.util.Set;
    2122
     
    518519    @Override
    519520    public int hashCode() {
    520         final int prime = 31;
    521         int result = super.hashCode();
    522         result = prime * result + ((clonedPrimitives == null) ? 0 : clonedPrimitives.hashCode());
    523         result = prime * result + ((toDelete == null) ? 0 : toDelete.hashCode());
    524         return result;
     521        return Objects.hash(super.hashCode(), toDelete, clonedPrimitives);
    525522    }
    526523
    527524    @Override
    528525    public boolean equals(Object obj) {
    529         if (this == obj)
    530             return true;
    531         if (!super.equals(obj))
    532             return false;
    533         if (getClass() != obj.getClass())
    534             return false;
    535         DeleteCommand other = (DeleteCommand) obj;
    536         if (clonedPrimitives == null) {
    537             if (other.clonedPrimitives != null)
    538                 return false;
    539         } else if (!clonedPrimitives.equals(other.clonedPrimitives))
    540             return false;
    541         if (toDelete == null) {
    542             if (other.toDelete != null)
    543                 return false;
    544         } else if (!toDelete.equals(other.toDelete))
    545             return false;
    546         return true;
     526        if (this == obj) return true;
     527        if (obj == null || getClass() != obj.getClass()) return false;
     528        if (!super.equals(obj)) return false;
     529        DeleteCommand that = (DeleteCommand) obj;
     530        return Objects.equals(toDelete, that.toDelete) &&
     531                Objects.equals(clonedPrimitives, that.clonedPrimitives);
    547532    }
    548533}
  • trunk/src/org/openstreetmap/josm/command/MoveCommand.java

    r9231 r9371  
    99import java.util.LinkedList;
    1010import java.util.List;
     11import java.util.Objects;
    1112
    1213import javax.swing.Icon;
     
    246247    @Override
    247248    public int hashCode() {
    248         final int prime = 31;
    249         int result = super.hashCode();
    250         long temp;
    251         temp = Double.doubleToLongBits(backupX);
    252         result = prime * result + (int) (temp ^ (temp >>> 32));
    253         temp = Double.doubleToLongBits(backupY);
    254         result = prime * result + (int) (temp ^ (temp >>> 32));
    255         result = prime * result + ((nodes == null) ? 0 : nodes.hashCode());
    256         result = prime * result + ((oldState == null) ? 0 : oldState.hashCode());
    257         result = prime * result + ((startEN == null) ? 0 : startEN.hashCode());
    258         temp = Double.doubleToLongBits(x);
    259         result = prime * result + (int) (temp ^ (temp >>> 32));
    260         temp = Double.doubleToLongBits(y);
    261         result = prime * result + (int) (temp ^ (temp >>> 32));
    262         return result;
     249        return Objects.hash(super.hashCode(), nodes, startEN, x, y, backupX, backupY, oldState);
    263250    }
    264251
    265252    @Override
    266253    public boolean equals(Object obj) {
    267         if (this == obj)
    268             return true;
    269         if (!super.equals(obj))
    270             return false;
    271         if (getClass() != obj.getClass())
    272             return false;
    273         MoveCommand other = (MoveCommand) obj;
    274         if (Double.doubleToLongBits(backupX) != Double.doubleToLongBits(other.backupX))
    275             return false;
    276         if (Double.doubleToLongBits(backupY) != Double.doubleToLongBits(other.backupY))
    277             return false;
    278         if (nodes == null) {
    279             if (other.nodes != null)
    280                 return false;
    281         } else if (!nodes.equals(other.nodes))
    282             return false;
    283         if (oldState == null) {
    284             if (other.oldState != null)
    285                 return false;
    286         } else if (!oldState.equals(other.oldState))
    287             return false;
    288         if (startEN == null) {
    289             if (other.startEN != null)
    290                 return false;
    291         } else if (!startEN.equals(other.startEN))
    292             return false;
    293         if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))
    294             return false;
    295         if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))
    296             return false;
    297         return true;
     254        if (this == obj) return true;
     255        if (obj == null || getClass() != obj.getClass()) return false;
     256        if (!super.equals(obj)) return false;
     257        MoveCommand that = (MoveCommand) obj;
     258        return Double.compare(that.x, x) == 0 &&
     259                Double.compare(that.y, y) == 0 &&
     260                Double.compare(that.backupX, backupX) == 0 &&
     261                Double.compare(that.backupY, backupY) == 0 &&
     262                Objects.equals(nodes, that.nodes) &&
     263                Objects.equals(startEN, that.startEN) &&
     264                Objects.equals(oldState, that.oldState);
    298265    }
    299266}
  • trunk/src/org/openstreetmap/josm/command/PurgeCommand.java

    r9243 r9371  
    1111import java.util.List;
    1212import java.util.Map;
     13import java.util.Objects;
    1314import java.util.Set;
    1415
     
    279280    @Override
    280281    public int hashCode() {
    281         final int prime = 31;
    282         int result = super.hashCode();
    283         result = prime * result + ((ds == null) ? 0 : ds.hashCode());
    284         result = prime * result + ((makeIncompleteData == null) ? 0 : makeIncompleteData.hashCode());
    285         result = prime * result + ((makeIncompleteDataByPrimId == null) ? 0 : makeIncompleteDataByPrimId.hashCode());
    286         result = prime * result + ((purgedConflicts == null) ? 0 : purgedConflicts.hashCode());
    287         result = prime * result + ((toPurge == null) ? 0 : toPurge.hashCode());
    288         return result;
     282        return Objects.hash(super.hashCode(), toPurge, makeIncompleteData, makeIncompleteDataByPrimId, purgedConflicts, ds);
    289283    }
    290284
    291285    @Override
    292286    public boolean equals(Object obj) {
    293         if (this == obj)
    294             return true;
    295         if (!super.equals(obj))
    296             return false;
    297         if (getClass() != obj.getClass())
    298             return false;
    299         PurgeCommand other = (PurgeCommand) obj;
    300         if (ds == null) {
    301             if (other.ds != null)
    302                 return false;
    303         } else if (!ds.equals(other.ds))
    304             return false;
    305         if (makeIncompleteData == null) {
    306             if (other.makeIncompleteData != null)
    307                 return false;
    308         } else if (!makeIncompleteData.equals(other.makeIncompleteData))
    309             return false;
    310         if (makeIncompleteDataByPrimId == null) {
    311             if (other.makeIncompleteDataByPrimId != null)
    312                 return false;
    313         } else if (!makeIncompleteDataByPrimId.equals(other.makeIncompleteDataByPrimId))
    314             return false;
    315         if (purgedConflicts == null) {
    316             if (other.purgedConflicts != null)
    317                 return false;
    318         } else if (!purgedConflicts.equals(other.purgedConflicts))
    319             return false;
    320         if (toPurge == null) {
    321             if (other.toPurge != null)
    322                 return false;
    323         } else if (!toPurge.equals(other.toPurge))
    324             return false;
    325         return true;
     287        if (this == obj) return true;
     288        if (obj == null || getClass() != obj.getClass()) return false;
     289        if (!super.equals(obj)) return false;
     290        PurgeCommand that = (PurgeCommand) obj;
     291        return Objects.equals(toPurge, that.toPurge) &&
     292                Objects.equals(makeIncompleteData, that.makeIncompleteData) &&
     293                Objects.equals(makeIncompleteDataByPrimId, that.makeIncompleteDataByPrimId) &&
     294                Objects.equals(purgedConflicts, that.purgedConflicts) &&
     295                Objects.equals(ds, that.ds);
    326296    }
    327297}
  • trunk/src/org/openstreetmap/josm/command/RemoveNodesCommand.java

    r8456 r9371  
    77import java.util.HashSet;
    88import java.util.List;
     9import java.util.Objects;
    910import java.util.Set;
    1011
     
    6566    @Override
    6667    public int hashCode() {
    67         final int prime = 31;
    68         int result = super.hashCode();
    69         result = prime * result + ((rmNodes == null) ? 0 : rmNodes.hashCode());
    70         result = prime * result + ((way == null) ? 0 : way.hashCode());
    71         return result;
     68        return Objects.hash(super.hashCode(), way, rmNodes);
    7269    }
    7370
    7471    @Override
    7572    public boolean equals(Object obj) {
    76         if (this == obj)
    77             return true;
    78         if (!super.equals(obj))
    79             return false;
    80         if (getClass() != obj.getClass())
    81             return false;
    82         RemoveNodesCommand other = (RemoveNodesCommand) obj;
    83         if (rmNodes == null) {
    84             if (other.rmNodes != null)
    85                 return false;
    86         } else if (!rmNodes.equals(other.rmNodes))
    87             return false;
    88         if (way == null) {
    89             if (other.way != null)
    90                 return false;
    91         } else if (!way.equals(other.way))
    92             return false;
    93         return true;
     73        if (this == obj) return true;
     74        if (obj == null || getClass() != obj.getClass()) return false;
     75        if (!super.equals(obj)) return false;
     76        RemoveNodesCommand that = (RemoveNodesCommand) obj;
     77        return Objects.equals(way, that.way) &&
     78                Objects.equals(rmNodes, that.rmNodes);
    9479    }
    9580}
  • 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}
  • trunk/src/org/openstreetmap/josm/command/ScaleCommand.java

    r9243 r9371  
    55
    66import java.util.Collection;
     7import java.util.Objects;
    78
    89import org.openstreetmap.josm.data.coor.EastNorth;
     
    8384    @Override
    8485    public int hashCode() {
    85         final int prime = 31;
    86         int result = super.hashCode();
    87         result = prime * result + ((pivot == null) ? 0 : pivot.hashCode());
    88         long temp;
    89         temp = Double.doubleToLongBits(scalingFactor);
    90         result = prime * result + (int) (temp ^ (temp >>> 32));
    91         result = prime * result + ((startEN == null) ? 0 : startEN.hashCode());
    92         return result;
     86        return Objects.hash(super.hashCode(), pivot, scalingFactor, startEN);
    9387    }
    9488
    9589    @Override
    9690    public boolean equals(Object obj) {
    97         if (this == obj)
    98             return true;
    99         if (!super.equals(obj))
    100             return false;
    101         if (getClass() != obj.getClass())
    102             return false;
    103         ScaleCommand other = (ScaleCommand) obj;
    104         if (pivot == null) {
    105             if (other.pivot != null)
    106                 return false;
    107         } else if (!pivot.equals(other.pivot))
    108             return false;
    109         if (Double.doubleToLongBits(scalingFactor) != Double.doubleToLongBits(other.scalingFactor))
    110             return false;
    111         if (startEN == null) {
    112             if (other.startEN != null)
    113                 return false;
    114         } else if (!startEN.equals(other.startEN))
    115             return false;
    116         return true;
     91        if (this == obj) return true;
     92        if (obj == null || getClass() != obj.getClass()) return false;
     93        if (!super.equals(obj)) return false;
     94        ScaleCommand that = (ScaleCommand) obj;
     95        return Double.compare(that.scalingFactor, scalingFactor) == 0 &&
     96                Objects.equals(pivot, that.pivot) &&
     97                Objects.equals(startEN, that.startEN);
    11798    }
    11899}
  • trunk/src/org/openstreetmap/josm/command/SelectCommand.java

    r8456 r9371  
    55
    66import java.util.Collection;
     7import java.util.Objects;
    78
    89import org.openstreetmap.josm.Main;
     
    5455    @Override
    5556    public int hashCode() {
    56         final int prime = 31;
    57         int result = super.hashCode();
    58         result = prime * result + ((newSelection == null) ? 0 : newSelection.hashCode());
    59         result = prime * result + ((oldSelection == null) ? 0 : oldSelection.hashCode());
    60         return result;
     57        return Objects.hash(super.hashCode(), newSelection, oldSelection);
    6158    }
    6259
    6360    @Override
    6461    public boolean equals(Object obj) {
    65         if (this == obj)
    66             return true;
    67         if (!super.equals(obj))
    68             return false;
    69         if (getClass() != obj.getClass())
    70             return false;
    71         SelectCommand other = (SelectCommand) obj;
    72         if (newSelection == null) {
    73             if (other.newSelection != null)
    74                 return false;
    75         } else if (!newSelection.equals(other.newSelection))
    76             return false;
    77         if (oldSelection == null) {
    78             if (other.oldSelection != null)
    79                 return false;
    80         } else if (!oldSelection.equals(other.oldSelection))
    81             return false;
    82         return true;
     62        if (this == obj) return true;
     63        if (obj == null || getClass() != obj.getClass()) return false;
     64        if (!super.equals(obj)) return false;
     65        SelectCommand that = (SelectCommand) obj;
     66        return Objects.equals(newSelection, that.newSelection) &&
     67                Objects.equals(oldSelection, that.oldSelection);
    8368    }
    8469}
  • trunk/src/org/openstreetmap/josm/command/SequenceCommand.java

    r8840 r9371  
    77import java.util.Collection;
    88import java.util.HashSet;
     9import java.util.Objects;
    910
    1011import javax.swing.Icon;
     
    126127    @Override
    127128    public int hashCode() {
    128         final int prime = 31;
    129         int result = super.hashCode();
    130         result = prime * result + (continueOnError ? 1231 : 1237);
    131         result = prime * result + ((name == null) ? 0 : name.hashCode());
    132         result = prime * result + Arrays.hashCode(sequence);
    133         result = prime * result + (sequenceComplete ? 1231 : 1237);
    134         return result;
     129        return Objects.hash(super.hashCode(), sequence, sequenceComplete, name, continueOnError);
    135130    }
    136131
    137132    @Override
    138133    public boolean equals(Object obj) {
    139         if (this == obj)
    140             return true;
    141         if (!super.equals(obj))
    142             return false;
    143         if (getClass() != obj.getClass())
    144             return false;
    145         SequenceCommand other = (SequenceCommand) obj;
    146         if (continueOnError != other.continueOnError)
    147             return false;
    148         if (name == null) {
    149             if (other.name != null)
    150                 return false;
    151         } else if (!name.equals(other.name))
    152             return false;
    153         if (!Arrays.equals(sequence, other.sequence))
    154             return false;
    155         if (sequenceComplete != other.sequenceComplete)
    156             return false;
    157         return true;
     134        if (this == obj) return true;
     135        if (obj == null || getClass() != obj.getClass()) return false;
     136        if (!super.equals(obj)) return false;
     137        SequenceCommand that = (SequenceCommand) obj;
     138        return sequenceComplete == that.sequenceComplete &&
     139                continueOnError == that.continueOnError &&
     140                Arrays.equals(sequence, that.sequence) &&
     141                Objects.equals(name, that.name);
    158142    }
    159143}
  • trunk/src/org/openstreetmap/josm/command/TransformNodesCommand.java

    r9243 r9371  
    88import java.util.LinkedList;
    99import java.util.Map;
     10import java.util.Objects;
    1011
    1112import javax.swing.Icon;
     
    145146    @Override
    146147    public int hashCode() {
    147         final int prime = 31;
    148         int result = super.hashCode();
    149         result = prime * result + ((nodes == null) ? 0 : nodes.hashCode());
    150         result = prime * result + ((oldStates == null) ? 0 : oldStates.hashCode());
    151         return result;
     148        return Objects.hash(super.hashCode(), nodes, oldStates);
    152149    }
    153150
    154151    @Override
    155152    public boolean equals(Object obj) {
    156         if (this == obj)
    157             return true;
    158         if (!super.equals(obj))
    159             return false;
    160         if (getClass() != obj.getClass())
    161             return false;
    162         TransformNodesCommand other = (TransformNodesCommand) obj;
    163         if (nodes == null) {
    164             if (other.nodes != null)
    165                 return false;
    166         } else if (!nodes.equals(other.nodes))
    167             return false;
    168         if (oldStates == null) {
    169             if (other.oldStates != null)
    170                 return false;
    171         } else if (!oldStates.equals(other.oldStates))
    172             return false;
    173         return true;
     153        if (this == obj) return true;
     154        if (obj == null || getClass() != obj.getClass()) return false;
     155        if (!super.equals(obj)) return false;
     156        TransformNodesCommand that = (TransformNodesCommand) obj;
     157        return Objects.equals(nodes, that.nodes) &&
     158                Objects.equals(oldStates, that.oldStates);
    174159    }
    175160}
  • trunk/src/org/openstreetmap/josm/command/conflict/ConflictAddCommand.java

    r8914 r9371  
    55
    66import java.util.Collection;
     7import java.util.Objects;
    78
    89import javax.swing.Icon;
     
    8990    @Override
    9091    public int hashCode() {
    91         final int prime = 31;
    92         int result = super.hashCode();
    93         result = prime * result + ((conflict == null) ? 0 : conflict.hashCode());
    94         return result;
     92        return Objects.hash(super.hashCode(), conflict);
    9593    }
    9694
    9795    @Override
    9896    public boolean equals(Object obj) {
    99         if (this == obj)
    100             return true;
    101         if (!super.equals(obj))
    102             return false;
    103         if (getClass() != obj.getClass())
    104             return false;
    105         ConflictAddCommand other = (ConflictAddCommand) obj;
    106         if (conflict == null) {
    107             if (other.conflict != null)
    108                 return false;
    109         } else if (!conflict.equals(other.conflict))
    110             return false;
    111         return true;
     97        if (this == obj) return true;
     98        if (obj == null || getClass() != obj.getClass()) return false;
     99        if (!super.equals(obj)) return false;
     100        ConflictAddCommand that = (ConflictAddCommand) obj;
     101        return Objects.equals(conflict, that.conflict);
    112102    }
    113103}
  • trunk/src/org/openstreetmap/josm/command/conflict/ConflictResolveCommand.java

    r8914 r9371  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     5
     6import java.util.Objects;
    57
    68import org.openstreetmap.josm.Main;
     
    8486    @Override
    8587    public int hashCode() {
    86         final int prime = 31;
    87         int result = super.hashCode();
    88         result = prime * result + ((resolvedConflicts == null) ? 0 : resolvedConflicts.hashCode());
    89         return result;
     88        return Objects.hash(super.hashCode(), resolvedConflicts);
    9089    }
    9190
    9291    @Override
    9392    public boolean equals(Object obj) {
    94         if (this == obj)
    95             return true;
    96         if (!super.equals(obj))
    97             return false;
    98         if (getClass() != obj.getClass())
    99             return false;
    100         ConflictResolveCommand other = (ConflictResolveCommand) obj;
    101         if (resolvedConflicts == null) {
    102             if (other.resolvedConflicts != null)
    103                 return false;
    104         } else if (!resolvedConflicts.equals(other.resolvedConflicts))
    105             return false;
    106         return true;
     93        if (this == obj) return true;
     94        if (obj == null || getClass() != obj.getClass()) return false;
     95        if (!super.equals(obj)) return false;
     96        ConflictResolveCommand that = (ConflictResolveCommand) obj;
     97        return Objects.equals(resolvedConflicts, that.resolvedConflicts);
    10798    }
    10899}
  • trunk/src/org/openstreetmap/josm/command/conflict/CoordinateConflictResolveCommand.java

    r8910 r9371  
    55
    66import java.util.Collection;
     7import java.util.Objects;
    78
    89import javax.swing.Icon;
     
    7677    @Override
    7778    public int hashCode() {
    78         final int prime = 31;
    79         int result = super.hashCode();
    80         result = prime * result + ((conflict == null) ? 0 : conflict.hashCode());
    81         result = prime * result + ((decision == null) ? 0 : decision.hashCode());
    82         return result;
     79        return Objects.hash(super.hashCode(), conflict, decision);
    8380    }
    8481
    8582    @Override
    8683    public boolean equals(Object obj) {
    87         if (this == obj)
    88             return true;
    89         if (!super.equals(obj))
    90             return false;
    91         if (getClass() != obj.getClass())
    92             return false;
    93         CoordinateConflictResolveCommand other = (CoordinateConflictResolveCommand) obj;
    94         if (conflict == null) {
    95             if (other.conflict != null)
    96                 return false;
    97         } else if (!conflict.equals(other.conflict))
    98             return false;
    99         if (decision != other.decision)
    100             return false;
    101         return true;
     84        if (this == obj) return true;
     85        if (obj == null || getClass() != obj.getClass()) return false;
     86        if (!super.equals(obj)) return false;
     87        CoordinateConflictResolveCommand that = (CoordinateConflictResolveCommand) obj;
     88        return Objects.equals(conflict, that.conflict) &&
     89                decision == that.decision;
    10290    }
    10391}
  • trunk/src/org/openstreetmap/josm/command/conflict/DeletedStateConflictResolveCommand.java

    r8910 r9371  
    55
    66import java.util.Collection;
     7import java.util.Objects;
    78import java.util.Set;
    89
     
    9192    @Override
    9293    public int hashCode() {
    93         final int prime = 31;
    94         int result = super.hashCode();
    95         result = prime * result + ((conflict == null) ? 0 : conflict.hashCode());
    96         result = prime * result + ((decision == null) ? 0 : decision.hashCode());
    97         return result;
     94        return Objects.hash(super.hashCode(), conflict, decision);
    9895    }
    9996
    10097    @Override
    10198    public boolean equals(Object obj) {
    102         if (this == obj)
    103             return true;
    104         if (!super.equals(obj))
    105             return false;
    106         if (getClass() != obj.getClass())
    107             return false;
    108         DeletedStateConflictResolveCommand other = (DeletedStateConflictResolveCommand) obj;
    109         if (conflict == null) {
    110             if (other.conflict != null)
    111                 return false;
    112         } else if (!conflict.equals(other.conflict))
    113             return false;
    114         if (decision != other.decision)
    115             return false;
    116         return true;
     99        if (this == obj) return true;
     100        if (obj == null || getClass() != obj.getClass()) return false;
     101        if (!super.equals(obj)) return false;
     102        DeletedStateConflictResolveCommand that = (DeletedStateConflictResolveCommand) obj;
     103        return Objects.equals(conflict, that.conflict) &&
     104                decision == that.decision;
    117105    }
    118106}
  • trunk/src/org/openstreetmap/josm/command/conflict/ModifiedConflictResolveCommand.java

    r8910 r9371  
    66
    77import java.util.Collection;
     8import java.util.Objects;
    89
    910import javax.swing.Icon;
     
    6768    @Override
    6869    public int hashCode() {
    69         final int prime = 31;
    70         int result = super.hashCode();
    71         result = prime * result + ((conflict == null) ? 0 : conflict.hashCode());
    72         return result;
     70        return Objects.hash(super.hashCode(), conflict);
    7371    }
    7472
    7573    @Override
    7674    public boolean equals(Object obj) {
    77         if (this == obj)
    78             return true;
    79         if (!super.equals(obj))
    80             return false;
    81         if (getClass() != obj.getClass())
    82             return false;
    83         ModifiedConflictResolveCommand other = (ModifiedConflictResolveCommand) obj;
    84         if (conflict == null) {
    85             if (other.conflict != null)
    86                 return false;
    87         } else if (!conflict.equals(other.conflict))
    88             return false;
    89         return true;
     75        if (this == obj) return true;
     76        if (obj == null || getClass() != obj.getClass()) return false;
     77        if (!super.equals(obj)) return false;
     78        ModifiedConflictResolveCommand that = (ModifiedConflictResolveCommand) obj;
     79        return Objects.equals(conflict, that.conflict);
    9080    }
    9181}
  • trunk/src/org/openstreetmap/josm/command/conflict/RelationMemberConflictResolverCommand.java

    r8510 r9371  
    66import java.util.Collection;
    77import java.util.List;
     8import java.util.Objects;
    89
    910import javax.swing.Icon;
     
    9899    @Override
    99100    public int hashCode() {
    100         final int prime = 31;
    101         int result = super.hashCode();
    102         result = prime * result + ((mergedMembers == null) ? 0 : mergedMembers.hashCode());
    103         result = prime * result + ((my == null) ? 0 : my.hashCode());
    104         result = prime * result + ((their == null) ? 0 : their.hashCode());
    105         return result;
     101        return Objects.hash(super.hashCode(), my, their, mergedMembers);
    106102    }
    107103
    108104    @Override
    109105    public boolean equals(Object obj) {
    110         if (this == obj)
    111             return true;
    112         if (!super.equals(obj))
    113             return false;
    114         if (getClass() != obj.getClass())
    115             return false;
    116         RelationMemberConflictResolverCommand other = (RelationMemberConflictResolverCommand) obj;
    117         if (mergedMembers == null) {
    118             if (other.mergedMembers != null)
    119                 return false;
    120         } else if (!mergedMembers.equals(other.mergedMembers))
    121             return false;
    122         if (my == null) {
    123             if (other.my != null)
    124                 return false;
    125         } else if (!my.equals(other.my))
    126             return false;
    127         if (their == null) {
    128             if (other.their != null)
    129                 return false;
    130         } else if (!their.equals(other.their))
    131             return false;
    132         return true;
     106        if (this == obj) return true;
     107        if (obj == null || getClass() != obj.getClass()) return false;
     108        if (!super.equals(obj)) return false;
     109        RelationMemberConflictResolverCommand that = (RelationMemberConflictResolverCommand) obj;
     110        return Objects.equals(my, that.my) &&
     111                Objects.equals(their, that.their) &&
     112                Objects.equals(mergedMembers, that.mergedMembers);
    133113    }
    134114}
  • trunk/src/org/openstreetmap/josm/command/conflict/TagConflictResolveCommand.java

    r8910 r9371  
    66import java.util.Collection;
    77import java.util.List;
     8import java.util.Objects;
    89
    910import javax.swing.Icon;
     
    103104    @Override
    104105    public int hashCode() {
    105         final int prime = 31;
    106         int result = super.hashCode();
    107         result = prime * result + ((conflict == null) ? 0 : conflict.hashCode());
    108         result = prime * result + ((mergeItems == null) ? 0 : mergeItems.hashCode());
    109         return result;
     106        return Objects.hash(super.hashCode(), conflict, mergeItems);
    110107    }
    111108
    112109    @Override
    113110    public boolean equals(Object obj) {
    114         if (this == obj)
    115             return true;
    116         if (!super.equals(obj))
    117             return false;
    118         if (getClass() != obj.getClass())
    119             return false;
    120         TagConflictResolveCommand other = (TagConflictResolveCommand) obj;
    121         if (conflict == null) {
    122             if (other.conflict != null)
    123                 return false;
    124         } else if (!conflict.equals(other.conflict))
    125             return false;
    126         if (mergeItems == null) {
    127             if (other.mergeItems != null)
    128                 return false;
    129         } else if (!mergeItems.equals(other.mergeItems))
    130             return false;
    131         return true;
     111        if (this == obj) return true;
     112        if (obj == null || getClass() != obj.getClass()) return false;
     113        if (!super.equals(obj)) return false;
     114        TagConflictResolveCommand that = (TagConflictResolveCommand) obj;
     115        return Objects.equals(conflict, that.conflict) &&
     116                Objects.equals(mergeItems, that.mergeItems);
    132117    }
    133118}
  • trunk/src/org/openstreetmap/josm/command/conflict/VersionConflictResolveCommand.java

    r8910 r9371  
    66
    77import java.util.Collection;
     8import java.util.Objects;
    89
    910import javax.swing.Icon;
     
    7677    @Override
    7778    public int hashCode() {
    78         final int prime = 31;
    79         int result = super.hashCode();
    80         result = prime * result + ((conflict == null) ? 0 : conflict.hashCode());
    81         return result;
     79        return Objects.hash(super.hashCode(), conflict);
    8280    }
    8381
    8482    @Override
    8583    public boolean equals(Object obj) {
    86         if (this == obj)
    87             return true;
    88         if (!super.equals(obj))
    89             return false;
    90         if (getClass() != obj.getClass())
    91             return false;
    92         VersionConflictResolveCommand other = (VersionConflictResolveCommand) obj;
    93         if (conflict == null) {
    94             if (other.conflict != null)
    95                 return false;
    96         } else if (!conflict.equals(other.conflict))
    97             return false;
    98         return true;
     84        if (this == obj) return true;
     85        if (obj == null || getClass() != obj.getClass()) return false;
     86        if (!super.equals(obj)) return false;
     87        VersionConflictResolveCommand that = (VersionConflictResolveCommand) obj;
     88        return Objects.equals(conflict, that.conflict);
    9989    }
    10090}
  • trunk/src/org/openstreetmap/josm/command/conflict/WayNodesConflictResolverCommand.java

    r8910 r9371  
    66import java.util.Collection;
    77import java.util.List;
     8import java.util.Objects;
    89
    910import javax.swing.Icon;
     
    7576    @Override
    7677    public int hashCode() {
    77         final int prime = 31;
    78         int result = super.hashCode();
    79         result = prime * result + ((conflict == null) ? 0 : conflict.hashCode());
    80         result = prime * result + ((mergedNodeList == null) ? 0 : mergedNodeList.hashCode());
    81         return result;
     78        return Objects.hash(super.hashCode(), conflict, mergedNodeList);
    8279    }
    8380
    8481    @Override
    8582    public boolean equals(Object obj) {
    86         if (this == obj)
    87             return true;
    88         if (!super.equals(obj))
    89             return false;
    90         if (getClass() != obj.getClass())
    91             return false;
    92         WayNodesConflictResolverCommand other = (WayNodesConflictResolverCommand) obj;
    93         if (conflict == null) {
    94             if (other.conflict != null)
    95                 return false;
    96         } else if (!conflict.equals(other.conflict))
    97             return false;
    98         if (mergedNodeList == null) {
    99             if (other.mergedNodeList != null)
    100                 return false;
    101         } else if (!mergedNodeList.equals(other.mergedNodeList))
    102             return false;
    103         return true;
     83        if (this == obj) return true;
     84        if (obj == null || getClass() != obj.getClass()) return false;
     85        if (!super.equals(obj)) return false;
     86        WayNodesConflictResolverCommand that = (WayNodesConflictResolverCommand) obj;
     87        return Objects.equals(conflict, that.conflict) &&
     88                Objects.equals(mergedNodeList, that.mergedNodeList);
    10489    }
    10590}
  • trunk/src/org/openstreetmap/josm/data/Bounds.java

    r9243 r9371  
    77import java.text.DecimalFormat;
    88import java.text.MessageFormat;
     9import java.util.Objects;
    910
    1011import org.openstreetmap.josm.data.coor.LatLon;
     
    443444    @Override
    444445    public int hashCode() {
    445         final int prime = 31;
    446         int result = 1;
    447         long temp;
    448         temp = Double.doubleToLongBits(maxLat);
    449         result = prime * result + (int) (temp ^ (temp >>> 32));
    450         temp = Double.doubleToLongBits(maxLon);
    451         result = prime * result + (int) (temp ^ (temp >>> 32));
    452         temp = Double.doubleToLongBits(minLat);
    453         result = prime * result + (int) (temp ^ (temp >>> 32));
    454         temp = Double.doubleToLongBits(minLon);
    455         result = prime * result + (int) (temp ^ (temp >>> 32));
    456         return result;
     446        return Objects.hash(minLat, minLon, maxLat, maxLon);
    457447    }
    458448
    459449    @Override
    460450    public boolean equals(Object obj) {
    461         if (this == obj)
    462             return true;
    463         if (obj == null)
    464             return false;
    465         if (getClass() != obj.getClass())
    466             return false;
    467         Bounds other = (Bounds) obj;
    468         if (Double.doubleToLongBits(maxLat) != Double.doubleToLongBits(other.maxLat))
    469             return false;
    470         if (Double.doubleToLongBits(maxLon) != Double.doubleToLongBits(other.maxLon))
    471             return false;
    472         if (Double.doubleToLongBits(minLat) != Double.doubleToLongBits(other.minLat))
    473             return false;
    474         if (Double.doubleToLongBits(minLon) != Double.doubleToLongBits(other.minLon))
    475             return false;
    476         return true;
     451        if (this == obj) return true;
     452        if (obj == null || getClass() != obj.getClass()) return false;
     453        Bounds bounds = (Bounds) obj;
     454        return Double.compare(bounds.minLat, minLat) == 0 &&
     455                Double.compare(bounds.minLon, minLon) == 0 &&
     456                Double.compare(bounds.maxLat, maxLat) == 0 &&
     457                Double.compare(bounds.maxLon, maxLon) == 0;
    477458    }
    478459}
  • trunk/src/org/openstreetmap/josm/data/DataSource.java

    r8846 r9371  
    66import java.util.Collection;
    77import java.util.List;
     8import java.util.Objects;
    89
    910import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    4041    @Override
    4142    public int hashCode() {
    42         final int prime = 31;
    43         int result = 1;
    44         result = prime * result + ((bounds == null) ? 0 : bounds.hashCode());
    45         result = prime * result + ((origin == null) ? 0 : origin.hashCode());
    46         return result;
     43        return Objects.hash(bounds, origin);
    4744    }
    4845
    4946    @Override
    5047    public boolean equals(Object obj) {
    51         if (this == obj)
    52             return true;
    53         if (obj == null)
    54             return false;
    55         if (getClass() != obj.getClass())
    56             return false;
    57         DataSource other = (DataSource) obj;
    58         if (bounds == null) {
    59             if (other.bounds != null)
    60                 return false;
    61         } else if (!bounds.equals(other.bounds))
    62             return false;
    63         if (origin == null) {
    64             if (other.origin != null)
    65                 return false;
    66         } else if (!origin.equals(other.origin))
    67             return false;
    68         return true;
     48        if (this == obj) return true;
     49        if (obj == null || getClass() != obj.getClass()) return false;
     50        DataSource that = (DataSource) obj;
     51        return Objects.equals(bounds, that.bounds) &&
     52                Objects.equals(origin, that.origin);
    6953    }
    7054
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r9312 r9371  
    228228        @Override
    229229        public int hashCode() {
    230             final int prime = 31;
    231             int result = 1;
    232             result = prime * result + ((value == null) ? 0 : value.hashCode());
    233             return result;
     230            return Objects.hash(value);
    234231        }
    235232
    236233        @Override
    237234        public boolean equals(Object obj) {
    238             if (this == obj)
    239                 return true;
    240             if (obj == null)
    241                 return false;
    242             if (!(obj instanceof AbstractSetting))
    243                 return false;
    244             AbstractSetting<?> other = (AbstractSetting<?>) obj;
    245             if (value == null) {
    246                 if (other.value != null)
    247                     return false;
    248             } else if (!value.equals(other.value))
    249                 return false;
    250             return true;
     235            if (this == obj) return true;
     236            if (obj == null || getClass() != obj.getClass()) return false;
     237            AbstractSetting<?> that = (AbstractSetting<?>) obj;
     238            return Objects.equals(value, that.value);
    251239        }
    252240    }
  • 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}
  • trunk/src/org/openstreetmap/josm/data/coor/Coordinate.java

    r7509 r9371  
    33
    44import java.io.Serializable;
     5import java.util.Objects;
    56
    67import org.openstreetmap.josm.data.osm.BBox;
     
    113114    }
    114115
    115     protected final int computeHashCode(int init) {
    116         final int prime = 31;
    117         int result = init;
    118         long temp;
    119         temp = java.lang.Double.doubleToLongBits(x);
    120         result = prime * result + (int) (temp ^ (temp >>> 32));
    121         temp = java.lang.Double.doubleToLongBits(y);
    122         result = prime * result + (int) (temp ^ (temp >>> 32));
    123         return result;
    124     }
    125 
    126     @Override
    127     public int hashCode() {
    128         return computeHashCode(1);
    129     }
    130 
    131     @Override
    132     public boolean equals(Object obj) {
    133         if (this == obj)
    134             return true;
    135         if (obj == null || getClass() != obj.getClass())
    136             return false;
    137         Coordinate other = (Coordinate) obj;
    138         if (java.lang.Double.doubleToLongBits(x) != java.lang.Double.doubleToLongBits(other.x))
    139             return false;
    140         if (java.lang.Double.doubleToLongBits(y) != java.lang.Double.doubleToLongBits(other.y))
    141             return false;
    142         return true;
    143     }
    144116}
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r9243 r9371  
    1616import java.util.Arrays;
    1717import java.util.Locale;
     18import java.util.Objects;
    1819
    1920import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
     
    428429    @Override
    429430    public int hashCode() {
    430         return computeHashCode(super.hashCode());
     431        return Objects.hash(super.hashCode());
    431432    }
    432433
    433434    @Override
    434435    public boolean equals(Object obj) {
    435         if (this == obj)
    436             return true;
    437         if (!super.equals(obj))
    438             return false;
    439         if (getClass() != obj.getClass())
    440             return false;
    441         Coordinate other = (Coordinate) obj;
    442         if (java.lang.Double.doubleToLongBits(x) != java.lang.Double.doubleToLongBits(other.x))
    443             return false;
    444         if (java.lang.Double.doubleToLongBits(y) != java.lang.Double.doubleToLongBits(other.y))
    445             return false;
    446         return true;
     436        if (this == obj) return true;
     437        if (obj == null || getClass() != obj.getClass()) return false;
     438        return super.equals(obj);
    447439    }
    448440
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r9135 r9371  
    134134        @Override
    135135        public int hashCode() {
    136             final int prime = 31;
    137             int result = super.hashCode();
    138             result = prime * result + ((shapes == null) ? 0 : shapes.hashCode());
    139             return result;
     136            return Objects.hash(super.hashCode(), shapes);
    140137        }
    141138
    142139        @Override
    143         public boolean equals(Object obj) {
    144             if (this == obj)
    145                 return true;
    146             if (!super.equals(obj))
    147                 return false;
    148             if (getClass() != obj.getClass())
    149                 return false;
    150             ImageryBounds other = (ImageryBounds) obj;
    151             if (shapes == null) {
    152                 if (other.shapes != null)
    153                     return false;
    154             } else if (!shapes.equals(other.shapes))
    155                 return false;
    156             return true;
     140        public boolean equals(Object o) {
     141            if (this == o) return true;
     142            if (o == null || getClass() != o.getClass()) return false;
     143            if (!super.equals(o)) return false;
     144            ImageryBounds that = (ImageryBounds) o;
     145            return Objects.equals(shapes, that.shapes);
    157146        }
    158147    }
     
    457446
    458447    @Override
    459     public boolean equals(Object o) {
    460         if (this == o) return true;
    461         if (o == null || getClass() != o.getClass()) return false;
    462 
    463         ImageryInfo that = (ImageryInfo) o;
    464 
    465         if (imageryType != that.imageryType) return false;
    466         if (url != null ? !url.equals(that.url) : that.url != null) return false;
    467         if (name != null ? !name.equals(that.name) : that.name != null) return false;
    468 
    469         return true;
     448    public int hashCode() {
     449        return Objects.hash(url, imageryType);
    470450    }
    471451
     
    509489
    510490    @Override
    511     public int hashCode() {
    512         int result = url != null ? url.hashCode() : 0;
    513         result = 31 * result + (imageryType != null ? imageryType.hashCode() : 0);
    514         return result;
     491    public boolean equals(Object o) {
     492        if (this == o) return true;
     493        if (o == null || getClass() != o.getClass()) return false;
     494        ImageryInfo that = (ImageryInfo) o;
     495        return imageryType == that.imageryType && Objects.equals(url, that.url);
    515496    }
    516497
  • trunk/src/org/openstreetmap/josm/data/imagery/Shape.java

    r8510 r9371  
    9393    @Override
    9494    public int hashCode() {
    95         int hash = 5;
    96         hash = 47 * hash + Objects.hashCode(this.coords);
    97         return hash;
     95        return Objects.hash(coords);
    9896    }
    9997
    10098    @Override
    10199    public boolean equals(Object obj) {
    102         if (obj == null) {
    103             return false;
    104         }
    105         if (getClass() != obj.getClass()) {
    106             return false;
    107         }
    108         final Shape other = (Shape) obj;
    109         if (!Objects.equals(this.coords, other.coords)) {
    110             return false;
    111         }
    112         return true;
     100        if (this == obj) return true;
     101        if (obj == null || getClass() != obj.getClass()) return false;
     102        Shape shape = (Shape) obj;
     103        return Objects.equals(coords, shape.coords);
    113104    }
    114105}
  • trunk/src/org/openstreetmap/josm/data/notes/Note.java

    r9070 r9371  
    55import java.util.Date;
    66import java.util.List;
     7import java.util.Objects;
    78
    89import org.openstreetmap.josm.data.coor.LatLon;
     
    104105    @Override
    105106    public int hashCode() {
    106         final int prime = 31;
    107         int result = 1;
    108         result = prime * result + (int) (id ^ (id >>> 32));
    109         return result;
     107        return Objects.hash(id);
    110108    }
    111109
    112     /** Compares notes by OSM ID */
    113110    @Override
    114111    public boolean equals(Object obj) {
    115         if (this == obj)
    116             return true;
    117         if (obj == null)
    118             return false;
    119         if (getClass() != obj.getClass())
    120             return false;
    121         Note other = (Note) obj;
    122         if (id != other.id)
    123             return false;
    124         return true;
     112        if (this == obj) return true;
     113        if (obj == null || getClass() != obj.getClass()) return false;
     114        Note note = (Note) obj;
     115        return id == note.id;
    125116    }
    126117}
  • trunk/src/org/openstreetmap/josm/data/oauth/OAuthToken.java

    r9067 r9371  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.oauth;
     3
     4import java.util.Objects;
    35
    46import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    6466    @Override
    6567    public int hashCode() {
    66         final int prime = 31;
    67         int result = 1;
    68         result = prime * result + ((key == null) ? 0 : key.hashCode());
    69         result = prime * result + ((secret == null) ? 0 : secret.hashCode());
    70         return result;
     68        return Objects.hash(key, secret);
    7169    }
    7270
    7371    @Override
    7472    public boolean equals(Object obj) {
    75         if (this == obj)
    76             return true;
    77         if (obj == null)
    78             return false;
    79         if (getClass() != obj.getClass())
    80             return false;
    81         OAuthToken other = (OAuthToken) obj;
    82         if (key == null) {
    83             if (other.key != null)
    84                 return false;
    85         } else if (!key.equals(other.key))
    86             return false;
    87         if (secret == null) {
    88             if (other.secret != null)
    89                 return false;
    90         } else if (!secret.equals(other.secret))
    91             return false;
    92         return true;
     73        if (this == obj) return true;
     74        if (obj == null || getClass() != obj.getClass()) return false;
     75        OAuthToken that = (OAuthToken) obj;
     76        return Objects.equals(key, that.key) &&
     77                Objects.equals(secret, that.secret);
    9378    }
    9479}
  • trunk/src/org/openstreetmap/josm/data/osm/BBox.java

    r9243 r9371  
    44import java.awt.geom.Rectangle2D;
    55import java.util.Arrays;
     6import java.util.Objects;
    67
    78import org.openstreetmap.josm.data.coor.LatLon;
  • trunk/src/org/openstreetmap/josm/data/osm/Changeset.java

    r8840 r9371  
    99import java.util.List;
    1010import java.util.Map;
     11import java.util.Objects;
    1112
    1213import org.openstreetmap.josm.data.Bounds;
     
    278279    @Override
    279280    public int hashCode() {
    280         if (id > 0)
    281             return id;
    282         else
    283             return super.hashCode();
     281        return Objects.hash(id);
    284282    }
    285283
    286284    @Override
    287285    public boolean equals(Object obj) {
    288         if (this == obj)
    289             return true;
    290         if (obj == null)
    291             return false;
    292         if (getClass() != obj.getClass())
    293             return false;
    294         Changeset other = (Changeset) obj;
    295         if (this.id > 0 && other.id == this.id)
    296             return true;
    297         return this == obj;
     286        if (this == obj) return true;
     287        if (obj == null || getClass() != obj.getClass()) return false;
     288        Changeset changeset = (Changeset) obj;
     289        return id == changeset.id;
    298290    }
    299291
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r9268 r9371  
    1717import java.util.Locale;
    1818import java.util.Map;
     19import java.util.Objects;
    1920import java.util.Set;
    2021
     
    13201321    @Override
    13211322    public boolean equals(Object obj) {
    1322         if (obj instanceof OsmPrimitive)
    1323             return ((OsmPrimitive) obj).id == id && obj.getClass() == getClass();
    1324         return false;
     1323        if (this == obj) return true;
     1324        if (obj == null || getClass() != obj.getClass()) return false;
     1325        OsmPrimitive that = (OsmPrimitive) obj;
     1326        return Objects.equals(id, that.id);
    13251327    }
    13261328
     
    13311333     */
    13321334    @Override
    1333     public final int hashCode() {
    1334         return (int) id;
     1335    public int hashCode() {
     1336        return Objects.hash(id);
    13351337    }
    13361338
  • trunk/src/org/openstreetmap/josm/data/osm/RelationMember.java

    r8510 r9371  
    33
    44import java.util.Arrays;
     5import java.util.Objects;
    56
    67import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    165166    @Override
    166167    public int hashCode() {
    167         final int prime = 31;
    168         int result = 1;
    169         result = prime * result + member.hashCode();
    170         result = prime * result + role.hashCode();
    171         return result;
     168        return Objects.hash(role, member);
    172169    }
    173170
    174171    @Override
    175172    public boolean equals(Object obj) {
    176         if (obj instanceof RelationMember) {
    177             RelationMember other = (RelationMember) obj;
    178             return member.equals(other.getMember()) && role.equals(other.getRole());
    179         } else
    180             return false;
     173        if (this == obj) return true;
     174        if (obj == null || getClass() != obj.getClass()) return false;
     175        RelationMember that = (RelationMember) obj;
     176        return Objects.equals(role, that.role) &&
     177                Objects.equals(member, that.member);
    181178    }
    182179
  • trunk/src/org/openstreetmap/josm/data/osm/RelationMemberData.java

    r8846 r9371  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm;
     3
     4import java.util.Objects;
    35
    46public class RelationMemberData implements PrimitiveId {
     
    6264    @Override
    6365    public int hashCode() {
    64         final int prime = 31;
    65         int result = 1;
    66         result = prime * result + (int) (memberId ^ (memberId >>> 32));
    67         result = prime * result
    68                 + ((memberType == null) ? 0 : memberType.hashCode());
    69         result = prime * result + ((role == null) ? 0 : role.hashCode());
    70         return result;
     66        return Objects.hash(role, memberId, memberType);
    7167    }
    7268
    7369    @Override
    7470    public boolean equals(Object obj) {
    75         if (this == obj)
    76             return true;
    77         if (obj == null)
    78             return false;
    79         if (getClass() != obj.getClass())
    80             return false;
    81         RelationMemberData other = (RelationMemberData) obj;
    82         if (memberId != other.memberId)
    83             return false;
    84         if (memberType != other.memberType)
    85             return false;
    86         if (role == null) {
    87             if (other.role != null)
    88                 return false;
    89         } else if (!role.equals(other.role))
    90             return false;
    91         return true;
     71        if (this == obj) return true;
     72        if (obj == null || getClass() != obj.getClass()) return false;
     73        RelationMemberData that = (RelationMemberData) obj;
     74        return memberId == that.memberId &&
     75                Objects.equals(role, that.role) &&
     76                memberType == that.memberType;
    9277    }
    9378}
  • 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}
  • trunk/src/org/openstreetmap/josm/data/osm/SimplePrimitiveId.java

    r8496 r9371  
    55import java.util.ArrayList;
    66import java.util.List;
     7import java.util.Objects;
    78import java.util.regex.MatchResult;
    89import java.util.regex.Matcher;
     
    4243    @Override
    4344    public int hashCode() {
    44         final int prime = 31;
    45         int result = 1;
    46         result = prime * result + (int) (id ^ (id >>> 32));
    47         result = prime * result + ((type == null) ? 0 : type.hashCode());
    48         return result;
     45        return Objects.hash(id, type);
    4946    }
    5047
    5148    @Override
    5249    public boolean equals(Object obj) {
    53         if (this == obj)
    54             return true;
    55         if (obj == null)
    56             return false;
    57         if (getClass() != obj.getClass())
    58             return false;
    59         SimplePrimitiveId other = (SimplePrimitiveId) obj;
    60         if (id != other.id)
    61             return false;
    62         if (type == null) {
    63             if (other.type != null)
    64                 return false;
    65         } else if (!type.equals(other.type))
    66             return false;
    67         return true;
     50        if (this == obj) return true;
     51        if (obj == null || getClass() != obj.getClass()) return false;
     52        SimplePrimitiveId that = (SimplePrimitiveId) obj;
     53        return id == that.id &&
     54                type == that.type;
    6855    }
    6956
  • trunk/src/org/openstreetmap/josm/data/osm/Tag.java

    r8846 r9371  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm;
     3
     4import java.util.Objects;
    35
    46import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    8486    @Override
    8587    public int hashCode() {
    86         final int prime = 31;
    87         int result = 1;
    88         result = prime * result + key.hashCode();
    89         result = prime * result + value.hashCode();
    90         return result;
     88        return Objects.hash(key, value);
    9189    }
    9290
    9391    @Override
    9492    public boolean equals(Object obj) {
    95         if (obj instanceof Tag) {
    96             Tag other = (Tag) obj;
    97             return key.equals(other.getKey()) && value.equals(other.getValue());
    98         } else
    99             return false;
     93        if (this == obj) return true;
     94        if (obj == null || getClass() != obj.getClass()) return false;
     95        Tag tag = (Tag) obj;
     96        return Objects.equals(key, tag.key) &&
     97                Objects.equals(value, tag.value);
    10098    }
    10199
  • trunk/src/org/openstreetmap/josm/data/osm/User.java

    r9243 r9371  
    99import java.util.List;
    1010import java.util.Map;
     11import java.util.Objects;
    1112import java.util.Set;
    1213
     
    219220    @Override
    220221    public int hashCode() {
    221         final int prime = 31;
    222         int result = 1;
    223         result = prime * result + getName().hashCode();
    224         result = prime * result + (int) (uid ^ (uid >>> 32));
    225         return result;
     222        return Objects.hash(uid);
    226223    }
    227224
    228225    @Override
    229226    public boolean equals(Object obj) {
    230         if (!(obj instanceof User))
    231             return false;
    232         User other = (User) obj;
    233         if (uid != other.uid)
    234             return false;
    235         return true;
     227        if (this == obj) return true;
     228        if (obj == null || getClass() != obj.getClass()) return false;
     229        User user = (User) obj;
     230        return uid == user.uid;
    236231    }
    237232
  • trunk/src/org/openstreetmap/josm/data/osm/WaySegment.java

    r9243 r9371  
    33
    44import java.awt.geom.Line2D;
     5import java.util.Objects;
    56
    67/**
     
    7980    @Override
    8081    public boolean equals(Object o) {
    81         return o instanceof WaySegment
    82             && ((WaySegment) o).way == way
    83             && ((WaySegment) o).lowerIndex == lowerIndex;
     82        if (this == o) return true;
     83        if (o == null || getClass() != o.getClass()) return false;
     84        WaySegment that = (WaySegment) o;
     85        return lowerIndex == that.lowerIndex &&
     86                Objects.equals(way, that.way);
    8487    }
    8588
    8689    @Override
    8790    public int hashCode() {
    88         return way.hashCode() ^ lowerIndex;
     91        return Objects.hash(way, lowerIndex);
    8992    }
    9093
  • trunk/src/org/openstreetmap/josm/data/osm/event/DatasetEventManager.java

    r9059 r9371  
    55import java.util.Arrays;
    66import java.util.List;
     7import java.util.Objects;
    78import java.util.Queue;
    89import java.util.concurrent.CopyOnWriteArrayList;
     
    115116        @Override
    116117        public int hashCode() {
    117             return listener.hashCode();
     118            return Objects.hash(listener);
    118119        }
    119120
    120121        @Override
    121122        public boolean equals(Object o) {
    122             return o instanceof ListenerInfo && ((ListenerInfo) o).listener == listener;
     123            if (this == o) return true;
     124            if (o == null || getClass() != o.getClass()) return false;
     125            ListenerInfo that = (ListenerInfo) o;
     126            return Objects.equals(listener, that.listener);
    123127        }
    124128    }
  • trunk/src/org/openstreetmap/josm/data/osm/event/SelectionEventManager.java

    r8836 r9371  
    44import java.util.Collection;
    55import java.util.List;
     6import java.util.Objects;
    67import java.util.concurrent.CopyOnWriteArrayList;
    78
     
    3536        @Override
    3637        public int hashCode() {
    37             return listener.hashCode();
     38            return Objects.hash(listener);
    3839        }
    3940
    4041        @Override
    4142        public boolean equals(Object o) {
    42             return o instanceof ListenerInfo && ((ListenerInfo) o).listener == listener;
     43            if (this == o) return true;
     44            if (o == null || getClass() != o.getClass()) return false;
     45            ListenerInfo that = (ListenerInfo) o;
     46            return Objects.equals(listener, that.listener);
    4347        }
    4448    }
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java

    r8846 r9371  
    1010import java.util.Locale;
    1111import java.util.Map;
     12import java.util.Objects;
    1213
    1314import org.openstreetmap.josm.data.osm.Changeset;
     
    249250    @Override
    250251    public int hashCode() {
    251         final int prime = 31;
    252         int result = 1;
    253         result = prime * result + (int) (id ^ (id >>> 32));
    254         result = prime * result + (int) (version ^ (version >>> 32));
    255         return result;
     252        return Objects.hash(id, version);
    256253    }
    257254
    258255    @Override
    259256    public boolean equals(Object obj) {
    260         if (this == obj)
    261             return true;
    262         if (!(obj instanceof HistoryOsmPrimitive))
    263             return false;
    264         // equal semantics is valid for subclasses like {@link HistoryOsmNode} etc. too.
    265         // So, don't enforce equality of class.
    266         HistoryOsmPrimitive other = (HistoryOsmPrimitive) obj;
    267         if (id != other.id)
    268             return false;
    269         if (version != other.version)
    270             return false;
    271         return true;
     257        if (this == obj) return true;
     258        if (obj == null || getClass() != obj.getClass()) return false;
     259        HistoryOsmPrimitive that = (HistoryOsmPrimitive) obj;
     260        return id == that.id &&
     261                version == that.version;
    272262    }
    273263
  • trunk/src/org/openstreetmap/josm/data/validation/PaintVisitor.java

    r8444 r9371  
    77import java.util.HashSet;
    88import java.util.List;
     9import java.util.Objects;
    910import java.util.Set;
    1011
     
    5859        @Override
    5960        public int hashCode() {
    60             final int prime = 31;
    61             int result = 1;
    62             result = prime * result + p1.hashCode();
    63             result = prime * result + color.hashCode();
    64             return result;
     61            return Objects.hash(p1, color);
    6562        }
    6663
    6764        @Override
    6865        public boolean equals(Object obj) {
    69             if (this == obj)
    70                 return true;
    71             if (obj == null)
    72                 return false;
    73             if (getClass() != obj.getClass())
    74                 return false;
    75             PaintedPoint other = (PaintedPoint) obj;
    76             if (!p1.equals(other.p1))
    77                 return false;
    78             if (!color.equals(other.color))
    79                 return false;
    80             return true;
     66            if (this == obj) return true;
     67            if (obj == null || getClass() != obj.getClass()) return false;
     68            PaintedPoint that = (PaintedPoint) obj;
     69            return Objects.equals(p1, that.p1) &&
     70                    Objects.equals(color, that.color);
    8171        }
    8272    }
     
    9282        @Override
    9383        public int hashCode() {
    94             final int prime = 31;
    95             int result = super.hashCode();
    96             result = prime * result + p2.hashCode();
    97             return result;
     84            return Objects.hash(super.hashCode(), p2);
    9885        }
    9986
    10087        @Override
    10188        public boolean equals(Object obj) {
    102             if (!super.equals(obj)) {
    103                 return false;
    104             }
    105             PaintedSegment other = (PaintedSegment) obj;
    106             if (!p2.equals(other.p2))
    107                 return false;
    108             return true;
     89            if (this == obj) return true;
     90            if (obj == null || getClass() != obj.getClass()) return false;
     91            if (!super.equals(obj)) return false;
     92            PaintedSegment that = (PaintedSegment) obj;
     93            return Objects.equals(p2, that.p2);
    10994        }
    11095    }
  • trunk/src/org/openstreetmap/josm/data/validation/Test.java

    r9345 r9371  
    88import java.util.Collection;
    99import java.util.List;
     10import java.util.Objects;
    1011
    1112import javax.swing.JCheckBox;
     
    340341    @Override
    341342    public int hashCode() {
    342         final int prime = 31;
    343         int result = 1;
    344         result = prime * result + ((description == null) ? 0 : description.hashCode());
    345         result = prime * result + ((name == null) ? 0 : name.hashCode());
    346         return result;
     343        return Objects.hash(name, description);
    347344    }
    348345
    349346    @Override
    350347    public boolean equals(Object obj) {
    351         if (this == obj)
    352             return true;
    353         if (obj == null)
    354             return false;
    355         if (!(obj instanceof Test))
    356             return false;
    357         Test other = (Test) obj;
    358         if (description == null) {
    359             if (other.description != null)
    360                 return false;
    361         } else if (!description.equals(other.description))
    362             return false;
    363         if (name == null) {
    364             if (other.name != null)
    365                 return false;
    366         } else if (!name.equals(other.name))
    367             return false;
    368         return true;
     348        if (this == obj) return true;
     349        if (obj == null || getClass() != obj.getClass()) return false;
     350        Test test = (Test) obj;
     351        return Objects.equals(name, test.name) &&
     352                Objects.equals(description, test.description);
    369353    }
    370354}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java

    r9067 r9371  
    1010import java.util.List;
    1111import java.util.Map;
     12import java.util.Objects;
    1213import java.util.Set;
    1314
     
    5556        @Override
    5657        public int hashCode() {
    57             return role.hashCode()+(int) relId+tags.hashCode()+type.hashCode()+coor.hashCode();
     58            return Objects.hash(role, type, tags, coor, relId);
    5859        }
    5960
    6061        @Override
    6162        public boolean equals(Object obj) {
    62             if (!(obj instanceof RelMember)) return false;
    63             RelMember rm = (RelMember) obj;
    64             return rm.role.equals(role) && rm.type.equals(type) && rm.relId == relId && rm.tags.equals(tags) && rm.coor.equals(coor);
     63            if (this == obj) return true;
     64            if (obj == null || getClass() != obj.getClass()) return false;
     65            RelMember relMember = (RelMember) obj;
     66            return relId == relMember.relId &&
     67                    Objects.equals(role, relMember.role) &&
     68                    type == relMember.type &&
     69                    Objects.equals(tags, relMember.tags) &&
     70                    Objects.equals(coor, relMember.coor);
    6571        }
    6672
     
    117123        @Override
    118124        public int hashCode() {
    119             return members.hashCode();
     125            return Objects.hash(members);
    120126        }
    121127
    122128        @Override
    123129        public boolean equals(Object obj) {
    124             if (!(obj instanceof RelationMembers)) return false;
    125             RelationMembers rm = (RelationMembers) obj;
    126             return rm.members.equals(members);
     130            if (this == obj) return true;
     131            if (obj == null || getClass() != obj.getClass()) return false;
     132            RelationMembers that = (RelationMembers) obj;
     133            return Objects.equals(members, that.members);
    127134        }
    128135    }
     
    148155        @Override
    149156        public int hashCode() {
    150             return members.hashCode()+keys.hashCode();
     157            return Objects.hash(members, keys);
    151158        }
    152159
    153160        @Override
    154161        public boolean equals(Object obj) {
    155             if (!(obj instanceof RelationPair)) return false;
    156             RelationPair rp = (RelationPair) obj;
    157             return rp.members.equals(members) && rp.keys.equals(keys);
     162            if (this == obj) return true;
     163            if (obj == null || getClass() != obj.getClass()) return false;
     164            RelationPair that = (RelationPair) obj;
     165            return Objects.equals(members, that.members) &&
     166                    Objects.equals(keys, that.keys);
    158167        }
    159168    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java

    r8850 r9371  
    1111import java.util.List;
    1212import java.util.Map;
     13import java.util.Objects;
    1314import java.util.Set;
    1415
     
    4950        @Override
    5051        public int hashCode() {
    51             return coor.hashCode() + keys.hashCode();
     52            return Objects.hash(coor, keys);
    5253        }
    5354
    5455        @Override
    5556        public boolean equals(Object obj) {
    56             if (!(obj instanceof WayPair))
    57                 return false;
    58             WayPair wp = (WayPair) obj;
    59             return wp.coor.equals(coor) && wp.keys.equals(keys);
     57            if (this == obj) return true;
     58            if (obj == null || getClass() != obj.getClass()) return false;
     59            WayPair wayPair = (WayPair) obj;
     60            return Objects.equals(coor, wayPair.coor) &&
     61                    Objects.equals(keys, wayPair.keys);
    6062        }
    6163    }
     
    7476        @Override
    7577        public int hashCode() {
    76             return coor.hashCode();
     78            return Objects.hash(coor);
    7779        }
    7880
    7981        @Override
    8082        public boolean equals(Object obj) {
    81             if (!(obj instanceof WayPairNoTags)) return false;
    82             WayPairNoTags wp = (WayPairNoTags) obj;
    83             return wp.coor.equals(coor);
     83            if (this == obj) return true;
     84            if (obj == null || getClass() != obj.getClass()) return false;
     85            WayPairNoTags that = (WayPairNoTags) obj;
     86            return Objects.equals(coor, that.coor);
    8487        }
    8588    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r9359 r9371  
    2323import java.util.Locale;
    2424import java.util.Map;
     25import java.util.Objects;
    2526import java.util.Set;
    2627import java.util.regex.Matcher;
     
    9596        @Override
    9697        public int hashCode() {
    97             final int prime = 31;
    98             int result = 1;
    99             result = prime * result + ((declaration == null) ? 0 : declaration.hashCode());
    100             result = prime * result + ((selectors == null) ? 0 : selectors.hashCode());
    101             return result;
     98            return Objects.hash(selectors, declaration);
    10299        }
    103100
    104101        @Override
    105102        public boolean equals(Object obj) {
    106             if (this == obj)
    107                 return true;
    108             if (obj == null)
    109                 return false;
    110             if (!(obj instanceof GroupedMapCSSRule))
    111                 return false;
    112             GroupedMapCSSRule other = (GroupedMapCSSRule) obj;
    113             if (declaration == null) {
    114                 if (other.declaration != null)
    115                     return false;
    116             } else if (!declaration.equals(other.declaration))
    117                 return false;
    118             if (selectors == null) {
    119                 if (other.selectors != null)
    120                     return false;
    121             } else if (!selectors.equals(other.selectors))
    122                 return false;
    123             return true;
     103            if (this == obj) return true;
     104            if (obj == null || getClass() != obj.getClass()) return false;
     105            GroupedMapCSSRule that = (GroupedMapCSSRule) obj;
     106            return Objects.equals(selectors, that.selectors) &&
     107                    Objects.equals(declaration, that.declaration);
    124108        }
    125109
     
    660644        @Override
    661645        public int hashCode() {
    662             final int prime = 31;
    663             int result = super.hashCode();
    664             result = prime * result + ((rule == null) ? 0 : rule.hashCode());
    665             return result;
     646            return Objects.hash(super.hashCode(), rule);
    666647        }
    667648
     
    825806    @Override
    826807    public synchronized int hashCode() {
    827         final int prime = 31;
    828         int result = super.hashCode();
    829         result = prime * result + ((checks == null) ? 0 : checks.hashCode());
    830         return result;
     808        return Objects.hash(super.hashCode(), checks);
    831809    }
    832810
    833811    @Override
    834812    public synchronized boolean equals(Object obj) {
    835         if (this == obj)
    836             return true;
    837         if (!super.equals(obj))
    838             return false;
    839         if (!(obj instanceof MapCSSTagChecker))
    840             return false;
    841         MapCSSTagChecker other = (MapCSSTagChecker) obj;
    842         if (checks == null) {
    843             if (other.checks != null)
    844                 return false;
    845         } else if (!checks.equals(other.checks))
    846             return false;
    847         return true;
     813        if (this == obj) return true;
     814        if (obj == null || getClass() != obj.getClass()) return false;
     815        if (!super.equals(obj)) return false;
     816        MapCSSTagChecker that = (MapCSSTagChecker) obj;
     817        return Objects.equals(checks, that.checks);
    848818    }
    849819}
  • 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
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java

    r9246 r9371  
    5454        @Override
    5555        public int hashCode() {
    56             final int prime = 31;
    57             int result = 1;
    58             result = prime * result + ((layer == null) ? 0 : layer.hashCode());
    59             result = prime * result + ((relation == null) ? 0 : relation.hashCode());
    60             return result;
     56            return Objects.hash(relation, layer);
    6157        }
    6258
    6359        @Override
    6460        public boolean equals(Object obj) {
    65             if (this == obj)
    66                 return true;
    67             if (obj == null)
    68                 return false;
    69             if (getClass() != obj.getClass())
    70                 return false;
    71             DialogContext other = (DialogContext) obj;
    72             if (layer == null) {
    73                 if (other.layer != null)
    74                     return false;
    75             } else if (!layer.equals(other.layer))
    76                 return false;
    77             if (relation == null) {
    78                 if (other.relation != null)
    79                     return false;
    80             } else if (!relation.equals(other.relation))
    81                 return false;
    82             return true;
     61            if (this == obj) return true;
     62            if (obj == null || getClass() != obj.getClass()) return false;
     63            DialogContext that = (DialogContext) obj;
     64            return Objects.equals(relation, that.relation) &&
     65                    Objects.equals(layer, that.layer);
    8366        }
    8467
  • trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java

    r8836 r9371  
    1212import java.util.List;
    1313import java.util.Locale;
     14import java.util.Objects;
    1415
    1516import javax.swing.DefaultListModel;
     
    7980        @Override
    8081        public int hashCode() {
    81             final int prime = 31;
    82             int result = 1;
    83             result = prime * result + ((area == null) ? 0 : area.hashCode());
    84             result = prime * result + ((name == null) ? 0 : name.hashCode());
    85             return result;
     82            return Objects.hash(name, area);
    8683        }
    8784
    8885        @Override
    8986        public boolean equals(Object obj) {
    90             if (this == obj)
    91                 return true;
    92             if (obj == null)
    93                 return false;
    94             if (getClass() != obj.getClass())
    95                 return false;
    96             Bookmark other = (Bookmark) obj;
    97             if (area == null) {
    98                 if (other.area != null)
    99                     return false;
    100             } else if (!area.equals(other.area))
    101                 return false;
    102             if (name == null) {
    103                 if (other.name != null)
    104                     return false;
    105             } else if (!name.equals(other.name))
    106                 return false;
    107             return true;
     87            if (this == obj) return true;
     88            if (obj == null || getClass() != obj.getClass()) return false;
     89            Bookmark bookmark = (Bookmark) obj;
     90            return Objects.equals(name, bookmark.name) &&
     91                    Objects.equals(area, bookmark.area);
    10892        }
    10993
  • trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySpecification.java

    r8510 r9371  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.io;
     3
     4import java.util.Objects;
    35
    46/**
     
    107109    @Override
    108110    public int hashCode() {
    109         final int prime = 31;
    110         int result = 1;
    111         result = prime * result + chunkSize;
    112         result = prime * result + (closeChangesetAfterUpload ? 1231 : 1237);
    113         result = prime * result + ((policy == null) ? 0 : policy.hashCode());
    114         result = prime * result + ((strategy == null) ? 0 : strategy.hashCode());
    115         return result;
     111        return Objects.hash(strategy, chunkSize, policy, closeChangesetAfterUpload);
    116112    }
    117113
    118114    @Override
    119115    public boolean equals(Object obj) {
    120         if (this == obj)
    121             return true;
    122         if (obj == null)
    123             return false;
    124         if (getClass() != obj.getClass())
    125             return false;
    126         UploadStrategySpecification other = (UploadStrategySpecification) obj;
    127         if (chunkSize != other.chunkSize)
    128             return false;
    129         if (closeChangesetAfterUpload != other.closeChangesetAfterUpload)
    130             return false;
    131         if (policy == null) {
    132             if (other.policy != null)
    133                 return false;
    134         } else if (!policy.equals(other.policy))
    135             return false;
    136         if (strategy == null) {
    137             if (other.strategy != null)
    138                 return false;
    139         } else if (!strategy.equals(other.strategy))
    140             return false;
    141         return true;
     116        if (this == obj) return true;
     117        if (obj == null || getClass() != obj.getClass()) return false;
     118        UploadStrategySpecification that = (UploadStrategySpecification) obj;
     119        return chunkSize == that.chunkSize &&
     120                closeChangesetAfterUpload == that.closeChangesetAfterUpload &&
     121                strategy == that.strategy &&
     122                policy == that.policy;
    142123    }
    143124}
  • trunk/src/org/openstreetmap/josm/gui/mappaint/DividedScale.java

    r9341 r9371  
    44import java.util.ArrayList;
    55import java.util.List;
     6import java.util.Objects;
    67
    78import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;
     
    176177    @Override
    177178    public boolean equals(Object obj) {
    178         if (obj == null || getClass() != obj.getClass())
    179             return false;
    180         final DividedScale other = (DividedScale) obj;
    181         return bd.equals(other.bd) && data.equals(other.data);
     179        if (this == obj) return true;
     180        if (obj == null || getClass() != obj.getClass()) return false;
     181        DividedScale<?> that = (DividedScale<?>) obj;
     182        return Objects.equals(bd, that.bd) &&
     183                Objects.equals(data, that.data);
    182184    }
    183185
    184186    @Override
    185187    public int hashCode() {
    186         int hash = 7;
    187         hash = 23 * hash + bd.hashCode();
    188         hash = 23 * hash + data.hashCode();
    189         return hash;
     188        return Objects.hash(bd, data);
    190189    }
    191190
  • trunk/src/org/openstreetmap/josm/gui/mappaint/Keyword.java

    r8404 r9371  
    1919    @Override
    2020    public boolean equals(Object obj) {
    21         if (obj == null || getClass() != obj.getClass())
    22             return false;
    23         return Objects.equals(val, ((Keyword) obj).val);
     21        if (this == obj) return true;
     22        if (obj == null || getClass() != obj.getClass()) return false;
     23        Keyword keyword = (Keyword) obj;
     24        return Objects.equals(val, keyword.val);
    2425    }
    2526
    2627    @Override
    2728    public int hashCode() {
    28         return val.hashCode();
     29        return Objects.hash(val);
    2930    }
    3031
  • trunk/src/org/openstreetmap/josm/gui/mappaint/Range.java

    r9239 r9371  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint;
     3
     4import java.util.Objects;
    35
    46/**
     
    9193        if (this == o) return true;
    9294        if (o == null || getClass() != o.getClass()) return false;
    93 
    9495        Range range = (Range) o;
    95 
    96         if (Double.compare(range.lower, lower) != 0) return false;
    97         if (Double.compare(range.upper, upper) != 0) return false;
    98 
    99         return true;
     96        return Double.compare(range.lower, lower) == 0 &&
     97                Double.compare(range.upper, upper) == 0;
    10098    }
    10199
    102100    @Override
    103101    public int hashCode() {
    104         int result;
    105         long temp;
    106         temp = Double.doubleToLongBits(lower);
    107         result = (int) (temp ^ (temp >>> 32));
    108         temp = Double.doubleToLongBits(upper);
    109         result = 31 * result + (int) (temp ^ (temp >>> 32));
    110         return result;
     102        return Objects.hash(lower, upper);
    111103    }
    112104}
  • trunk/src/org/openstreetmap/josm/gui/mappaint/StyleElementList.java

    r9284 r9371  
    5757    @Override
    5858    public boolean equals(Object obj) {
    59         if (obj == null || getClass() != obj.getClass()) {
    60             return false;
    61         }
    62         final StyleElementList other = (StyleElementList) obj;
    63         return Objects.equals(lst, other.lst);
     59        if (this == obj) return true;
     60        if (obj == null || getClass() != obj.getClass()) return false;
     61        StyleElementList that = (StyleElementList) obj;
     62        return Objects.equals(lst, that.lst);
    6463    }
    6564
    6665    @Override
    6766    public int hashCode() {
    68         return lst.hashCode();
     67        return Objects.hash(lst);
    6968    }
    70 
    7169}
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSRule.java

    r8846 r9371  
    33
    44import java.util.List;
     5import java.util.Objects;
    56
    67import org.openstreetmap.josm.gui.mappaint.Environment;
     
    4243        @Override
    4344        public int hashCode() {
    44             final int prime = 31;
    45             int result = 1;
    46             result = prime * result + idx;
    47             result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
    48             return result;
     45            return Objects.hash(instructions, idx);
    4946        }
    5047
    5148        @Override
    5249        public boolean equals(Object obj) {
    53             if (this == obj)
    54                 return true;
    55             if (obj == null)
    56                 return false;
    57             if (!(obj instanceof Declaration))
    58                 return false;
    59             Declaration other = (Declaration) obj;
    60             if (idx != other.idx)
    61                 return false;
    62             if (instructions == null) {
    63                 if (other.instructions != null)
    64                     return false;
    65             } else if (!instructions.equals(other.instructions))
    66                 return false;
    67             return true;
     50            if (this == obj) return true;
     51            if (obj == null || getClass() != obj.getClass()) return false;
     52            Declaration that = (Declaration) obj;
     53            return idx == that.idx &&
     54                    Objects.equals(instructions, that.instructions);
    6855        }
    6956
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/AreaElement.java

    r9341 r9371  
    117117    @Override
    118118    public boolean equals(Object obj) {
    119         if (obj == null || getClass() != obj.getClass())
    120             return false;
    121         if (!super.equals(obj))
    122             return false;
    123         AreaElement other = (AreaElement) obj;
    124         // we should get the same image object due to caching
    125         if (!Objects.equals(fillImage, other.fillImage))
    126             return false;
    127         if (!Objects.equals(color, other.color))
    128             return false;
    129         if (!Objects.equals(extent, other.extent))
    130             return false;
    131         if (!Objects.equals(extentThreshold, other.extentThreshold))
    132             return false;
    133         if (!Objects.equals(text, other.text))
    134             return false;
    135         return true;
     119        if (this == obj) return true;
     120        if (obj == null || getClass() != obj.getClass()) return false;
     121        if (!super.equals(obj)) return false;
     122        AreaElement that = (AreaElement) obj;
     123        return Objects.equals(color, that.color) &&
     124                Objects.equals(fillImage, that.fillImage) &&
     125                Objects.equals(text, that.text) &&
     126                Objects.equals(extent, that.extent) &&
     127                Objects.equals(extentThreshold, that.extentThreshold);
    136128    }
    137129
    138130    @Override
    139131    public int hashCode() {
    140         int hash = super.hashCode();
    141         hash = 61 * hash + color.hashCode();
    142         hash = 61 * hash + (extent != null ? Float.floatToIntBits(extent) : 0);
    143         hash = 61 * hash + (extentThreshold != null ? Float.floatToIntBits(extentThreshold) : 0);
    144         hash = 61 * hash + (fillImage != null ? fillImage.hashCode() : 0);
    145         hash = 61 * hash + (text != null ? text.hashCode() : 0);
    146         return hash;
     132        return Objects.hash(super.hashCode(), color, fillImage, text, extent, extentThreshold);
    147133    }
    148134
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/BoxTextElement.java

    r9278 r9371  
    44import java.awt.Color;
    55import java.awt.Rectangle;
     6import java.util.Objects;
    67
    78import org.openstreetmap.josm.data.osm.Node;
     
    7374        @Override
    7475        public int hashCode() {
    75             return box.hashCode();
     76            return Objects.hash(box);
    7677        }
    7778
    7879        @Override
    7980        public boolean equals(Object obj) {
    80             if (!(obj instanceof BoxProvider))
    81                 return false;
    82             final BoxProvider other = (BoxProvider) obj;
    83             BoxProviderResult resultOther = other.get();
    84             if (resultOther.isTemporary()) return false;
    85             return box.equals(resultOther.getBox());
     81            if (this == obj) return true;
     82            if (obj == null || getClass() != obj.getClass()) return false;
     83            SimpleBoxProvider that = (SimpleBoxProvider) obj;
     84            return Objects.equals(box, that.box);
    8685        }
    8786    }
     
    207206    @Override
    208207    public boolean equals(Object obj) {
    209         if (!super.equals(obj))
    210             return false;
    211         if (obj == null || getClass() != obj.getClass())
    212             return false;
    213         final BoxTextElement other = (BoxTextElement) obj;
    214         if (!text.equals(other.text)) return false;
    215         if (boxProvider != null) {
    216             if (!boxProvider.equals(other.boxProvider)) return false;
    217         } else if (other.boxProvider != null)
    218             return false;
    219         else {
    220             if (!box.equals(other.box)) return false;
    221         }
    222         if (hAlign != other.hAlign) return false;
    223         if (vAlign != other.vAlign) return false;
    224         return true;
     208        if (this == obj) return true;
     209        if (obj == null || getClass() != obj.getClass()) return false;
     210        if (!super.equals(obj)) return false;
     211        BoxTextElement that = (BoxTextElement) obj;
     212        return Objects.equals(text, that.text) &&
     213                Objects.equals(boxProvider, that.boxProvider) &&
     214                Objects.equals(box, that.box) &&
     215                hAlign == that.hAlign &&
     216                vAlign == that.vAlign;
    225217    }
    226218
    227219    @Override
    228220    public int hashCode() {
    229         int hash = super.hashCode();
    230         hash = 97 * hash + text.hashCode();
    231         if (boxProvider != null) {
    232             hash = 97 * hash + boxProvider.hashCode();
    233         } else {
    234             hash = 97 * hash + box.hashCode();
    235         }
    236         hash = 97 * hash + hAlign.hashCode();
    237         hash = 97 * hash + vAlign.hashCode();
    238         return hash;
     221        return Objects.hash(super.hashCode(), text, boxProvider, box, hAlign, vAlign);
    239222    }
    240223
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LabelCompositionStrategy.java

    r9278 r9371  
    66import java.util.Collections;
    77import java.util.List;
     8import java.util.Objects;
    89
    910import org.openstreetmap.josm.Main;
     
    7071        @Override
    7172        public int hashCode() {
    72             final int prime = 31;
    73             int result = 1;
    74             result = prime * result + ((defaultLabel == null) ? 0 : defaultLabel.hashCode());
    75             return result;
     73            return Objects.hash(defaultLabel);
    7674        }
    7775
    7876        @Override
    7977        public boolean equals(Object obj) {
    80             if (this == obj)
    81                 return true;
    82             if (obj == null)
    83                 return false;
    84             if (getClass() != obj.getClass())
    85                 return false;
    86             StaticLabelCompositionStrategy other = (StaticLabelCompositionStrategy) obj;
    87             if (defaultLabel == null) {
    88                 if (other.defaultLabel != null)
    89                     return false;
    90             } else if (!defaultLabel.equals(other.defaultLabel))
    91                 return false;
    92             return true;
     78            if (this == obj) return true;
     79            if (obj == null || getClass() != obj.getClass()) return false;
     80            StaticLabelCompositionStrategy that = (StaticLabelCompositionStrategy) obj;
     81            return Objects.equals(defaultLabel, that.defaultLabel);
    9382        }
    9483    }
     
    126115        @Override
    127116        public int hashCode() {
    128             final int prime = 31;
    129             int result = 1;
    130             result = prime * result + ((defaultLabelTag == null) ? 0 : defaultLabelTag.hashCode());
    131             return result;
     117            return Objects.hash(defaultLabelTag);
    132118        }
    133119
    134120        @Override
    135121        public boolean equals(Object obj) {
    136             if (this == obj)
    137                 return true;
    138             if (obj == null)
    139                 return false;
    140             if (getClass() != obj.getClass())
    141                 return false;
    142             TagLookupCompositionStrategy other = (TagLookupCompositionStrategy) obj;
    143             if (defaultLabelTag == null) {
    144                 if (other.defaultLabelTag != null)
    145                     return false;
    146             } else if (!defaultLabelTag.equals(other.defaultLabelTag))
    147                 return false;
    148             return true;
     122            if (this == obj) return true;
     123            if (obj == null || getClass() != obj.getClass()) return false;
     124            TagLookupCompositionStrategy that = (TagLookupCompositionStrategy) obj;
     125            return Objects.equals(defaultLabelTag, that.defaultLabelTag);
    149126        }
    150127    }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java

    r9341 r9371  
    359359    @Override
    360360    public int hashCode() {
    361         int hash = super.hashCode();
    362         hash = 29 * hash + line.hashCode();
    363         hash = 29 * hash + color.hashCode();
    364         hash = 29 * hash + (dashesLine != null ? dashesLine.hashCode() : 0);
    365         hash = 29 * hash + (dashesBackground != null ? dashesBackground.hashCode() : 0);
    366         hash = 29 * hash + Float.floatToIntBits(offset);
    367         hash = 29 * hash + Float.floatToIntBits(realWidth);
    368         hash = 29 * hash + (this.wayDirectionArrows ? 1 : 0);
    369         return hash;
     361        return Objects.hash(super.hashCode(), line, color, dashesBackground, offset, realWidth, wayDirectionArrows, dashesLine);
    370362    }
    371363
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineTextElement.java

    r9341 r9371  
    4444    @Override
    4545    public boolean equals(Object obj) {
    46         if (obj == null || getClass() != obj.getClass())
    47             return false;
    48         if (!super.equals(obj))
    49             return false;
    50         final LineTextElement other = (LineTextElement) obj;
    51         return Objects.equals(text, other.text);
     46        if (this == obj) return true;
     47        if (obj == null || getClass() != obj.getClass()) return false;
     48        if (!super.equals(obj)) return false;
     49        LineTextElement that = (LineTextElement) obj;
     50        return Objects.equals(text, that.text);
    5251    }
    5352
    5453    @Override
    5554    public int hashCode() {
    56         int hash = super.hashCode();
    57         hash = 43 * hash + text.hashCode();
    58         return hash;
     55        return Objects.hash(super.hashCode(), text);
    5956    }
    6057
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/MapImage.java

    r9334 r9371  
    217217    @Override
    218218    public boolean equals(Object obj) {
    219         if (obj == null || getClass() != obj.getClass())
    220             return false;
    221         final MapImage other = (MapImage) obj;
    222         // img changes when image is fully loaded and can't be used for equality check.
    223         return  alpha == other.alpha &&
    224                 Objects.equals(name, other.name) &&
    225                 Objects.equals(source, other.source) &&
    226                 autoRescale == other.autoRescale &&
    227                 width == other.width &&
    228                 height == other.height;
     219        if (this == obj) return true;
     220        if (obj == null || getClass() != obj.getClass()) return false;
     221        MapImage mapImage = (MapImage) obj;
     222        return alpha == mapImage.alpha &&
     223                autoRescale == mapImage.autoRescale &&
     224                width == mapImage.width &&
     225                height == mapImage.height &&
     226                Objects.equals(name, mapImage.name) &&
     227                Objects.equals(source, mapImage.source);
    229228    }
    230229
    231230    @Override
    232231    public int hashCode() {
    233         int hash = 7;
    234         hash = 67 * hash + alpha;
    235         hash = 67 * hash + name.hashCode();
    236         hash = 67 * hash + source.hashCode();
    237         hash = 67 * hash + (autoRescale ? 1 : 0);
    238         hash = 67 * hash + width;
    239         hash = 67 * hash + height;
    240         return hash;
     232        return Objects.hash(alpha, name, source, autoRescale, width, height);
    241233    }
    242234
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java

    r9341 r9371  
    6868        @Override
    6969        public int hashCode() {
    70             int hash = 7;
    71             hash = 67 * hash + symbol.hashCode();
    72             hash = 67 * hash + size;
    73             hash = 67 * hash + (stroke != null ? stroke.hashCode() : 0);
    74             hash = 67 * hash + (strokeColor != null ? strokeColor.hashCode() : 0);
    75             hash = 67 * hash + (fillColor != null ? fillColor.hashCode() : 0);
    76             return hash;
     70            return Objects.hash(symbol, size, stroke, strokeColor, fillColor);
    7771        }
    7872
     
    364358    @Override
    365359    public int hashCode() {
    366         int hash = super.hashCode();
    367         hash = 17 * hash + (mapImage != null ? mapImage.hashCode() : 0);
    368         hash = 17 * hash + (symbol != null ? symbol.hashCode() : 0);
    369         hash = 17 * hash + (mapImageAngle != null ? mapImageAngle.hashCode() : 0);
    370         return hash;
     360        return Objects.hash(super.hashCode(), mapImage, mapImageAngle, symbol);
    371361    }
    372362
    373363    @Override
    374364    public boolean equals(Object obj) {
    375         if (obj == null || getClass() != obj.getClass())
    376             return false;
    377         if (!super.equals(obj))
    378             return false;
    379 
    380         final NodeElement other = (NodeElement) obj;
    381         // we should get the same image object due to caching
    382         if (!Objects.equals(mapImage, other.mapImage))
    383             return false;
    384         if (!Objects.equals(symbol, other.symbol))
    385             return false;
    386         if (!Objects.equals(mapImageAngle, other.mapImageAngle))
    387             return false;
    388         return true;
     365        if (this == obj) return true;
     366        if (obj == null || getClass() != obj.getClass()) return false;
     367        if (!super.equals(obj)) return false;
     368        NodeElement that = (NodeElement) obj;
     369        return Objects.equals(mapImage, that.mapImage) &&
     370                Objects.equals(mapImageAngle, that.mapImageAngle) &&
     371                Objects.equals(symbol, that.symbol);
    389372    }
    390373
    391374    @Override
     375
    392376    public String toString() {
    393377        StringBuilder s = new StringBuilder("NodeElemStyle{");
  • 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
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/StyleElement.java

    r9341 r9371  
    55import java.util.HashMap;
    66import java.util.Map;
     7import java.util.Objects;
    78
    89import org.openstreetmap.josm.Main;
     
    147148        @Override
    148149        public int hashCode() {
    149             final int prime = 31;
    150             int result = 1;
    151             result = prime * result + ((name == null) ? 0 : name.hashCode());
    152             result = prime * result + size;
    153             result = prime * result + style;
    154             return result;
     150            return Objects.hash(name, style, size);
    155151        }
    156152
    157153        @Override
    158154        public boolean equals(Object obj) {
    159             if (this == obj)
    160                 return true;
    161             if (obj == null)
    162                 return false;
    163             if (getClass() != obj.getClass())
    164                 return false;
    165             FontDescriptor other = (FontDescriptor) obj;
    166             if (name == null) {
    167                 if (other.name != null)
    168                     return false;
    169             } else if (!name.equals(other.name))
    170                 return false;
    171             if (size != other.size)
    172                 return false;
    173             if (style != other.style)
    174                 return false;
    175             return true;
     155            if (this == obj) return true;
     156            if (obj == null || getClass() != obj.getClass()) return false;
     157            FontDescriptor that = (FontDescriptor) obj;
     158            return style == that.style &&
     159                    size == that.size &&
     160                    Objects.equals(name, that.name);
    176161        }
    177162    }
     
    214199    @Override
    215200    public boolean equals(Object o) {
    216         if (!(o instanceof StyleElement))
    217             return false;
    218         StyleElement s = (StyleElement) o;
    219         return isModifier == s.isModifier &&
    220                 majorZIndex == s.majorZIndex &&
    221                 zIndex == s.zIndex &&
    222                 objectZIndex == s.objectZIndex;
     201        if (this == o) return true;
     202        if (o == null || getClass() != o.getClass()) return false;
     203        StyleElement that = (StyleElement) o;
     204        return Float.compare(that.majorZIndex, majorZIndex) == 0 &&
     205                Float.compare(that.zIndex, zIndex) == 0 &&
     206                Float.compare(that.objectZIndex, objectZIndex) == 0 &&
     207                isModifier == that.isModifier;
    223208    }
    224209
    225210    @Override
    226211    public int hashCode() {
    227         int hash = 5;
    228         hash = 41 * hash + Float.floatToIntBits(this.majorZIndex);
    229         hash = 41 * hash + Float.floatToIntBits(this.zIndex);
    230         hash = 41 * hash + Float.floatToIntBits(this.objectZIndex);
    231         hash = 41 * hash + (isModifier ? 1 : 0);
    232         return hash;
     212        return Objects.hash(majorZIndex, zIndex, objectZIndex, isModifier);
    233213    }
    234214
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/TextLabel.java

    r9278 r9371  
    201201    @Override
    202202    public int hashCode() {
    203         int hash = 3;
    204         hash = 79 * hash + (labelCompositionStrategy != null ? labelCompositionStrategy.hashCode() : 0);
    205         hash = 79 * hash + font.hashCode();
    206         hash = 79 * hash + xOffset;
    207         hash = 79 * hash + yOffset;
    208         hash = 79 * hash + color.hashCode();
    209         hash = 79 * hash + (haloRadius != null ? Float.floatToIntBits(haloRadius) : 0);
    210         hash = 79 * hash + (haloColor != null ? haloColor.hashCode() : 0);
    211         return hash;
     203        return Objects.hash(labelCompositionStrategy, font, xOffset, yOffset, color, haloRadius, haloColor);
    212204    }
    213205
    214206    @Override
    215207    public boolean equals(Object obj) {
    216         if (obj == null || getClass() != obj.getClass())
    217             return false;
    218         final TextLabel other = (TextLabel) obj;
    219         return Objects.equals(labelCompositionStrategy, other.labelCompositionStrategy) &&
    220         Objects.equals(font, other.font) &&
    221         xOffset == other.xOffset &&
    222         yOffset == other.yOffset &&
    223         Objects.equals(color, other.color) &&
    224         Objects.equals(haloRadius, other.haloRadius) &&
    225         Objects.equals(haloColor, other.haloColor);
     208        if (this == obj) return true;
     209        if (obj == null || getClass() != obj.getClass()) return false;
     210        TextLabel textLabel = (TextLabel) obj;
     211        return xOffset == textLabel.xOffset &&
     212                yOffset == textLabel.yOffset &&
     213                Objects.equals(labelCompositionStrategy, textLabel.labelCompositionStrategy) &&
     214                Objects.equals(font, textLabel.font) &&
     215                Objects.equals(color, textLabel.color) &&
     216                Objects.equals(haloRadius, textLabel.haloRadius) &&
     217                Objects.equals(haloColor, textLabel.haloColor);
    226218    }
    227219}
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEntry.java

    r8377 r9371  
    109109    @Override
    110110    public boolean equals(Object obj) {
    111         if (obj == null || getClass() != obj.getClass())
    112             return false;
    113         final SourceEntry other = (SourceEntry) obj;
    114         return Objects.equals(other.url, url) &&
    115                 other.isZip == isZip &&
    116                 Objects.equals(other.zipEntryPath, zipEntryPath) &&
    117                 Objects.equals(other.name, name) &&
    118                 Objects.equals(other.title, title) &&
    119                 other.active == active;
     111        if (this == obj) return true;
     112        if (obj == null || getClass() != obj.getClass()) return false;
     113        SourceEntry that = (SourceEntry) obj;
     114        return isZip == that.isZip &&
     115                active == that.active &&
     116                Objects.equals(url, that.url) &&
     117                Objects.equals(zipEntryPath, that.zipEntryPath) &&
     118                Objects.equals(name, that.name) &&
     119                Objects.equals(title, that.title);
    120120    }
    121121
    122122    @Override
    123123    public int hashCode() {
    124         int hash = 5;
    125         hash = 89 * hash + (this.url != null ? this.url.hashCode() : 0);
    126         hash = 89 * hash + (this.isZip ? 1 : 0);
    127         hash = 89 * hash + (this.zipEntryPath != null ? this.zipEntryPath.hashCode() : 0);
    128         hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0);
    129         hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0);
    130         hash = 89 * hash + (this.active ? 1 : 0);
    131         return hash;
     124        return Objects.hash(url, isZip, zipEntryPath, name, title, active);
    132125    }
    133126
  • trunk/src/org/openstreetmap/josm/gui/progress/ProgressTaskId.java

    r8846 r9371  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.progress;
     3
     4import java.util.Objects;
    35
    46public class ProgressTaskId {
     
    1618    @Override
    1719    public int hashCode() {
    18         return id.hashCode();
     20        return Objects.hash(id);
    1921    }
    2022
    2123    @Override
    2224    public boolean equals(Object obj) {
    23         if (this == obj)
    24             return true;
    25         if (obj == null)
    26             return false;
    27         if (getClass() != obj.getClass())
    28             return false;
    29         ProgressTaskId other = (ProgressTaskId) obj;
    30         return other.id.equals(id);
     25        if (this == obj) return true;
     26        if (obj == null || getClass() != obj.getClass()) return false;
     27        ProgressTaskId that = (ProgressTaskId) obj;
     28        return Objects.equals(id, that.id);
    3129    }
    3230}
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java

    r9266 r9371  
    8484        @Override
    8585        public int hashCode() {
    86             int hash = 7;
    87             hash = 59 * hash + Objects.hashCode(this.key);
    88             hash = 59 * hash + Objects.hashCode(this.value);
    89             hash = 59 * hash + (this.defaultKey ? 1 : 0);
    90             return hash;
     86            return Objects.hash(key, value, defaultKey);
    9187        }
    9288
  • trunk/src/org/openstreetmap/josm/tools/MultiMap.java

    r9074 r9371  
    99import java.util.Map;
    1010import java.util.Map.Entry;
     11import java.util.Objects;
    1112import java.util.Set;
    1213
     
    214215    @Override
    215216    public int hashCode() {
    216         return map.hashCode();
     217        return Objects.hash(map);
    217218    }
    218219
    219220    @Override
    220221    public boolean equals(Object obj) {
    221         if (this == obj)
    222             return true;
    223         if (obj == null)
    224             return false;
    225         if (!(obj instanceof MultiMap))
    226             return false;
    227         return map.equals(((MultiMap<?, ?>) obj).map);
     222        if (this == obj) return true;
     223        if (obj == null || getClass() != obj.getClass()) return false;
     224        MultiMap<?, ?> multiMap = (MultiMap<?, ?>) obj;
     225        return Objects.equals(map, multiMap.map);
    228226    }
    229227
    230228    @Override
     229
    231230    public String toString() {
    232231        List<String> entries = new ArrayList<>(map.size());
  • trunk/src/org/openstreetmap/josm/tools/Pair.java

    r9246 r9371  
    33import java.util.ArrayList;
    44import java.util.List;
     5import java.util.Objects;
    56
    67/**
     
    3435    @Override
    3536    public int hashCode() {
    36         return a.hashCode() + b.hashCode();
     37        return Objects.hash(a, b);
    3738    }
    3839
    3940    @Override
    4041    public boolean equals(Object other) {
    41         if (other instanceof Pair<?, ?>) {
    42             Pair<?, ?> o = (Pair<?, ?>) other;
    43             return a.equals(o.a) && b.equals(o.b);
    44         } else
    45             return false;
     42        if (this == other) return true;
     43        if (other == null || getClass() != other.getClass()) return false;
     44        Pair<?, ?> pair = (Pair<?, ?>) other;
     45        return Objects.equals(a, pair.a) &&
     46                Objects.equals(b, pair.b);
    4647    }
    4748
Note: See TracChangeset for help on using the changeset viewer.