Ticket #19174: 19174.patch

File 19174.patch, 21.3 KB (added by simon04, 6 years ago)
  • src/org/openstreetmap/josm/data/gpx/GpxRoute.java

    commit b0efa87799acf7e913671846ec74f3fc41fefc4f
    Author: Simon Legner <Simon.Legner@gmail.com>
    Date:   2020-03-15 16:11:25 +0100
    
        xxx
    
    diff --git a/src/org/openstreetmap/josm/data/gpx/GpxRoute.java b/src/org/openstreetmap/josm/data/gpx/GpxRoute.java
    index 543f0590a..b519eab4c 100644
    a b  
    33
    44import java.util.Collection;
    55import java.util.LinkedList;
     6import java.util.Objects;
    67
    78/**
    89 * A route is a part of a GPX file containing of multiple GPX points.
     
    1718
    1819    @Override
    1920    public int hashCode() {
    20         return 31 * super.hashCode() + ((routePoints == null) ? 0 : routePoints.hashCode());
     21        return Objects.hash(super.hashCode(), routePoints);
    2122    }
    2223
    2324    @Override
    public boolean equals(Object obj) {  
    2930        if (getClass() != obj.getClass())
    3031            return false;
    3132        GpxRoute other = (GpxRoute) obj;
    32         if (routePoints == null) {
    33             if (other.routePoints != null)
    34                 return false;
    35         } else if (!routePoints.equals(other.routePoints))
    36             return false;
    37         return true;
     33        return Objects.equals(routePoints, other.routePoints);
    3834    }
    3935}
  • src/org/openstreetmap/josm/data/gpx/GpxTrack.java

    diff --git a/src/org/openstreetmap/josm/data/gpx/GpxTrack.java b/src/org/openstreetmap/josm/data/gpx/GpxTrack.java
    index f78adc63b..d29c82793 100644
    a b  
    99import java.util.List;
    1010import java.util.Map;
    1111import java.util.Map.Entry;
     12import java.util.Objects;
    1213import java.util.Optional;
    1314
    1415import org.openstreetmap.josm.data.Bounds;
    public double length() {  
    211212
    212213    @Override
    213214    public int hashCode() {
    214         return 31 * super.hashCode() + ((segments == null) ? 0 : segments.hashCode());
     215        return Objects.hash(segments);
    215216    }
    216217
    217218    @Override
    public boolean equals(Object obj) {  
    225226        if (getClass() != obj.getClass())
    226227            return false;
    227228        GpxTrack other = (GpxTrack) obj;
    228         if (segments == null) {
    229             if (other.segments != null)
    230                 return false;
    231         } else if (!segments.equals(other.segments))
    232             return false;
    233         return true;
     229        return Objects.equals(segments, other.segments);
    234230    }
    235231
    236232    @Override
  • src/org/openstreetmap/josm/data/gpx/GpxTrackSegment.java

    diff --git a/src/org/openstreetmap/josm/data/gpx/GpxTrackSegment.java b/src/org/openstreetmap/josm/data/gpx/GpxTrackSegment.java
    index 87cb2e90f..9cfd0ec0e 100644
    a b  
    55import java.util.Collection;
    66import java.util.Collections;
    77import java.util.List;
     8import java.util.Objects;
    89
    910import org.openstreetmap.josm.data.Bounds;
    1011
    public int getUpdateCount() {  
    7778
    7879    @Override
    7980    public int hashCode() {
    80         final int prime = 31;
    81         int result = prime + super.hashCode();
    82         result = prime * result + ((wayPoints == null) ? 0 : wayPoints.hashCode());
    83         return result;
     81        return Objects.hash(super.hashCode(), wayPoints);
    8482    }
    8583
    8684    @Override
    public boolean equals(Object obj) {  
    9492        if (getClass() != obj.getClass())
    9593            return false;
    9694        GpxTrackSegment other = (GpxTrackSegment) obj;
    97         if (wayPoints == null) {
    98             if (other.wayPoints != null)
    99                 return false;
    100         } else if (!wayPoints.equals(other.wayPoints))
    101             return false;
    102         return true;
     95        return Objects.equals(wayPoints, other.wayPoints);
    10396    }
    10497}
  • src/org/openstreetmap/josm/data/preferences/AbstractProperty.java

    diff --git a/src/org/openstreetmap/josm/data/preferences/AbstractProperty.java b/src/org/openstreetmap/josm/data/preferences/AbstractProperty.java
    index 07a10e0c9..4453e979a 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.preferences;
    33
     4import java.util.Objects;
     5
    46import org.openstreetmap.josm.spi.preferences.Config;
    57import org.openstreetmap.josm.spi.preferences.IPreferences;
    68import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent;
    public void preferenceChanged(PreferenceChangeEvent e) {  
    2830
    2931        @Override
    3032        public int hashCode() {
    31             final int prime = 31;
    32             int result = 1;
    33             result = prime * result + getOuterType().hashCode();
    34             result = prime * result + ((listener == null) ? 0 : listener.hashCode());
    35             return result;
     33            return Objects.hash(getOuterType(), listener);
    3634        }
    3735
    3836        @Override
    protected void removeListenerImpl(PreferenceChangedListener adapter) {  
    317315
    318316    @Override
    319317    public int hashCode() {
    320         final int prime = 31;
    321         int result = 1;
    322         result = prime * result + ((key == null) ? 0 : key.hashCode());
    323         result = prime * result + ((preferences == null) ? 0 : preferences.hashCode());
    324         return result;
     318        return Objects.hash(key, preferences);
    325319    }
    326320
    327321    @Override
    public boolean equals(Object obj) {  
    331325        if (obj == null || getClass() != obj.getClass())
    332326            return false;
    333327        AbstractProperty<?> other = (AbstractProperty<?>) obj;
    334         if (key == null) {
    335             if (other.key != null)
    336                 return false;
    337         } else if (!key.equals(other.key))
    338             return false;
    339         if (preferences == null) {
    340             if (other.preferences != null)
    341                 return false;
    342         } else if (!preferences.equals(other.preferences))
    343             return false;
    344         return true;
     328        return Objects.equals(key, other.key) && Objects.equals(preferences, other.preferences);
    345329    }
    346330}
  • src/org/openstreetmap/josm/data/tagging/ac/AutoCompletionItem.java

    diff --git a/src/org/openstreetmap/josm/data/tagging/ac/AutoCompletionItem.java b/src/org/openstreetmap/josm/data/tagging/ac/AutoCompletionItem.java
    index 0430a6c88..f0918911c 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.tagging.ac;
    33
     4import java.util.Objects;
     5
    46/**
    57 * Represents an entry in the set of auto completion values.
    68 *
    public String toString() {  
    8587
    8688    @Override
    8789    public int hashCode() {
    88         final int prime = 31;
    89         int result = 1;
    90         result = prime * result
    91                 + ((priority == null) ? 0 : priority.hashCode());
    92         result = prime * result + ((value == null) ? 0 : value.hashCode());
    93         return result;
     90        return Objects.hash(priority, value);
    9491    }
    9592
    9693    @Override
    public boolean equals(Object obj) {  
    104101        if (getClass() != obj.getClass())
    105102            return false;
    106103        final AutoCompletionItem other = (AutoCompletionItem) obj;
    107         if (priority == null) {
    108             if (other.priority != null)
    109                 return false;
    110         } else if (!priority.equals(other.priority))
    111             return false;
    112         if (value == null) {
    113             if (other.value != null)
    114                 return false;
    115         } else if (!value.equals(other.value))
    116             return false;
    117         return true;
     104        return Objects.equals(priority, other.priority) && Objects.equals(value, other.value);
    118105    }
    119106
    120107    @Override
  • src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java

    diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java b/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
    index c7fa2f46b..29a37490b 100644
    a b public void loadThumbnail() {  
    7676
    7777    @Override
    7878    public int hashCode() {
    79         return 31 * super.hashCode() + ((thumbnail == null) ? 0 : thumbnail.hashCode());
     79        return Objects.hash(thumbnail);
    8080    }
    8181
    8282    @Override
  • src/org/openstreetmap/josm/gui/mappaint/styleelement/AreaIconElement.java

    diff --git a/src/org/openstreetmap/josm/gui/mappaint/styleelement/AreaIconElement.java b/src/org/openstreetmap/josm/gui/mappaint/styleelement/AreaIconElement.java
    index fb5fbf1ee..26900b503 100644
    a b public static AreaIconElement create(final Environment env) {  
    7171
    7272    @Override
    7373    public int hashCode() {
    74         final int prime = 31;
    75         int result = super.hashCode();
    76         result = prime * result + ((iconImage == null) ? 0 : iconImage.hashCode());
    77         result = prime * result + ((iconImageAngle == null) ? 0 : iconImageAngle.hashCode());
    78         result = prime * result + ((iconPosition == null) ? 0 : iconPosition.hashCode());
    79         return result;
     74        return Objects.hash(iconImage, iconImageAngle, iconPosition);
    8075    }
    8176
    8277    @Override
  • src/org/openstreetmap/josm/gui/mappaint/styleelement/placement/CompletelyInsideAreaStrategy.java

    diff --git a/src/org/openstreetmap/josm/gui/mappaint/styleelement/placement/CompletelyInsideAreaStrategy.java b/src/org/openstreetmap/josm/gui/mappaint/styleelement/placement/CompletelyInsideAreaStrategy.java
    index f1c8ccbab..dcbd712c0 100644
    a b  
    44import java.awt.Rectangle;
    55import java.awt.geom.Point2D;
    66import java.awt.geom.Rectangle2D;
     7import java.util.Objects;
    78
    89import org.openstreetmap.josm.gui.MapViewState;
    910import org.openstreetmap.josm.gui.draw.MapViewPath;
  • src/org/openstreetmap/josm/gui/preferences/advanced/PrefEntry.java

    diff --git a/src/org/openstreetmap/josm/gui/preferences/advanced/PrefEntry.java b/src/org/openstreetmap/josm/gui/preferences/advanced/PrefEntry.java
    index 2801fb3a8..406ec7d89 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.preferences.advanced;
    33
     4import java.util.Objects;
     5
    46import org.openstreetmap.josm.spi.preferences.Setting;
    57import org.openstreetmap.josm.tools.CheckParameterUtil;
    68
    public int compareTo(PrefEntry other) {  
    105107
    106108    @Override
    107109    public int hashCode() {
    108         return 31 + ((key == null) ? 0 : key.hashCode());
     110        return Objects.hash(key);
    109111    }
    110112
    111113    @Override
    public boolean equals(Object obj) {  
    115117        if (obj == null || getClass() != obj.getClass())
    116118            return false;
    117119        PrefEntry other = (PrefEntry) obj;
    118         if (key == null) {
    119             if (other.key != null)
    120                 return false;
    121         } else if (!key.equals(other.key))
    122             return false;
    123         return true;
     120        return Objects.equals(key, other.key);
    124121    }
    125122
    126123    @Override
  • src/org/openstreetmap/josm/plugins/PluginHandler.java

    diff --git a/src/org/openstreetmap/josm/plugins/PluginHandler.java b/src/org/openstreetmap/josm/plugins/PluginHandler.java
    index 264e6f132..0941b81ea 100644
    a b  
    3232import java.util.Locale;
    3333import java.util.Map;
    3434import java.util.Map.Entry;
     35import java.util.Objects;
    3536import java.util.Set;
    3637import java.util.TreeSet;
    3738import java.util.concurrent.ExecutionException;
    public DeprecatedPlugin(String name, String reason) {  
    222223
    223224        @Override
    224225        public int hashCode() {
    225             final int prime = 31;
    226             int result = prime + ((name == null) ? 0 : name.hashCode());
    227             return prime * result + ((reason == null) ? 0 : reason.hashCode());
     226            return Objects.hash(name, reason);
    228227        }
    229228
    230229        @Override
    public boolean equals(Object obj) {  
    236235            if (getClass() != obj.getClass())
    237236                return false;
    238237            DeprecatedPlugin other = (DeprecatedPlugin) obj;
    239             if (name == null) {
    240                 if (other.name != null)
    241                     return false;
    242             } else if (!name.equals(other.name))
    243                 return false;
    244             if (reason == null) {
    245                 if (other.reason != null)
    246                     return false;
    247             } else if (!reason.equals(other.reason))
    248                 return false;
    249             return true;
     238            return Objects.equals(name, other.name) && Objects.equals(reason, other.reason);
    250239        }
    251240
    252241        @Override
  • src/org/openstreetmap/josm/tools/ListenerList.java

    diff --git a/src/org/openstreetmap/josm/tools/ListenerList.java b/src/org/openstreetmap/josm/tools/ListenerList.java
    index 6dce4ae1c..7df4bf551 100644
    a b public boolean equals(Object obj) {  
    4949
    5050        @Override
    5151        public int hashCode() {
    52             T l = listener.get();
    53             if (l == null) {
    54                 return 0;
    55             } else {
    56                 return l.hashCode();
    57             }
     52            return Objects.hash(listener.get());
    5853        }
    5954
    6055        @Override
  • src/org/openstreetmap/josm/tools/template_engine/CompoundTemplateEntry.java

    diff --git a/src/org/openstreetmap/josm/tools/template_engine/CompoundTemplateEntry.java b/src/org/openstreetmap/josm/tools/template_engine/CompoundTemplateEntry.java
    index 1f859ea2e..5afb49b31 100644
    a b  
    22package org.openstreetmap.josm.tools.template_engine;
    33
    44import java.util.Arrays;
     5import java.util.Objects;
    56
    67/**
    78 * {@link TemplateEntry} that concatenates several templates.
  • src/org/openstreetmap/josm/tools/template_engine/Condition.java

    diff --git a/src/org/openstreetmap/josm/tools/template_engine/Condition.java b/src/org/openstreetmap/josm/tools/template_engine/Condition.java
    index 8c0c8c05b..0bbab605b 100644
    a b  
    44import java.util.ArrayList;
    55import java.util.Collection;
    66import java.util.List;
     7import java.util.Objects;
    78
    89/**
    910 * {@link TemplateEntry} that applies other templates based on conditions.
    public String toString() {  
    7374
    7475    @Override
    7576    public int hashCode() {
    76         return 31 + ((entries == null) ? 0 : entries.hashCode());
     77        return 31 + entries.hashCode();
    7778    }
    7879
    7980    @Override
    public boolean equals(Object obj) {  
    8384        if (obj == null || getClass() != obj.getClass())
    8485            return false;
    8586        Condition other = (Condition) obj;
    86         if (entries == null) {
    87             if (other.entries != null)
    88                 return false;
    89         } else if (!entries.equals(other.entries))
    90             return false;
    91         return true;
     87        return Objects.equals(entries, other.entries);
    9288    }
    9389}
  • src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java

    diff --git a/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java b/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java
    index 2ffe6d895..653958db3 100644
    a b  
    77import java.util.Collection;
    88import java.util.Collections;
    99import java.util.List;
     10import java.util.Objects;
    1011
    1112import org.openstreetmap.josm.data.osm.Node;
    1213import org.openstreetmap.josm.data.osm.OsmPrimitive;
    public boolean evaluateCondition(Match condition) {  
    5152
    5253        @Override
    5354        public int hashCode() {
    54             return 31 + ((condition == null) ? 0 : condition.hashCode());
     55            return Objects.hash(condition);
    5556        }
    5657
    5758        @Override
    public boolean equals(Object obj) {  
    6162            if (obj == null || getClass() != obj.getClass())
    6263                return false;
    6364            ContextProvider other = (ContextProvider) obj;
    64             if (condition == null) {
    65                 if (other.condition != null)
    66                     return false;
    67             } else if (!condition.equals(other.condition))
    68                 return false;
    69             return true;
     65            return Objects.equals(condition, other.condition);
    7066        }
    7167    }
    7268
    public boolean match(OsmPrimitive osm) {  
    106102
    107103        @Override
    108104        public int hashCode() {
    109             return 31 * super.hashCode() + ((childCondition == null) ? 0 : childCondition.hashCode());
     105            return Objects.hash(super.hashCode(), childCondition);
    110106        }
    111107
    112108        @Override
    public boolean equals(Object obj) {  
    116112            if (!super.equals(obj) || getClass() != obj.getClass())
    117113                return false;
    118114            ParentSet other = (ParentSet) obj;
    119             if (childCondition == null) {
    120                 if (other.childCondition != null)
    121                     return false;
    122             } else if (!childCondition.equals(other.childCondition))
    123                 return false;
    124             return true;
     115            return Objects.equals(childCondition, other.childCondition);
    125116        }
    126117    }
    127118
    public boolean match(OsmPrimitive osm) {  
    169160
    170161        @Override
    171162        public int hashCode() {
    172             return 31 * super.hashCode() + ((parentCondition == null) ? 0 : parentCondition.hashCode());
     163            return Objects.hash(super.hashCode(), parentCondition);
    173164        }
    174165
    175166        @Override
    public boolean equals(Object obj) {  
    179170            if (!super.equals(obj) || getClass() != obj.getClass())
    180171                return false;
    181172            ChildSet other = (ChildSet) obj;
    182             if (parentCondition == null) {
    183                 if (other.parentCondition != null)
    184                     return false;
    185             } else if (!parentCondition.equals(other.parentCondition))
    186                 return false;
    187             return true;
     173            return Objects.equals(parentCondition, other.parentCondition);
    188174        }
    189175    }
    190176
    public boolean match(OsmPrimitive osm) {  
    220206
    221207        @Override
    222208        public int hashCode() {
    223             final int prime = 31;
    224             int result = super.hashCode();
    225             result = prime * result + ((lhs == null) ? 0 : lhs.hashCode());
    226             result = prime * result + ((rhs == null) ? 0 : rhs.hashCode());
    227             return result;
     209            return Objects.hash(super.hashCode(), lhs, rhs);
    228210        }
    229211
    230212        @Override
    public boolean equals(Object obj) {  
    234216            if (!super.equals(obj) || getClass() != obj.getClass())
    235217                return false;
    236218            OrSet other = (OrSet) obj;
    237             if (lhs == null) {
    238                 if (other.lhs != null)
    239                     return false;
    240             } else if (!lhs.equals(other.lhs))
    241                 return false;
    242             if (rhs == null) {
    243                 if (other.rhs != null)
    244                     return false;
    245             } else if (!rhs.equals(other.rhs))
    246                 return false;
    247             return true;
     219            return Objects.equals(lhs, other.lhs) && Objects.equals(rhs, other.rhs);
    248220        }
    249221    }
    250222
    public boolean match(OsmPrimitive osm) {  
    276248
    277249        @Override
    278250        public int hashCode() {
    279             final int prime = 31;
    280             int result = super.hashCode();
    281             result = prime * result + ((lhs == null) ? 0 : lhs.hashCode());
    282             result = prime * result + ((rhs == null) ? 0 : rhs.hashCode());
    283             return result;
     251            return Objects.hash(super.hashCode(), lhs, rhs);
    284252        }
    285253
    286254        @Override
    public boolean equals(Object obj) {  
    290258            if (!super.equals(obj) || getClass() != obj.getClass())
    291259                return false;
    292260            AndSet other = (AndSet) obj;
    293             if (lhs == null) {
    294                 if (other.lhs != null)
    295                     return false;
    296             } else if (!lhs.equals(other.lhs))
    297                 return false;
    298             if (rhs == null) {
    299                 if (other.rhs != null)
    300                     return false;
    301             } else if (!rhs.equals(other.rhs))
    302                 return false;
    303             return true;
     261            return Objects.equals(lhs, other.lhs) && Objects.equals(rhs, other.rhs);
    304262        }
    305263    }
    306264
    public boolean isValid(TemplateEngineDataProvider dataProvider) {  
    409367
    410368    @Override
    411369    public int hashCode() {
    412         final int prime = 31;
    413         int result = 1;
    414         result = prime * result + ((context == null) ? 0 : context.hashCode());
    415         result = prime * result + ((template == null) ? 0 : template.hashCode());
    416         return result;
     370        return Objects.hash(context, template);
    417371    }
    418372
    419373    @Override
    public boolean equals(Object obj) {  
    423377        if (obj == null || getClass() != obj.getClass())
    424378            return false;
    425379        ContextSwitchTemplate other = (ContextSwitchTemplate) obj;
    426         if (context == null) {
    427             if (other.context != null)
    428                 return false;
    429         } else if (!context.equals(other.context))
    430             return false;
    431         if (template == null) {
    432             if (other.template != null)
    433                 return false;
    434         } else if (!template.equals(other.template))
    435             return false;
    436         return true;
     380        return Objects.equals(context, other.context) && Objects.equals(template, other.template);
    437381    }
    438382}