Changeset 16488 in josm


Ignore:
Timestamp:
2020-05-23T21:44:48+02:00 (5 years ago)
Author:
simon04
Message:

fix #19281, see #19174 - Use Objects.hash where it is not used (patch by hiddewie, modified)

Location:
trunk/src/org/openstreetmap/josm
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r16436 r16488  
    10001000    @Override
    10011001    public synchronized int hashCode() {
    1002         final int prime = 31;
    1003         int result = prime + super.hashCode();
    1004         result = prime * result + ((namespaces == null) ? 0 : namespaces.hashCode());
    1005         result = prime * result + ((layerPrefs == null) ? 0 : layerPrefs.hashCode());
    1006         result = prime * result + ((dataSources == null) ? 0 : dataSources.hashCode());
    1007         result = prime * result + ((privateRoutes == null) ? 0 : privateRoutes.hashCode());
    1008         result = prime * result + ((privateTracks == null) ? 0 : privateTracks.hashCode());
    1009         result = prime * result + ((privateWaypoints == null) ? 0 : privateWaypoints.hashCode());
    1010         return result;
     1002        return Objects.hash(
     1003                super.hashCode(),
     1004                namespaces,
     1005                layerPrefs,
     1006                dataSources,
     1007                privateRoutes,
     1008                privateTracks,
     1009                privateWaypoints
     1010        );
    10111011    }
    10121012
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxTrackSegment.java

    r15496 r16488  
    66import java.util.Collections;
    77import java.util.List;
     8import java.util.Objects;
    89
    910import org.openstreetmap.josm.data.Bounds;
     
    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
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r15760 r16488  
    288288    @Override
    289289    public int hashCode() {
    290         final int prime = 31;
    291         int result = super.hashCode();
    292         long temp = Double.doubleToLongBits(lat);
    293         result = prime * result + (int) (temp ^ (temp >>> 32));
    294         temp = Double.doubleToLongBits(lon);
    295         result = prime * result + (int) (temp ^ (temp >>> 32));
    296         temp = getTimeInMillis();
    297         result = prime * result + (int) (temp ^ (temp >>> 32));
    298         return result;
     290        return Objects.hash(super.hashCode(), lat, lon, getTimeInMillis());
    299291    }
    300292
  • trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java

    r16453 r16488  
    422422        @Override
    423423        public int hashCode() {
    424             final int prime = 31;
    425             int result = 1;
    426             result = prime * result + ((lhs == null) ? 0 : lhs.hashCode());
    427             result = prime * result + ((rhs == null) ? 0 : rhs.hashCode());
    428             return result;
     424            return Objects.hash(lhs, lhs);
    429425        }
    430426
     
    530526        @Override
    531527        public int hashCode() {
    532             final int prime = 31;
    533             int result = 1;
    534             result = prime * result + (defaultValue ? 1231 : 1237);
    535             result = prime * result + ((key == null) ? 0 : key.hashCode());
    536             return result;
     528            return Objects.hash(defaultValue, key);
    537529        }
    538530
     
    853845        @Override
    854846        public int hashCode() {
    855             final int prime = 31;
    856             int result = 1;
    857             result = prime * result + compareMode;
    858             result = prime * result + ((key == null) ? 0 : key.hashCode());
    859             result = prime * result + ((referenceNumber == null) ? 0 : referenceNumber.hashCode());
    860             result = prime * result + ((referenceValue == null) ? 0 : referenceValue.hashCode());
    861             return result;
     847            return Objects.hash(compareMode, key, referenceNumber, referenceValue);
    862848        }
    863849
     
    1010996        @Override
    1011997        public int hashCode() {
    1012             final int prime = 31;
    1013             int result = 1;
    1014             result = prime * result + ((key == null) ? 0 : key.hashCode());
    1015             result = prime * result + ((keyPattern == null) ? 0 : keyPattern.hashCode());
    1016             result = prime * result + ((mode == null) ? 0 : mode.hashCode());
    1017             result = prime * result + ((value == null) ? 0 : value.hashCode());
    1018             result = prime * result + ((valuePattern == null) ? 0 : valuePattern.hashCode());
    1019             return result;
     998            return Objects.hash(key, keyPattern, mode, value, valuePattern);
    1020999        }
    10211000
     
    11171096        @Override
    11181097        public int hashCode() {
    1119             final int prime = 31;
    1120             int result = 1;
    1121             result = prime * result + (caseSensitive ? 1231 : 1237);
    1122             result = prime * result + ((search == null) ? 0 : search.hashCode());
    1123             result = prime * result + ((searchRegex == null) ? 0 : searchRegex.hashCode());
    1124             return result;
     1098            return Objects.hash(caseSensitive, search, searchRegex);
    11251099        }
    11261100
     
    13361310        @Override
    13371311        public int hashCode() {
    1338             final int prime = 31;
    1339             int result = 1;
    1340             result = prime * result + (modulo ? 1231 : 1237);
    1341             result = prime * result + nth;
    1342             return result;
     1312            return Objects.hash(modulo, nth);
    13431313        }
    13441314
     
    13921362        @Override
    13931363        public int hashCode() {
    1394             final int prime = 31;
    1395             int result = 1;
    1396             result = prime * result + (int) (max ^ (max >>> 32));
    1397             result = prime * result + (int) (min ^ (min >>> 32));
    1398             return result;
     1364            return Objects.hash(max, min);
    13991365        }
    14001366
  • trunk/src/org/openstreetmap/josm/data/preferences/AbstractProperty.java

    r14155 r16488  
    99import org.openstreetmap.josm.tools.bugreport.BugReport;
    1010
     11import java.util.Objects;
     12
    1113/**
    1214 * Captures the common functionality of preference properties
     
    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
     
    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
  • trunk/src/org/openstreetmap/josm/data/tagging/ac/AutoCompletionItem.java

    r13173 r16488  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.tagging.ac;
     3
     4import java.util.Objects;
    35
    46/**
     
    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
  • trunk/src/org/openstreetmap/josm/gui/download/UserQueryList.java

    r14433 r16488  
    625625        @Override
    626626        public int hashCode() {
    627             final int prime = 31;
    628             int result = 1;
    629             result = prime * result + ((itemKey == null) ? 0 : itemKey.hashCode());
    630             result = prime * result + ((query == null) ? 0 : query.hashCode());
    631             return result;
     627            return Objects.hash(itemKey, query);
    632628        }
    633629
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java

    r14625 r16488  
    7777    @Override
    7878    public int hashCode() {
    79         return 31 * super.hashCode() + ((thumbnail == null) ? 0 : thumbnail.hashCode());
     79        return Objects.hash(super.hashCode(), thumbnail);
    8080    }
    8181
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java

    r16056 r16488  
    55import java.util.Locale;
    66import java.util.Map;
     7import java.util.Objects;
    78import java.util.concurrent.CopyOnWriteArrayList;
    89
     
    323324    @Override
    324325    public int hashCode() {
    325         final int prime = 31;
    326         int result = 1;
    327         result = prime * result + (autoLoad ? 1231 : 1237);
    328         result = prime * result + (autoZoom ? 1231 : 1237);
    329         result = prime * result + (showErrors ? 1231 : 1237);
    330         return result;
     326        return Objects.hash(autoLoad, autoZoom, showErrors);
    331327    }
    332328
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/AreaIconElement.java

    r13662 r16488  
    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(super.hashCode(), iconImage, iconImageAngle, iconPosition);
    8075    }
    8176
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/placement/CompletelyInsideAreaStrategy.java

    r15586 r16488  
    55import java.awt.geom.Point2D;
    66import java.awt.geom.Rectangle2D;
     7import java.util.Objects;
    78
    89import org.openstreetmap.josm.gui.MapViewState;
     
    122123    @Override
    123124    public int hashCode() {
    124         final int prime = 31;
    125         int result = 1;
    126         long temp;
    127         temp = Double.doubleToLongBits(offsetX);
    128         result = prime * result + (int) (temp ^ (temp >>> 32));
    129         temp = Double.doubleToLongBits(offsetY);
    130         result = prime * result + (int) (temp ^ (temp >>> 32));
    131         return result;
     125        return Objects.hash(offsetX, offsetY);
    132126    }
    133127
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/placement/OnLineStrategy.java

    r14273 r16488  
    354354    @Override
    355355    public int hashCode() {
    356         final int prime = 31;
    357         int result = 1;
    358         long temp;
    359         temp = Double.doubleToLongBits(yOffset);
    360         result = prime * result + (int) (temp ^ (temp >>> 32));
    361         return result;
     356        return Double.hashCode(yOffset);
    362357    }
    363358
  • trunk/src/org/openstreetmap/josm/gui/util/WindowGeometry.java

    r14273 r16488  
    1414import java.awt.Rectangle;
    1515import java.awt.Window;
     16import java.util.Objects;
    1617import java.util.regex.Matcher;
    1718import java.util.regex.Pattern;
     
    491492    @Override
    492493    public int hashCode() {
    493         final int prime = 31;
    494         int result = 1;
    495         result = prime * result + ((extent == null) ? 0 : extent.hashCode());
    496         result = prime * result + ((topLeft == null) ? 0 : topLeft.hashCode());
    497         return result;
     494        return Objects.hash(extent, topLeft);
    498495    }
    499496
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r16427 r16488  
    3333import java.util.Map;
    3434import java.util.Map.Entry;
     35import java.util.Objects;
    3536import java.util.Set;
    3637import java.util.TreeSet;
     
    222223        @Override
    223224        public int hashCode() {
    224             final int prime = 31;
    225             int result = prime + ((name == null) ? 0 : name.hashCode());
    226             return prime * result + ((reason == null) ? 0 : reason.hashCode());
     225            return Objects.hash(name, reason);
    227226        }
    228227
  • trunk/src/org/openstreetmap/josm/tools/RotationAngle.java

    r14654 r16488  
    8282        @Override
    8383        public int hashCode() {
    84             final int prime = 31;
    85             int result = 1;
    86             long temp = Double.doubleToLongBits(angle);
    87             result = prime * result + (int) (temp ^ (temp >>> 32));
    88             return result;
     84            return Double.hashCode(angle);
    8985        }
    9086
  • trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java

    r16436 r16488  
    88import java.util.Collections;
    99import java.util.List;
     10import java.util.Objects;
    1011import java.util.stream.Collectors;
    1112import java.util.stream.Stream;
     
    5455        @Override
    5556        public int hashCode() {
    56             return 31 + ((condition == null) ? 0 : condition.hashCode());
     57            return Objects.hash(condition);
    5758        }
    5859
     
    104105        @Override
    105106        public int hashCode() {
    106             return 31 * super.hashCode() + ((childCondition == null) ? 0 : childCondition.hashCode());
     107            return Objects.hash(super.hashCode(), childCondition);
    107108        }
    108109
     
    167168        @Override
    168169        public int hashCode() {
    169             return 31 * super.hashCode() + ((parentCondition == null) ? 0 : parentCondition.hashCode());
     170            return Objects.hash(super.hashCode(), parentCondition);
    170171        }
    171172
     
    210211        @Override
    211212        public int hashCode() {
    212             final int prime = 31;
    213             int result = super.hashCode();
    214             result = prime * result + ((lhs == null) ? 0 : lhs.hashCode());
    215             result = prime * result + ((rhs == null) ? 0 : rhs.hashCode());
    216             return result;
     213            return Objects.hash(super.hashCode(), lhs, rhs);
    217214        }
    218215
     
    263260        @Override
    264261        public int hashCode() {
    265             final int prime = 31;
    266             int result = super.hashCode();
    267             result = prime * result + ((lhs == null) ? 0 : lhs.hashCode());
    268             result = prime * result + ((rhs == null) ? 0 : rhs.hashCode());
    269             return result;
     262            return Objects.hash(lhs, rhs);
    270263        }
    271264
     
    396389    @Override
    397390    public int hashCode() {
    398         final int prime = 31;
    399         int result = 1;
    400         result = prime * result + ((context == null) ? 0 : context.hashCode());
    401         result = prime * result + ((template == null) ? 0 : template.hashCode());
    402         return result;
     391        return Objects.hash(context, template);
    403392    }
    404393
  • trunk/src/org/openstreetmap/josm/tools/template_engine/SearchExpressionCondition.java

    r14093 r16488  
    33
    44import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match;
     5
     6import java.util.Objects;
    57
    68/**
     
    4042    @Override
    4143    public int hashCode() {
    42         final int prime = 31;
    43         int result = 1;
    44         result = prime * result + ((condition == null) ? 0 : condition.hashCode());
    45         result = prime * result + ((text == null) ? 0 : text.hashCode());
    46         return result;
     44        return Objects.hash(condition, text);
    4745    }
    4846
  • trunk/src/org/openstreetmap/josm/tools/template_engine/StaticText.java

    r14093 r16488  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.tools.template_engine;
     3
     4import java.util.Objects;
    35
    46/**
     
    3638    @Override
    3739    public int hashCode() {
    38         return 31 + ((staticText == null) ? 0 : staticText.hashCode());
     40        return Objects.hash(staticText);
    3941    }
    4042
  • trunk/src/org/openstreetmap/josm/tools/template_engine/Variable.java

    r14093 r16488  
    44import java.util.Collection;
    55import java.util.Locale;
     6import java.util.Objects;
    67
    78/**
     
    8384    @Override
    8485    public int hashCode() {
    85         final int prime = 31;
    86         int result = 1;
    87         result = prime * result + (special ? 1231 : 1237);
    88         result = prime * result + ((variableName == null) ? 0 : variableName.hashCode());
    89         return result;
     86        return Objects.hash(special, variableName);
    9087    }
    9188
Note: See TracChangeset for help on using the changeset viewer.