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/gui
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecision.java

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