Changeset 11381 in josm


Ignore:
Timestamp:
2016-12-12T02:28:14+01:00 (7 years ago)
Author:
Don-vip
Message:

findbugs - RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE

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

Legend:

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

    r10604 r11381  
    5151    private Collection<Node> getSelectedNodes() {
    5252        DataSet ds = getLayerManager().getEditDataSet();
    53         if (ds == null || ds.getSelected() == null) {
     53        if (ds == null) {
    5454            return Collections.emptyList();
    5555        } else {
  • trunk/src/org/openstreetmap/josm/actions/ZoomToAction.java

    r10413 r11381  
    7070            return;
    7171        int[] rows = this.table.getSelectedRows();
    72         if (rows == null || rows.length == 0)
     72        if (rows.length == 0)
    7373            return;
    7474        int row = rows[0];
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java

    r11144 r11381  
    401401                updateStateByCurrentSelection();
    402402            }
    403         } else if (state == State.IMPROVING && mousePos != null) {
     403        } else if (state == State.IMPROVING) {
    404404            // Checking if the new coordinate is outside of the world
    405405            if (mv.getLatLon(mousePos.x, mousePos.y).isOutSideWorld()) {
  • trunk/src/org/openstreetmap/josm/actions/mapmode/PlayHeadDragMode.java

    r9067 r11381  
    6666
    6767    @Override public void mouseReleased(MouseEvent ev) {
    68         Point p = ev.getPoint();
    6968        mouseStart = null;
    70         if (ev.getButton() != MouseEvent.BUTTON1 || p == null || !dragging)
     69        if (ev.getButton() != MouseEvent.BUTTON1 || !dragging)
    7170            return;
    7271
  • trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java

    r11339 r11381  
    566566                String pattern = evalVars(item.getAttribute("pattern"));
    567567                String key = evalVars(item.getAttribute("key"));
    568                 if (key != null) {
    569                     PreferencesUtils.deletePreferenceKey(key, mainPrefs);
    570                 }
    571                 if (pattern != null) {
    572                     PreferencesUtils.deletePreferenceKeyByPattern(pattern, mainPrefs);
    573                 }
     568                PreferencesUtils.deletePreferenceKey(key, mainPrefs);
     569                PreferencesUtils.deletePreferenceKeyByPattern(pattern, mainPrefs);
    574570                return;
    575571            }
     
    609605
    610606        private void processDownloadElement(Element item) {
    611             String address = evalVars(item.getAttribute("url"));
    612             String path = evalVars(item.getAttribute("path"));
    613             String unzip = evalVars(item.getAttribute("unzip"));
    614             String mkdir = evalVars(item.getAttribute("mkdir"));
    615 
    616607            String base = evalVars(item.getAttribute("base"));
    617608            String dir = getDirectoryByAbbr(base);
     
    621612            }
    622613
     614            String path = evalVars(item.getAttribute("path"));
    623615            if (path.contains("..") || path.startsWith("/") || path.contains(":")) {
    624616                return; // some basic protection
    625617            }
    626             if (address == null || path == null || address.isEmpty() || path.isEmpty()) {
     618
     619            String address = evalVars(item.getAttribute("url"));
     620            if (address.isEmpty() || path.isEmpty()) {
    627621                log("Error: Please specify url=\"where to get file\" and path=\"where to place it\"");
    628622                return;
    629623            }
     624
     625            String unzip = evalVars(item.getAttribute("unzip"));
     626            String mkdir = evalVars(item.getAttribute("mkdir"));
    630627            processDownloadOperation(address, path, dir, "true".equals(mkdir), "true".equals(unzip));
    631628        }
     
    641638            String text = evalVars(elem.getAttribute("text"));
    642639            String locText = evalVars(elem.getAttribute(LanguageInfo.getJOSMLocaleCode()+".text"));
    643             if (locText != null && !locText.isEmpty()) text = locText;
     640            if (!locText.isEmpty()) text = locText;
    644641
    645642            String type = evalVars(elem.getAttribute("type"));
  • trunk/src/org/openstreetmap/josm/data/cache/HostLimitQueue.java

    r10723 r11381  
    8989        }
    9090        job = takeFirst();
    91         if (job != null) {
    92             acquireSemaphore(job);
    93         }
     91        acquireSemaphore(job);
    9492        return job;
    9593    }
     
    119117        if (job instanceof JCSCachedTileLoaderJob) {
    120118            final JCSCachedTileLoaderJob<?, ?> jcsJob = (JCSCachedTileLoaderJob<?, ?>) job;
    121             Semaphore limit = getSemaphore(jcsJob);
    122             if (limit != null) {
    123                 limit.acquire();
    124                 jcsJob.setFinishedTask(() -> releaseSemaphore(jcsJob));
    125             }
     119            getSemaphore(jcsJob).acquire();
     120            jcsJob.setFinishedTask(() -> releaseSemaphore(jcsJob));
    126121        }
    127122    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r11129 r11381  
    669669        for (OsmPrimitive p : primitives) {
    670670            Map<String, String> tags = p.getKeys();
    671             if (tags == null || tags.isEmpty()) {
     671            if (tags.isEmpty()) {
    672672                continue;
    673673            }
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java

    r10680 r11381  
    273273        public void actionPerformed(ActionEvent arg0) {
    274274            int[] rows = mineTable.getSelectedRows();
    275             if (rows == null || rows.length == 0)
     275            if (rows.length == 0)
    276276                return;
    277277            model.decide(rows, MergeDecisionType.KEEP_MINE);
     
    305305        public void actionPerformed(ActionEvent arg0) {
    306306            int[] rows = theirTable.getSelectedRows();
    307             if (rows == null || rows.length == 0)
     307            if (rows.length == 0)
    308308                return;
    309309            model.decide(rows, MergeDecisionType.KEEP_THEIR);
     
    403403        public void actionPerformed(ActionEvent arg0) {
    404404            int[] rows = mergedTable.getSelectedRows();
    405             if (rows == null || rows.length == 0)
     405            if (rows.length == 0)
    406406                return;
    407407            model.decide(rows, MergeDecisionType.UNDECIDED);
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/TextTagPaster.java

    r10737 r11381  
    4040
    4141    private boolean containsValidTags(TransferSupport support) throws UnsupportedFlavorException, IOException {
    42         Map<String, String> tags = getTagsImpl(support);
    43         return tags != null && !tags.isEmpty();
     42        return !getTagsImpl(support).isEmpty();
    4443    }
    4544
     
    4746    protected Map<String, String> getTags(TransferSupport support) throws UnsupportedFlavorException, IOException {
    4847        Map<String, String> tags = getTagsImpl(support);
    49         if (tags == null || tags.isEmpty()) {
     48        if (tags.isEmpty()) {
    5049            TextTagParser.showBadBufferMessage(help);
    5150            throw new IOException("Invalid tags to paste.");
  • trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java

    r10938 r11381  
    160160        public void select() {
    161161            int[] indexes = userTable.getSelectedRows();
    162             if (indexes == null || indexes.length == 0)
     162            if (indexes.length == 0)
    163163                return;
    164164            model.selectPrimitivesOwnedBy(userTable.getSelectedRows());
     
    196196        public void actionPerformed(ActionEvent e) {
    197197            int[] rows = userTable.getSelectedRows();
    198             if (rows == null || rows.length == 0)
     198            if (rows.length == 0)
    199199                return;
    200200            List<User> users = model.getSelectedUsers(rows);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PresetListPanel.java

    r11357 r11381  
    3737        public void mouseClicked(MouseEvent e) {
    3838            Collection<OsmPrimitive> selection = t.createSelection(presetHandler.getSelection());
    39             if (selection == null || selection.isEmpty())
     39            if (selection.isEmpty())
    4040                return;
    4141            int answer = t.showDialog(selection, false);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java

    r11335 r11381  
    354354                    && ((DefaultMutableTreeNode) child).getUserObject() instanceof TestError) {
    355355                final TestError error = (TestError) ((DefaultMutableTreeNode) child).getUserObject();
    356                 if (error.getPrimitives() != null) {
    357                     if (error.getPrimitives().stream().anyMatch(isRelevant)) {
    358                         paths.add(p.pathByAddingChild(child));
    359                     }
     356                if (error.getPrimitives().stream().anyMatch(isRelevant)) {
     357                    paths.add(p.pathByAddingChild(child));
    360358                }
    361359            } else {
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r11199 r11381  
    11671167
    11681168            Rectangle2D sourceRect = coordinateConverter.getRectangleForTile(tile);
    1169             if (borderRect != null && !sourceRect.intersects(borderRect)) {
     1169            if (!sourceRect.intersects(borderRect)) {
    11701170                continue;
    11711171            }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r10824 r11381  
    147147                    return;
    148148                boolean mousePressedInButton = false;
    149                 if (e.getPoint() != null) {
    150                     for (Marker mkr : data) {
    151                         if (mkr.containsPoint(e.getPoint())) {
    152                             mousePressedInButton = true;
    153                             break;
    154                         }
     149                for (Marker mkr : data) {
     150                    if (mkr.containsPoint(e.getPoint())) {
     151                        mousePressedInButton = true;
     152                        break;
    155153                    }
    156154                }
     
    170168                if (!isVisible())
    171169                    return;
    172                 if (ev.getPoint() != null) {
    173                     for (Marker mkr : data) {
    174                         if (mkr.containsPoint(ev.getPoint())) {
    175                             mkr.actionPerformed(new ActionEvent(this, 0, null));
    176                         }
     170                for (Marker mkr : data) {
     171                    if (mkr.containsPoint(ev.getPoint())) {
     172                        mkr.actionPerformed(new ActionEvent(this, 0, null));
    177173                    }
    178174                }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java

    r10611 r11381  
    6464            Main.map.mapView.addMouseListener(new MouseAdapter() {
    6565                @Override public void mousePressed(MouseEvent ev) {
    66                     Point p = ev.getPoint();
    67                     if (ev.getButton() != MouseEvent.BUTTON1 || p == null)
    68                         return;
    69                     if (playHead.containsPoint(p)) {
     66                    if (ev.getButton() == MouseEvent.BUTTON1 && playHead.containsPoint(ev.getPoint())) {
    7067                        /* when we get a click on the marker, we need to switch mode to avoid
    7168                         * getting confused with other drag operations (like select) */
  • trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java

    r10627 r11381  
    213213        for (String setCookie: setCookies) {
    214214            String[] kvPairs = setCookie.split(";");
    215             if (kvPairs == null || kvPairs.length == 0) {
     215            if (kvPairs.length == 0) {
    216216                continue;
    217217            }
     
    219219                kvPair = kvPair.trim();
    220220                String[] kv = kvPair.split("=");
    221                 if (kv == null || kv.length != 2) {
     221                if (kv.length != 2) {
    222222                    continue;
    223223                }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java

    r10680 r11381  
    430430        if (values_from != null) {
    431431            String[] classMethod = values_from.split("#");
    432             if (classMethod != null && classMethod.length == 2) {
     432            if (classMethod.length == 2) {
    433433                try {
    434434                    Method method = Class.forName(classMethod[0]).getMethod(classMethod[1]);
     
    517517            for (Entry<String, PresetListEntry> entry : lhm.entrySet()) {
    518518                String k = entry.getValue().toString();
    519                 if (k != null && k.equals(display)) {
     519                if (k.equals(display)) {
    520520                    value = entry.getKey();
    521521                    break;
  • trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java

    r11100 r11381  
    439439        for (GraphicsDevice gd: GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
    440440            DisplayMode dm = gd.getDisplayMode();
    441             if (dm != null) {
    442                 height = Math.max(height, dm.getHeight());
    443                 width = Math.max(width, dm.getWidth());
    444             }
     441            height = Math.max(height, dm.getHeight());
     442            width = Math.max(width, dm.getWidth());
    445443        }
    446444        if (height == 0 || width == 0) {
  • trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java

    r10638 r11381  
    393393        protected Date[] parseTime(String value) throws ChangesetQueryUrlException {
    394394            String[] dates = value.split(",");
    395             if (dates == null || dates.length == 0 || dates.length > 2)
     395            if (dates.length == 0 || dates.length > 2)
    396396                throw new ChangesetQueryUrlException(
    397397                        tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "time", value));
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r10627 r11381  
    827827        StringBuilder urlBuilder = noteStringBuilder(note)
    828828            .append("/close");
    829         if (encodedMessage != null && !encodedMessage.trim().isEmpty()) {
     829        if (!encodedMessage.trim().isEmpty()) {
    830830            urlBuilder.append("?text=");
    831831            urlBuilder.append(encodedMessage);
     
    849849        StringBuilder urlBuilder = noteStringBuilder(note)
    850850            .append("/reopen");
    851         if (encodedMessage != null && !encodedMessage.trim().isEmpty()) {
     851        if (!encodedMessage.trim().isEmpty()) {
    852852            urlBuilder.append("?text=");
    853853            urlBuilder.append(encodedMessage);
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r10739 r11381  
    243243            if (child != null) {
    244244                String baseURL = child.getAttribute("xlink:href");
    245                 if (baseURL != null && !baseURL.equals(serviceUrlStr)) {
     245                if (!baseURL.equals(serviceUrlStr)) {
    246246                    Main.info("GetCapabilities specifies a different service URL: " + baseURL);
    247247                    serviceUrl = new URL(baseURL);
  • trunk/src/org/openstreetmap/josm/io/session/SessionReader.java

    r11374 r11381  
    380380        String activeAtt = layersEl.getAttribute("active");
    381381        try {
    382             active = (activeAtt != null && !activeAtt.isEmpty()) ? Integer.parseInt(activeAtt)-1 : -1;
     382            active = !activeAtt.isEmpty() ? (Integer.parseInt(activeAtt)-1) : -1;
    383383        } catch (NumberFormatException e) {
    384384            Main.warn("Unsupported value for 'active' layer attribute. Ignoring it. Error was: "+e.getMessage());
     
    407407                    if (idx == null) {
    408408                        error(tr("unexpected format of attribute ''index'' for element ''layer''"));
    409                     }
    410                     if (elems.containsKey(idx)) {
     409                    } else if (elems.containsKey(idx)) {
    411410                        error(tr("attribute ''index'' ({0}) for element ''layer'' must be unique", Integer.toString(idx)));
    412411                    }
     
    415414                    deps.putVoid(idx);
    416415                    String depStr = e.getAttribute("depends");
    417                     if (depStr != null && !depStr.isEmpty()) {
     416                    if (!depStr.isEmpty()) {
    418417                        for (String sd : depStr.split(",")) {
    419418                            Integer d = null;
  • trunk/src/org/openstreetmap/josm/plugins/PluginListParser.java

    r10123 r11381  
    9595            if (name != null) {
    9696                PluginInformation info = createInfo(name, url, manifest);
    97                 if (info != null) {
    98                     for (PluginProxy plugin : PluginHandler.pluginList) {
    99                         if (plugin.getPluginInformation().name.equals(info.getName())) {
    100                             info.localversion = plugin.getPluginInformation().localversion;
    101                         }
     97                for (PluginProxy plugin : PluginHandler.pluginList) {
     98                    if (plugin.getPluginInformation().name.equals(info.getName())) {
     99                        info.localversion = plugin.getPluginInformation().localversion;
    102100                    }
    103                     ret.add(info);
    104101                }
     102                ret.add(info);
    105103            }
    106104        } catch (PluginListParseException ex) {
  • trunk/src/org/openstreetmap/josm/tools/HttpClient.java

    r11288 r11381  
    209209                        ) {
    210210                    String content = this.fetchContent();
    211                     if (content == null || content.isEmpty()) {
     211                    if (content.isEmpty()) {
    212212                        Main.debug("Server did not return any body");
    213213                    } else {
     
    289289                }
    290290            }
    291             if (in != null) {
    292                 in = new ProgressInputStream(in, getContentLength(), monitor);
    293                 in = "gzip".equalsIgnoreCase(getContentEncoding()) ? new GZIPInputStream(in) : in;
    294                 Compression compression = Compression.NONE;
    295                 if (uncompress) {
    296                     final String contentType = getContentType();
    297                     Main.debug("Uncompressing input stream according to Content-Type header: {0}", contentType);
    298                     compression = Compression.forContentType(contentType);
    299                 }
    300                 if (uncompressAccordingToContentDisposition && Compression.NONE.equals(compression)) {
    301                     final String contentDisposition = getHeaderField("Content-Disposition");
    302                     final Matcher matcher = Pattern.compile("filename=\"([^\"]+)\"").matcher(
    303                             contentDisposition != null ? contentDisposition : "");
    304                     if (matcher.find()) {
    305                         Main.debug("Uncompressing input stream according to Content-Disposition header: {0}", contentDisposition);
    306                         compression = Compression.byExtension(matcher.group(1));
    307                     }
    308                 }
    309                 in = compression.getUncompressedInputStream(in);
    310             }
     291            in = new ProgressInputStream(in, getContentLength(), monitor);
     292            in = "gzip".equalsIgnoreCase(getContentEncoding()) ? new GZIPInputStream(in) : in;
     293            Compression compression = Compression.NONE;
     294            if (uncompress) {
     295                final String contentType = getContentType();
     296                Main.debug("Uncompressing input stream according to Content-Type header: {0}", contentType);
     297                compression = Compression.forContentType(contentType);
     298            }
     299            if (uncompressAccordingToContentDisposition && Compression.NONE.equals(compression)) {
     300                final String contentDisposition = getHeaderField("Content-Disposition");
     301                final Matcher matcher = Pattern.compile("filename=\"([^\"]+)\"").matcher(
     302                        contentDisposition != null ? contentDisposition : "");
     303                if (matcher.find()) {
     304                    Main.debug("Uncompressing input stream according to Content-Disposition header: {0}", contentDisposition);
     305                    compression = Compression.byExtension(matcher.group(1));
     306                }
     307            }
     308            in = compression.getUncompressedInputStream(in);
    311309            return in;
    312310        }
  • trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java

    r10627 r11381  
    204204    protected final void initFromPreferences(String preferenceKey) throws WindowGeometryException {
    205205        String value = Main.pref.get(preferenceKey);
    206         if (value == null || value.isEmpty())
     206        if (value.isEmpty())
    207207            throw new WindowGeometryException(
    208208                    tr("Preference with key ''{0}'' does not exist. Cannot restore window geometry from preferences.", preferenceKey));
Note: See TracChangeset for help on using the changeset viewer.