Changeset 7083 in josm for trunk/src/org


Ignore:
Timestamp:
2014-05-09T06:03:50+02:00 (10 years ago)
Author:
Don-vip
Message:

see #8465 - replace Utils.equal by Objects.equals, new in Java 7

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

Legend:

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

    r7026 r7083  
    2727import java.util.List;
    2828import java.util.Map;
     29import java.util.Objects;
    2930import java.util.StringTokenizer;
    3031import java.util.concurrent.Callable;
     
    181182     * The commands undo/redo handler.
    182183     */
    183     public UndoRedoHandler undoRedo = new UndoRedoHandler();
     184    public final UndoRedoHandler undoRedo = new UndoRedoHandler();
    184185
    185186    /**
     
    580581        toolbar.control.updateUI();
    581582        contentPanePrivate.updateUI();
    582 
    583583    }
    584584
     
    11231123                final String EXIT = tr("Exit JOSM");
    11241124                final String CONTINUE = tr("Continue, try anyway");
    1125                 int ret = JOptionPane.showOptionDialog(null, panel, tr("Error"), JOptionPane.YES_NO_OPTION, 
     1125                int ret = JOptionPane.showOptionDialog(null, panel, tr("Error"), JOptionPane.YES_NO_OPTION,
    11261126                        JOptionPane.ERROR_MESSAGE, null, new String[] {EXIT, CONTINUE}, EXIT);
    11271127                if (ret == 0) {
     
    11781178    private static void fireProjectionChanged(Projection oldValue, Projection newValue, Bounds oldBounds) {
    11791179        if (newValue == null ^ oldValue == null
    1180                 || (newValue != null && oldValue != null && !Utils.equal(newValue.toCode(), oldValue.toCode()))) {
     1180                || (newValue != null && oldValue != null && !Objects.equals(newValue.toCode(), oldValue.toCode()))) {
    11811181
    11821182            synchronized(Main.class) {
  • trunk/src/org/openstreetmap/josm/actions/search/PushbackTokenizer.java

    r6429 r7083  
    44import static org.openstreetmap.josm.tools.I18n.marktr;
    55import static org.openstreetmap.josm.tools.I18n.tr;
    6 import static org.openstreetmap.josm.tools.Utils.equal;
    76
    87import java.io.IOException;
     
    109import java.util.Arrays;
    1110import java.util.List;
     11import java.util.Objects;
    1212
    1313import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
     
    207207    public boolean readIfEqual(Token token) {
    208208        Token nextTok = nextToken();
    209         if (equal(nextTok, token))
     209        if (Objects.equals(nextTok, token))
    210210            return true;
    211211        currentToken = nextTok;
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r7082 r7083  
    2929import java.util.Map;
    3030import java.util.Map.Entry;
     31import java.util.Objects;
    3132import java.util.ResourceBundle;
    3233import java.util.SortedMap;
     
    239240                String aStr = itA.next();
    240241                String bStr = itB.next();
    241                 if (!Utils.equal(aStr,bStr)) return false;
     242                if (!Objects.equals(aStr,bStr)) return false;
    242243            }
    243244            return true;
     
    375376            if (a.size() != b.size()) return false;
    376377            for (Entry<String, String> e : a.entrySet()) {
    377                 if (!Utils.equal(e.getValue(), b.get(e.getKey()))) return false;
     378                if (!Objects.equals(e.getValue(), b.get(e.getKey()))) return false;
    378379            }
    379380            return true;
     
    12101211                Object defaultFieldValue = f.get(structPrototype);
    12111212                if (fieldValue != null) {
    1212                     if (f.getAnnotation(writeExplicitly.class) != null || !Utils.equal(fieldValue, defaultFieldValue)) {
     1213                    if (f.getAnnotation(writeExplicitly.class) != null || !Objects.equals(fieldValue, defaultFieldValue)) {
    12131214                        hash.put(f.getName().replace("_", "-"), fieldValue.toString());
    12141215                    }
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java

    r7037 r7083  
    88import java.util.Collections;
    99import java.util.List;
     10import java.util.Objects;
    1011
    1112import org.openstreetmap.josm.Main;
     
    1314import org.openstreetmap.josm.io.MirroredInputStream;
    1415import org.openstreetmap.josm.io.imagery.ImageryReader;
    15 import org.openstreetmap.josm.tools.Utils;
    1616import org.xml.sax.SAXException;
    1717
     
    122122    // some additional checks to respect extended URLs in preferences (legacy workaround)
    123123    private boolean isSimilar(String a, String b) {
    124         return Utils.equal(a, b) || (a != null && b != null && !a.isEmpty() && !b.isEmpty() && (a.contains(b) || b.contains(a)));
     124        return Objects.equals(a, b) || (a != null && b != null && !a.isEmpty() && !b.isEmpty() && (a.contains(b) || b.contains(a)));
    125125    }
    126126
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r7005 r7083  
    1414import java.util.Map;
    1515import java.util.Map.Entry;
     16import java.util.Objects;
    1617import java.util.Set;
    1718import java.util.concurrent.atomic.AtomicLong;
    18 
    19 import org.openstreetmap.josm.tools.Utils;
    2019
    2120/**
     
    730729     */
    731730    public boolean hasTag(String key, String value) {
    732         return Utils.equal(value, get(key));
     731        return Objects.equals(value, get(key));
    733732    }
    734733
  • trunk/src/org/openstreetmap/josm/data/osm/Filter.java

    r6289 r7083  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm;
    3 
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    53
    64import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;
     
    2624        super("", SearchMode.add, false, false, false);
    2725    }
    28    
     26
    2927    public Filter(String text, SearchMode mode, boolean caseSensitive,
    3028            boolean regexSearch, boolean allElements) {
     
    3432    public Filter(FilterPreferenceEntry e) {
    3533        super(e.text, SearchMode.add, false, false, false);
    36         if (equal(e.mode, "replace")) {
     34        if ("replace".equals(e.mode)) {
    3735            mode = SearchMode.replace;
    38         } else if (equal(e.mode, "add")) {
     36        } else if ("add".equals(e.mode)) {
    3937            mode = SearchMode.add;
    40         } else if (equal(e.mode, "remove")) {
     38        } else if ("remove".equals(e.mode)) {
    4139            mode = SearchMode.remove;
    42         } else  if (equal(e.mode, "in_selection")) {
     40        } else  if ("in_selection".equals(e.mode)) {
    4341            mode = SearchMode.in_selection;
    4442        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

    r7005 r7083  
    1111import java.util.List;
    1212import java.util.Map;
     13import java.util.Objects;
    1314import java.util.Set;
    1415
     
    2526import org.openstreetmap.josm.data.validation.util.ValUtil;
    2627import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    27 import org.openstreetmap.josm.tools.Utils;
    2828
    2929/**
     
    7171        @Override
    7272        boolean ignoreWaySegmentCombination(Way w1, Way w2) {
    73             if (!Utils.equal(getLayer(w1), getLayer(w2))) {
    74                 return true;
    75             }
    76             if (w1.hasKey(HIGHWAY) && w2.hasKey(HIGHWAY) && !Utils.equal(w1.get("level"), w2.get("level"))) {
     73            if (!Objects.equals(getLayer(w1), getLayer(w2))) {
     74                return true;
     75            }
     76            if (w1.hasKey(HIGHWAY) && w2.hasKey(HIGHWAY) && !Objects.equals(w1.get("level"), w2.get("level"))) {
    7777                return true;
    7878            }
     
    129129        @Override
    130130        boolean ignoreWaySegmentCombination(Way w1, Way w2) {
    131             return !Utils.equal(w1.get("boundary"), w2.get("boundary"));
     131            return !Objects.equals(w1.get("boundary"), w2.get("boundary"));
    132132        }
    133133
  • trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java

    r6889 r7083  
    1818import java.awt.event.WindowAdapter;
    1919import java.awt.event.WindowEvent;
     20import java.util.Objects;
    2021
    2122import javax.swing.AbstractAction;
     
    3839import org.openstreetmap.josm.io.OsmApi;
    3940import org.openstreetmap.josm.tools.ImageProvider;
    40 import org.openstreetmap.josm.tools.Utils;
    4141import org.openstreetmap.josm.tools.WindowGeometry;
    4242
     
    4545    public static CredentialDialog getOsmApiCredentialDialog(String username, String password, String host, String saveUsernameAndPasswordCheckboxText) {
    4646        CredentialDialog dialog = new CredentialDialog(saveUsernameAndPasswordCheckboxText);
    47         if (Utils.equal(OsmApi.getOsmApi().getHost(), host)) {
     47        if (Objects.equals(OsmApi.getOsmApi().getHost(), host)) {
    4848            dialog.prepareForOsmApiCredentials(username, password);
    4949        } else {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java

    r6883 r7083  
    22package org.openstreetmap.josm.gui.mappaint;
    33
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    5 
    64import java.awt.Color;
     5import java.util.Objects;
    76
    87import org.openstreetmap.josm.Main;
     
    1110import org.openstreetmap.josm.data.osm.Way;
    1211import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
     12import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    1313import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
    14 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    1514import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference;
    1615import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    6766        TextElement text = null;
    6867        Keyword textPos = c.get(TEXT_POSITION, null, Keyword.class);
    69         if (textPos == null || Utils.equal(textPos.val, "center")) {
     68        if (textPos == null || "center".equals(textPos.val)) {
    7069            text = TextElement.create(c, PaintColors.AREA_TEXT.get(), true);
    7170        }
     
    102101        AreaElemStyle other = (AreaElemStyle) obj;
    103102        // we should get the same image object due to caching
    104         if (!equal(fillImage, other.fillImage))
     103        if (!Objects.equals(fillImage, other.fillImage))
    105104            return false;
    106         if (!equal(color, other.color))
     105        if (!Objects.equals(color, other.color))
    107106            return false;
    108         if (!equal(text, other.text))
     107        if (!Objects.equals(text, other.text))
    109108            return false;
    110109        return true;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/BoxTextElemStyle.java

    r6889 r7083  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint;
    3 
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    53
    64import java.awt.Color;
     
    108import org.openstreetmap.josm.data.osm.OsmPrimitive;
    119import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
     10import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    1211import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
    13 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    1412import org.openstreetmap.josm.tools.CheckParameterUtil;
    1513
     
    115113        TextElement text = TextElement.create(c, DEFAULT_TEXT_COLOR, false);
    116114        if (text == null) return null;
    117         // Skip any primtives that don't have text to draw. (Styles are recreated for any tag change.)
     115        // Skip any primitives that don't have text to draw. (Styles are recreated for any tag change.)
    118116        // The concrete text to render is not cached in this object, but computed for each
    119117        // repaint. This way, one BoxTextElemStyle object can be used by multiple primitives (to save memory).
     
    122120        HorizontalTextAlignment hAlign = HorizontalTextAlignment.RIGHT;
    123121        Keyword hAlignKW = c.get("text-anchor-horizontal", Keyword.RIGHT, Keyword.class);
    124         if (equal(hAlignKW.val, "left")) {
     122        if ("left".equals(hAlignKW.val)) {
    125123            hAlign = HorizontalTextAlignment.LEFT;
    126         } else if (equal(hAlignKW.val, "center")) {
     124        } else if ("center".equals(hAlignKW.val)) {
    127125            hAlign = HorizontalTextAlignment.CENTER;
    128         } else if (equal(hAlignKW.val, "right")) {
     126        } else if ("right".equals(hAlignKW.val)) {
    129127            hAlign = HorizontalTextAlignment.RIGHT;
    130128        }
    131129        VerticalTextAlignment vAlign = VerticalTextAlignment.BOTTOM;
    132130        String vAlignStr = c.get("text-anchor-vertical", Keyword.BOTTOM, Keyword.class).val;
    133         if (equal(vAlignStr, "above")) {
     131        if ("above".equals(vAlignStr)) {
    134132            vAlign = VerticalTextAlignment.ABOVE;
    135         } else if (equal(vAlignStr, "top")) {
     133        } else if ("top".equals(vAlignStr)) {
    136134            vAlign = VerticalTextAlignment.TOP;
    137         } else if (equal(vAlignStr, "center")) {
     135        } else if ("center".equals(vAlignStr)) {
    138136            vAlign = VerticalTextAlignment.CENTER;
    139         } else if (equal(vAlignStr, "bottom")) {
     137        } else if ("bottom".equals(vAlignStr)) {
    140138            vAlign = VerticalTextAlignment.BOTTOM;
    141         } else if (equal(vAlignStr, "below")) {
     139        } else if ("below".equals(vAlignStr)) {
    142140            vAlign = VerticalTextAlignment.BELOW;
    143141        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java

    r7029 r7083  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint;
    3 
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    53
    64import java.awt.Color;
     
    133131        if (o instanceof Keyword) {
    134132            String s = ((Keyword) o).val;
    135             if (equal(s, "true") || equal(s, "yes"))
     133            if ("true".equals(s) || "yes".equals(s))
    136134                return true;
    137             if (equal(s, "false") || equal(s, "no"))
     135            if ("false".equals(s) || "no".equals(s))
    138136                return false;
    139137        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java

    r7059 r7083  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint;
    3 
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    53
    64import java.awt.Font;
     
    6765        } else {
    6866            Keyword widthKW = c.get(key, null, Keyword.class, true);
    69             if (equal(widthKW, Keyword.THINNEST))
     67            if (Keyword.THINNEST.equals(widthKW))
    7068                return 0f;
    71             if (equal(widthKW, Keyword.DEFAULT))
     69            if (Keyword.DEFAULT.equals(widthKW))
    7270                return (float) MapPaintSettings.INSTANCE.getDefaultSegmentWidth();
    7371            if (relativeTo != null) {
     
    9391    private static volatile Float DEFAULT_FONT_SIZE = null;
    9492    private static final Object lock = new Object();
    95    
     93
    9694    // thread save access (double-checked locking)
    9795    private static Float getDefaultFontSize() {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/Keyword.java

    r6889 r7083  
    22package org.openstreetmap.josm.gui.mappaint;
    33
    4 import org.openstreetmap.josm.tools.Utils;
     4import java.util.Objects;
    55
    66public class Keyword {
     
    2020        if (obj == null || getClass() != obj.getClass())
    2121            return false;
    22         return Utils.equal(val, ((Keyword) obj).val);
     22        return Objects.equals(val, ((Keyword) obj).val);
    2323    }
    2424
  • trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java

    r7045 r7083  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint;
    3 
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    53
    64import java.awt.BasicStroke;
    75import java.awt.Color;
    86import java.util.Arrays;
     7import java.util.Objects;
    98
    109import org.openstreetmap.josm.Main;
     
    215214        Keyword capKW = c.get(type.prefix + "linecap", null, Keyword.class);
    216215        if (capKW != null) {
    217             if (equal(capKW.val, "none")) {
     216            if ("none".equals(capKW.val)) {
    218217                cap = BasicStroke.CAP_BUTT;
    219             } else if (equal(capKW.val, "round")) {
     218            } else if ("round".equals(capKW.val)) {
    220219                cap = BasicStroke.CAP_ROUND;
    221             } else if (equal(capKW.val, "square")) {
     220            } else if ("square".equals(capKW.val)) {
    222221                cap = BasicStroke.CAP_SQUARE;
    223222            }
     
    230229        Keyword joinKW = c.get(type.prefix + "linejoin", null, Keyword.class);
    231230        if (joinKW != null) {
    232             if (equal(joinKW.val, "round")) {
     231            if ("round".equals(joinKW.val)) {
    233232                join = BasicStroke.JOIN_ROUND;
    234             } else if (equal(joinKW.val, "miter")) {
     233            } else if ("miter".equals(joinKW.val)) {
    235234                join = BasicStroke.JOIN_MITER;
    236             } else if (equal(joinKW.val, "bevel")) {
     235            } else if ("bevel".equals(joinKW.val)) {
    237236                join = BasicStroke.JOIN_BEVEL;
    238237            }
     
    329328            return false;
    330329        final LineElemStyle other = (LineElemStyle) obj;
    331         return  equal(line, other.line) &&
    332             equal(color, other.color) &&
    333             equal(dashesLine, other.dashesLine) &&
    334             equal(dashesBackground, other.dashesBackground) &&
     330        return Objects.equals(line, other.line) &&
     331            Objects.equals(color, other.color) &&
     332            Objects.equals(dashesLine, other.dashesLine) &&
     333            Objects.equals(dashesBackground, other.dashesBackground) &&
    335334            offset == other.offset &&
    336335            realWidth == other.realWidth;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/LineTextElemStyle.java

    r5571 r7083  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint;
     3
     4import java.util.Objects;
    35
    46import org.openstreetmap.josm.data.osm.OsmPrimitive;
    57import org.openstreetmap.josm.data.osm.Way;
    68import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
     9import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    710import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
    8 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    9 import org.openstreetmap.josm.tools.Utils;
    1011
    1112public class LineTextElemStyle extends ElemStyle {
     
    2122
    2223        Keyword textPos = c.get(TEXT_POSITION, null, Keyword.class);
    23         if (textPos != null && !Utils.equal(textPos.val, "line"))
     24        if (textPos != null && !"line".equals(textPos.val))
    2425            return null;
    2526
     
    4344            return false;
    4445        final LineTextElemStyle other = (LineTextElemStyle) obj;
    45         return Utils.equal(text, other.text);
     46        return Objects.equals(text, other.text);
    4647    }
    4748
     
    5556        return "LineTextElemStyle{" + super.toString() + "text=" + text + "}";
    5657    }
    57 
    5858}
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapImage.java

    r6711 r7083  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint;
    3 
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    53
    64import java.awt.Image;
    75import java.awt.Rectangle;
    86import java.awt.image.BufferedImage;
     7import java.util.Objects;
    98
    109import javax.swing.ImageIcon;
     
    1918
    2019public class MapImage {
    21    
     20
    2221    private static final int MAX_SIZE = 48;
    23    
     22
    2423    /**
    2524     * ImageIcon can change while the image is loading.
     
    158157        return new MapImageBoxProvider();
    159158    }
    160    
     159
    161160    /**
    162161     * Returns the really displayed node icon for this {@code MapImage}.
     
    174173        }
    175174    }
    176    
     175
    177176    private boolean mustRescale(Image image) {
    178         return ((width  == -1 && image.getWidth(null) > MAX_SIZE) 
     177        return ((width  == -1 && image.getWidth(null) > MAX_SIZE)
    179178             && (height == -1 && image.getHeight(null) > MAX_SIZE));
    180179    }
     
    187186        // img changes when image is fully loaded and can't be used for equality check.
    188187        return  alpha == other.alpha &&
    189                 equal(name, other.name) &&
    190                 equal(source, other.source) &&
     188                Objects.equals(name, other.name) &&
     189                Objects.equals(source, other.source) &&
    191190                width == other.width &&
    192191                height == other.height;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java

    r6280 r7083  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint;
    3 
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    53
    64import java.awt.BasicStroke;
     
    97import java.awt.Rectangle;
    108import java.awt.Stroke;
     9import java.util.Objects;
    1110
    1211import org.openstreetmap.josm.Main;
     
    2827    public final MapImage mapImage;
    2928    public final Symbol symbol;
    30    
     29
    3130    private Image enabledNodeIcon;
    3231    private Image disabledNodeIcon;
     
    6362            return  symbol == other.symbol &&
    6463                    size == other.size &&
    65                     equal(stroke, other.stroke) &&
    66                     equal(strokeColor, other.strokeColor) &&
    67                     equal(fillColor, other.fillColor);
     64                    Objects.equals(stroke, other.stroke) &&
     65                    Objects.equals(strokeColor, other.strokeColor) &&
     66                    Objects.equals(fillColor, other.fillColor);
    6867        }
    6968
     
    170169        if (shapeKW == null)
    171170            return null;
    172         if (equal(shapeKW.val, "square")) {
     171        if ("square".equals(shapeKW.val)) {
    173172            shape = SymbolShape.SQUARE;
    174         } else if (equal(shapeKW.val, "circle")) {
     173        } else if ("circle".equals(shapeKW.val)) {
    175174            shape = SymbolShape.CIRCLE;
    176         } else if (equal(shapeKW.val, "triangle")) {
     175        } else if ("triangle".equals(shapeKW.val)) {
    177176            shape = SymbolShape.TRIANGLE;
    178         } else if (equal(shapeKW.val, "pentagon")) {
     177        } else if ("pentagon".equals(shapeKW.val)) {
    179178            shape = SymbolShape.PENTAGON;
    180         } else if (equal(shapeKW.val, "hexagon")) {
     179        } else if ("hexagon".equals(shapeKW.val)) {
    181180            shape = SymbolShape.HEXAGON;
    182         } else if (equal(shapeKW.val, "heptagon")) {
     181        } else if ("heptagon".equals(shapeKW.val)) {
    183182            shape = SymbolShape.HEPTAGON;
    184         } else if (equal(shapeKW.val, "octagon")) {
     183        } else if ("octagon".equals(shapeKW.val)) {
    185184            shape = SymbolShape.OCTAGON;
    186         } else if (equal(shapeKW.val, "nonagon")) {
     185        } else if ("nonagon".equals(shapeKW.val)) {
    187186            shape = SymbolShape.NONAGON;
    188         } else if (equal(shapeKW.val, "decagon")) {
     187        } else if ("decagon".equals(shapeKW.val)) {
    189188            shape = SymbolShape.DECAGON;
    190189        } else
     
    356355        final NodeElemStyle other = (NodeElemStyle) obj;
    357356        // we should get the same image object due to caching
    358         if (!equal(mapImage, other.mapImage))
     357        if (!Objects.equals(mapImage, other.mapImage))
    359358            return false;
    360         if (!equal(symbol, other.symbol))
     359        if (!Objects.equals(symbol, other.symbol))
    361360            return false;
    362361        return true;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/RepeatImageElemStyle.java

    r5812 r7083  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint;
    3 
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    53
    64import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    4240        LineImageAlignment align = LineImageAlignment.CENTER;
    4341        Keyword alignKW = c.get(REPEAT_IMAGE_ALIGN, Keyword.CENTER, Keyword.class);
    44         if (equal(alignKW.val, "top")) {
     42        if ("top".equals(alignKW.val)) {
    4543            align = LineImageAlignment.TOP;
    46         } else if (equal(alignKW.val, "bottom")) {
     44        } else if ("bottom".equals(alignKW.val)) {
    4745            align = LineImageAlignment.BOTTOM;
    4846        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java

    r7005 r7083  
    77import java.util.Iterator;
    88import java.util.List;
     9import java.util.Objects;
    910
    1011import org.openstreetmap.josm.data.osm.Storage;
    1112import org.openstreetmap.josm.tools.Pair;
    12 import org.openstreetmap.josm.tools.Utils;
    1313
    1414/**
     
    9191                return false;
    9292            final StyleList other = (StyleList) obj;
    93             return Utils.equal(lst, other.lst);
     93            return Objects.equals(lst, other.lst);
    9494        }
    9595
  • trunk/src/org/openstreetmap/josm/gui/mappaint/TextElement.java

    r6889 r7083  
    22package org.openstreetmap.josm.gui.mappaint;
    33
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    5 
    64import java.awt.Color;
    75import java.awt.Font;
     6import java.util.Objects;
    87
    98import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    9089
    9190        /*
    92          * Check whether the label composition strategy is given by
    93          * a keyword
     91         * Check whether the label composition strategy is given by a keyword
    9492         */
    9593        Keyword keyword = c.get(TEXT, null, Keyword.class, true);
    96         if (equal(keyword, Keyword.AUTO))
     94        if (Keyword.AUTO.equals(keyword))
    9795            return AUTO_LABEL_COMPOSITION_STRATEGY;
    9896
     
    212210            return false;
    213211        final TextElement other = (TextElement) obj;
    214         return  equal(labelCompositionStrategy, other.labelCompositionStrategy) &&
    215         equal(font, other.font) &&
     212        return Objects.equals(labelCompositionStrategy, other.labelCompositionStrategy) &&
     213        Objects.equals(font, other.font) &&
    216214        xOffset == other.xOffset &&
    217215        yOffset == other.yOffset &&
    218         equal(color, other.color) &&
    219         equal(haloRadius, other.haloRadius) &&
    220         equal(haloColor, other.haloColor);
     216        Objects.equals(color, other.color) &&
     217        Objects.equals(haloRadius, other.haloRadius) &&
     218        Objects.equals(haloColor, other.haloColor);
    221219    }
    222220}
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java

    r7081 r7083  
    22package org.openstreetmap.josm.gui.mappaint.mapcss;
    33
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    5 
    64import java.text.MessageFormat;
    75import java.util.EnumSet;
     6import java.util.Objects;
    87import java.util.Set;
    98import java.util.regex.Pattern;
     
    8887            switch (this) {
    8988            case EQ:
    90                 return equal(testString, prototypeString);
     89                return Objects.equals(testString, prototypeString);
    9190            case NEQ:
    92                 return !equal(testString, prototypeString);
     91                return !Objects.equals(testString, prototypeString);
    9392            case REGEX:
    9493            case NREGEX:
     
    9897                String[] parts = testString.split(";");
    9998                for (String part : parts) {
    100                     if (equal(prototypeString, part.trim()))
     99                    if (Objects.equals(prototypeString, part.trim()))
    101100                        return true;
    102101                }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r7082 r7083  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint.mapcss;
    3 
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    53
    64import java.awt.Color;
     
    594592     */
    595593    public static Expression createFunctionExpression(String name, List<Expression> args) {
    596         if (equal(name, "cond") && args.size() == 3)
     594        if ("cond".equals(name) && args.size() == 3)
    597595            return new CondOperator(args.get(0), args.get(1), args.get(2));
    598         else if (equal(name, "and"))
     596        else if ("and".equals(name))
    599597            return new AndOperator(args);
    600         else if (equal(name, "or"))
     598        else if ("or".equals(name))
    601599            return new OrOperator(args);
    602         else if (equal(name, "length") && args.size() == 1)
     600        else if ("length".equals(name) && args.size() == 1)
    603601            return new LengthFunction(args.get(0));
    604602
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    r7082 r7083  
    276276                    for (Entry<String, Cascade> entry : mc.getLayers()) {
    277277                        env.layer = entry.getKey();
    278                         if (Utils.equal(env.layer, "*")) {
     278                        if ("*".equals(env.layer)) {
    279279                            continue;
    280280                        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSource.java

    r7082 r7083  
    1414import java.util.List;
    1515import java.util.Map;
     16import java.util.Objects;
    1617
    1718import org.openstreetmap.josm.Main;
     
    369370                WayPrototypesRecord p2 = new WayPrototypesRecord();
    370371                get(multipolyOuterWay, true, p2, (useMinMaxScale ? scale : null), mc);
    371                 if (Utils.equal(p.area, p2.area)) {
     372                if (Objects.equals(p.area, p2.area)) {
    372373                    p.area = null;
    373374                }
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r7082 r7083  
    44import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    55import static org.openstreetmap.josm.tools.I18n.tr;
    6 import static org.openstreetmap.josm.tools.Utils.equal;
    76
    87import java.awt.Component;
     
    3837import java.util.List;
    3938import java.util.Map;
     39import java.util.Objects;
    4040import java.util.Set;
    4141import java.util.concurrent.CopyOnWriteArrayList;
     
    417417            SourceEntry pe = p.next();
    418418            SourceEntry ce = c.next();
    419             if (!equal(pe.url, ce.url) || !equal(pe.name, ce.name) || pe.active != ce.active)
     419            if (!Objects.equals(pe.url, ce.url) || !Objects.equals(pe.name, ce.name) || pe.active != ce.active)
    420420                return true;
    421421        }
     
    916916            editEntryDialog.showDialog();
    917917            if (editEntryDialog.getValue() == 1) {
    918                 if (e.title != null || !equal(editEntryDialog.getTitle(), "")) {
     918                if (e.title != null || !"".equals(editEntryDialog.getTitle())) {
    919919                    e.title = editEntryDialog.getTitle();
    920                     if (equal(e.title, "")) {
     920                    if ("".equals(e.title)) {
    921921                        e.title = null;
    922922                    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEntry.java

    r6920 r7083  
    22package org.openstreetmap.josm.gui.preferences;
    33
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    5 
    64import java.io.File;
     5import java.util.Objects;
    76import java.util.regex.Matcher;
    87import java.util.regex.Pattern;
     
    5756        this.url = url;
    5857        this.isZip = isZip;
    59         this.zipEntryPath = equal(zipEntryPath, "") ? null : zipEntryPath;
    60         this.name = equal(name, "") ? null : name;
    61         this.title = equal(title, "") ? null : title;
     58        this.zipEntryPath = "".equals(zipEntryPath) ? null : zipEntryPath;
     59        this.name = "".equals(name) ? null : name;
     60        this.title = "".equals(title) ? null : title;
    6261        this.active = active;
    6362    }
     
    8180            return false;
    8281        final SourceEntry other = (SourceEntry) obj;
    83         return equal(other.url, url) &&
     82        return Objects.equals(other.url, url) &&
    8483                other.isZip == isZip &&
    85                 equal(other.zipEntryPath, zipEntryPath) &&
    86                 equal(other.name, name) &&
    87                 equal(other.title, title) &&
     84                Objects.equals(other.zipEntryPath, zipEntryPath) &&
     85                Objects.equals(other.name, name) &&
     86                Objects.equals(other.title, title) &&
    8887                other.active == active;
    8988    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTable.java

    r7027 r7083  
    1414import java.util.List;
    1515import java.util.Map;
     16import java.util.Objects;
    1617
    1718import javax.swing.ButtonGroup;
     
    3536import org.openstreetmap.josm.gui.widgets.JosmTextField;
    3637import org.openstreetmap.josm.tools.GBC;
    37 import org.openstreetmap.josm.tools.Utils;
    3838
    3939/**
     
    192192                if (sEditor.getValue() == 1) {
    193193                    String data = sEditor.getData();
    194                     if (!Utils.equal(sSetting.getValue(), data)) {
     194                    if (!Objects.equals(sSetting.getValue(), data)) {
    195195                        pe.setValue(new StringSetting(data));
    196196                        ok = true;
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java

    r7041 r7083  
    1212import java.util.List;
    1313import java.util.Map;
     14import java.util.Objects;
    1415import java.util.TreeSet;
    1516
     
    214215        private boolean insertNewDefaults(List<SourceEntry> list) {
    215216            boolean changed = false;
    216            
     217
    217218            boolean addedMapcssStyle = false; // Migration code can be removed ~ Nov. 2014
    218219
     
    226227                    @Override
    227228                    public boolean evaluate(SourceEntry se) {
    228                         return Utils.equal(def.url, se.url);
     229                        return Objects.equals(def.url, se.url);
    229230                    }
    230231                });
     
    234235                    changed = true;
    235236                    /* Migration code can be removed ~ Nov. 2014 */
    236                     if (Utils.equal(def.url, "resource://styles/standard/elemstyles.mapcss")) {
     237                    if ("resource://styles/standard/elemstyles.mapcss".equals(def.url)) {
    237238                        addedMapcssStyle = true;
    238239                    }
     
    257258                        @Override
    258259                        public boolean evaluate(SourceEntry se) {
    259                             return Utils.equal(se.url, "resource://styles/standard/elemstyles.xml");
     260                            return "resource://styles/standard/elemstyles.xml".equals(se.url);
    260261                        }
    261262                    });
     
    266267                }
    267268            }
    268            
     269
    269270            return changed;
    270271        }
  • trunk/src/org/openstreetmap/josm/gui/widgets/AbstractTextComponentValidator.java

    r6990 r7083  
    99import java.beans.PropertyChangeEvent;
    1010import java.beans.PropertyChangeListener;
     11import java.util.Objects;
    1112
    1213import javax.swing.BorderFactory;
     
    1819
    1920import org.openstreetmap.josm.tools.CheckParameterUtil;
    20 import org.openstreetmap.josm.tools.Utils;
    2121
    2222/**
     
    4545
    4646    protected void feedbackInvalid(String msg) {
    47         if (valid == null || valid || !Utils.equal(msg, this.msg)) {
     47        if (valid == null || valid || !Objects.equals(msg, this.msg)) {
    4848            // only provide feedback if the validity has changed. This avoids
    4949            // unnecessary UI updates.
     
    6161
    6262    protected void feedbackValid(String msg) {
    63         if (valid == null || !valid || !Utils.equal(msg, this.msg)) {
     63        if (valid == null || !valid || !Objects.equals(msg, this.msg)) {
    6464            // only provide feedback if the validity has changed. This avoids
    6565            // unnecessary UI updates.
  • trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java

    r6883 r7083  
    55import java.net.Authenticator.RequestorType;
    66import java.net.PasswordAuthentication;
     7import java.util.Objects;
    78
    89import org.openstreetmap.josm.data.oauth.OAuthToken;
     
    1011import org.openstreetmap.josm.io.OsmApi;
    1112import org.openstreetmap.josm.tools.CheckParameterUtil;
    12 import org.openstreetmap.josm.tools.Utils;
    1313
    1414/**
     
    7272        this.delegate = delegate;
    7373    }
    74    
     74
    7575    /**
    7676     * Returns type of credentials agent backing this credentials manager.
     
    106106        if (username == null) return null;
    107107        username = username.trim();
    108         return Utils.equal(username, "") ? null : username;
     108        return username.isEmpty() ? null : username;
    109109    }
    110110
     
    116116    @Override
    117117    public void store(RequestorType requestorType, String host, PasswordAuthentication credentials) throws CredentialsAgentException {
    118         if (requestorType == RequestorType.SERVER && Utils.equal(OsmApi.getOsmApi().getHost(), host)) {
     118        if (requestorType == RequestorType.SERVER && Objects.equals(OsmApi.getOsmApi().getHost(), host)) {
    119119            String username = credentials.getUserName();
    120120            if(username != null && !username.trim().isEmpty()) {
  • trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialAgent.java

    r6070 r7083  
    55
    66import java.awt.Component;
     7import java.net.Authenticator.RequestorType;
    78import java.net.PasswordAuthentication;
    8 import java.net.Authenticator.RequestorType;
     9import java.util.Objects;
    910
    1011import javax.swing.text.html.HTMLEditorKit;
     
    1516import org.openstreetmap.josm.gui.widgets.HtmlPanel;
    1617import org.openstreetmap.josm.io.OsmApi;
    17 import org.openstreetmap.josm.tools.Utils;
    1818
    1919/**
     
    3535        switch(requestorType) {
    3636        case SERVER:
    37             if (Utils.equal(OsmApi.getOsmApi().getHost(), host)) {
     37            if (Objects.equals(OsmApi.getOsmApi().getHost(), host)) {
    3838                user = Main.pref.get("osm-server.username", null);
    3939                password = Main.pref.get("osm-server.password", null);
     
    6767        switch(requestorType) {
    6868        case SERVER:
    69             if (Utils.equal(OsmApi.getOsmApi().getHost(), host)) {
     69            if (Objects.equals(OsmApi.getOsmApi().getHost(), host)) {
    7070                Main.pref.put("osm-server.username", credentials.getUserName());
    7171                if (credentials.getPassword() == null) {
  • trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java

    r7033 r7083  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.io.imagery;
    3 
    4 import static org.openstreetmap.josm.tools.Utils.equal;
    53
    64import java.io.IOException;
     
    97import java.util.Arrays;
    108import java.util.List;
     9import java.util.Objects;
    1110import java.util.Stack;
    1211
     
    176175            }
    177176            states.push(newState);
    178             if (newState == State.UNKNOWN && equal(atts.getValue("mandatory"), "true")) {
     177            if (newState == State.UNKNOWN && "true".equals(atts.getValue("mandatory"))) {
    179178                skipEntry = true;
    180179            }
     
    208207                    boolean found = false;
    209208                    for (ImageryType type : ImageryType.values()) {
    210                         if (equal(accumulator.toString(), type.getTypeString())) {
     209                        if (Objects.equals(accumulator.toString(), type.getTypeString())) {
    211210                            entry.setImageryType(type);
    212211                            found = true;
  • trunk/src/org/openstreetmap/josm/io/session/SessionReader.java

    r7033 r7083  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
    5 import static org.openstreetmap.josm.tools.Utils.equal;
    65
    76import java.io.BufferedInputStream;
     
    292291    private void parseJos(Document doc, ProgressMonitor progressMonitor) throws IllegalDataException {
    293292        Element root = doc.getDocumentElement();
    294         if (!equal(root.getTagName(), "josm-session")) {
     293        if (!"josm-session".equals(root.getTagName())) {
    295294            error(tr("Unexpected root element ''{0}'' in session file", root.getTagName()));
    296295        }
     
    355354            if (node.getNodeType() == Node.ELEMENT_NODE) {
    356355                Element e = (Element) node;
    357                 if (equal(e.getTagName(), "layer")) {
    358 
     356                if ("layer".equals(e.getTagName())) {
    359357                    if (!e.hasAttribute("index")) {
    360358                        error(tr("missing mandatory attribute ''index'' for element ''layer''"));
  • trunk/src/org/openstreetmap/josm/tools/Predicates.java

    r6870 r7083  
    11package org.openstreetmap.josm.tools;
    22
     3import java.util.Collection;
     4import java.util.Objects;
     5import java.util.regex.Pattern;
     6
    37import org.openstreetmap.josm.data.osm.OsmPrimitive;
    4 
    5 import java.util.Collection;
    6 import java.util.regex.Pattern;
    78
    89/**
     
    3334            @Override
    3435            public boolean evaluate(T obj) {
    35                 return Utils.equal(obj, ref);
     36                return Objects.equals(obj, ref);
    3637            }
    3738        };
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r7082 r7083  
    174174    }
    175175
    176     /**
    177      * for convenience: test whether 2 objects are either both null or a.equals(b)
    178      */
    179     public static <T> boolean equal(T a, T b) {
    180         if (a == b)
    181             return true;
    182         return (a != null && a.equals(b));
    183     }
    184 
    185176    public static void ensure(boolean condition, String message, Object...data) {
    186177        if (!condition)
Note: See TracChangeset for help on using the changeset viewer.