Changeset 18801 in josm


Ignore:
Timestamp:
2023-08-09T15:30:01+02:00 (9 months ago)
Author:
taylor.smock
Message:

Fix #22832: Code cleanup and some simplification, documentation fixes (patch by gaben)

There should not be any functional changes in this patch; it is intended to do
the following:

  • Simplify and cleanup code (example: Arrays.asList(item) -> Collections.singletonList(item))
  • Fix typos in documentation (which also corrects the documentation to match what actually happens, in some cases)
Location:
trunk
Files:
132 edited

Legend:

Unmodified
Added
Removed
  • trunk/native/docker-test.sh

    r17976 r18801  
     1#!/bin/bash
     2
    13docker build . -t josm/josm
    24mkdir -p test/report
    3 docker run -it --name josm -v `pwd`/test/report:/josm/test/report josm/josm
     5docker run -it --name josm -v "$(pwd)"/test/report:/josm/test/report josm/josm
    46docker rm josm
    57docker rmi josm/josm
  • trunk/native/windows/win-jpackage.sh

    r18525 r18801  
    3838#sed -i "s|%josm-source-dir%|$(pwd)|g" native/windows/main.wxs
    3939cp native/windows/main.wxs native/windows/main.wxs.bak
    40 sed -i 's?%josm-source-dir%?'`pwd`'?' native/windows/main.wxs
     40sed -i "s?%josm-source-dir%?$(pwd)?" native/windows/main.wxs
    4141sed -i 's?"/c/?"c:/?g' native/windows/main.wxs
    4242sed -i 's?"/d/?"d:/?g' native/windows/main.wxs
     
    4747for type in exe msi
    4848do
    49     jpackage $JPACKAGEOPTIONS -n "JOSM" --input dist --main-jar josm-custom.jar \
     49    jpackage "$JPACKAGEOPTIONS" -n "JOSM" --input dist --main-jar josm-custom.jar \
    5050    --main-class org.openstreetmap.josm.gui.MainApplication \
    5151    --icon ./native/windows/logo.ico --type $type --dest app \
     
    8686mv native/windows/main.wxs.bak native/windows/main.wxs
    8787
    88 mv app/JOSM-1.5.$1.exe app/JOSM.exe
    89 mv app/JOSM-1.5.$1.msi app/JOSM.msi
     88mv app/JOSM-1.5."$1".exe app/JOSM.exe
     89mv app/JOSM-1.5."$1".msi app/JOSM.msi
    9090
    9191# Workaround to https://bugs.openjdk.java.net/browse/JDK-8261845
  • trunk/scripts/BuildProjectionDefinitions.java

    r16344 r18801  
    9393        if (list.isEmpty())
    9494            throw new AssertionError("EPSG file seems corrupted");
    95         Pattern badDmsPattern = Pattern.compile("(\\d+(?:\\.\\d+)?d\\d+(?:\\.\\d+)?')(N|S|E|W)");
     95        Pattern badDmsPattern = Pattern.compile("(\\d+(?:\\.\\d+)?d\\d+(?:\\.\\d+)?')([NSEW])");
    9696        for (ProjectionDefinition pd : list) {
    9797            // DMS notation without second causes problems with cs2cs, add 0"
     
    145145
    146146        if (printStats) {
    147             System.out.println(String.format("loaded %d entries from %s", epsgJosm.size(), JOSM_EPSG_FILE));
    148             System.out.println(String.format("loaded %d entries from %s", epsgProj4.size(), PROJ4_EPSG_FILE));
    149             System.out.println(String.format("loaded %d entries from %s", esriProj4.size(), PROJ4_ESRI_FILE));
     147            System.out.printf("loaded %d entries from %s%n", epsgJosm.size(), JOSM_EPSG_FILE);
     148            System.out.printf("loaded %d entries from %s%n", epsgProj4.size(), PROJ4_EPSG_FILE);
     149            System.out.printf("loaded %d entries from %s%n", esriProj4.size(), PROJ4_ESRI_FILE);
    150150            System.out.println();
    151151            System.out.println("some entries from proj.4 have not been included:");
    152             System.out.println(String.format(" * already in the maintained JOSM list: %d entries", noInJosm));
     152            System.out.printf(" * already in the maintained JOSM list: %d entries%n", noInJosm);
    153153            if (noInProj4 > 0) {
    154                 System.out.println(String.format(" * ESRI already in the standard EPSG list: %d entries", noInProj4));
    155             }
    156             System.out.println(String.format(" * deprecated: %d entries", noDeprecated));
    157             System.out.println(String.format(" * using +proj=geocent, which is 3D (X,Y,Z) and not useful in JOSM: %d entries", noGeocent));
     154                System.out.printf(" * ESRI already in the standard EPSG list: %d entries%n", noInProj4);
     155            }
     156            System.out.printf(" * deprecated: %d entries%n", noDeprecated);
     157            System.out.printf(" * using +proj=geocent, which is 3D (X,Y,Z) and not useful in JOSM: %d entries%n", noGeocent);
    158158            if (noEllipsoid > 0) {
    159                 System.out.println(String.format(" * unsupported ellipsoids: %d entries", noEllipsoid));
     159                System.out.printf(" * unsupported ellipsoids: %d entries%n", noEllipsoid);
    160160                System.out.println("   in particular: " + ellipsoidMap);
    161161            }
    162162            if (noBaseProjection > 0) {
    163                 System.out.println(String.format(" * unsupported base projection: %d entries", noBaseProjection));
     163                System.out.printf(" * unsupported base projection: %d entries%n", noBaseProjection);
    164164                System.out.println("   in particular: " + baseProjectionMap);
    165165            }
    166166            if (noDatumgrid > 0) {
    167                 System.out.println(String.format(" * requires data file for vertical datum conversion: %d entries", noDatumgrid));
     167                System.out.printf(" * requires data file for vertical datum conversion: %d entries%n", noDatumgrid);
    168168                System.out.println("   in particular: " + datumgridMap);
    169169            }
    170170            if (noNadgrid > 0) {
    171                 System.out.println(String.format(" * requires data file for datum conversion: %d entries", noNadgrid));
     171                System.out.printf(" * requires data file for datum conversion: %d entries%n", noNadgrid);
    172172                System.out.println("   in particular: " + nadgridMap);
    173173            }
    174174            if (noOmercNoBounds > 0) {
    175                 System.out.println(String.format(
    176                         " * projection is Oblique Mercator (requires bounds), but no bounds specified: %d entries", noOmercNoBounds));
     175                System.out.printf(
     176                        " * projection is Oblique Mercator (requires bounds), but no bounds specified: %d entries%n", noOmercNoBounds);
    177177            }
    178178            if (noEquatorStereo > 0) {
    179                 System.out.println(String.format(" * projection is Equatorial Stereographic (see #15970): %d entries", noEquatorStereo));
     179                System.out.printf(" * projection is Equatorial Stereographic (see #15970): %d entries%n", noEquatorStereo);
    180180            }
    181181            System.out.println();
    182             System.out.println(String.format("written %d entries from %s", noJosm, JOSM_EPSG_FILE));
    183             System.out.println(String.format("written %d entries from %s", noProj4, PROJ4_EPSG_FILE));
    184             System.out.println(String.format("written %d entries from %s", noEsri, PROJ4_ESRI_FILE));
     182            System.out.printf("written %d entries from %s%n", noJosm, JOSM_EPSG_FILE);
     183            System.out.printf("written %d entries from %s%n", noProj4, PROJ4_EPSG_FILE);
     184            System.out.printf("written %d entries from %s%n", noEsri, PROJ4_ESRI_FILE);
    185185        }
    186186    }
  • trunk/scripts/SyncEditorLayerIndex.java

    r18723 r18801  
    7070 * Compare and analyse the differences of the editor layer index and the JOSM imagery list.
    7171 * The goal is to keep both lists in sync.
    72  *
    73  * The editor layer index project (https://github.com/osmlab/editor-layer-index)
    74  * provides also a version in the JOSM format, but the GEOJSON is the original source
    75  * format, so we read that.
    76  *
    77  * How to run:
    78  * -----------
    79  *
    80  * Main JOSM binary needs to be in classpath, e.g.
    81  *
    82  * $ java -cp ../dist/josm-custom.jar SyncEditorLayerIndex
    83  *
    84  * Add option "-h" to show the available command line flags.
     72 * <p>
     73 * The <a href="https://github.com/osmlab/editor-layer-index">editor layer index</a> project
     74 * provides also a version in the JOSM format, but the GEOJSON is the original source format, so we read that.
     75 * <p>
     76 * For running, the main JOSM binary needs to be in classpath, e.g.
     77 * <p>
     78 * {@code $ java -cp ../dist/josm-custom.jar SyncEditorLayerIndex}
     79 * <p>
     80 * Add option {@code -h} to show the available command line flags.
    8581 */
    8682@SuppressWarnings("unchecked")
     
    294290    void myprintln(String s) {
    295291        String color;
     292        final String escaped = s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
    296293        if ((color = isSkipString(s)) != null) {
    297294            skip.remove(s);
    298295            if (optionXhtmlBody || optionXhtml) {
    299296                s = "<pre style=\"margin:3px;color:"+color+"\">"
    300                         + s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;")+"</pre>";
     297                        + escaped +"</pre>";
    301298            }
    302299            if (!optionNoSkip) {
     
    310307                                (s.startsWith("!") ? "orange" :
    311308                                    (s.startsWith("~") ? "red" : "brown"))));
    312             s = "<pre style=\"margin:3px;color:"+color+"\">"+s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;")+"</pre>";
     309            s = "<pre style=\"margin:3px;color:"+color+"\">"+ escaped +"</pre>";
    313310        }
    314311        if ((s.startsWith("+ ") || s.startsWith("+++ ELI") || s.startsWith("#")) && optionNoEli) {
  • trunk/scripts/TagInfoExtract.java

    r18760 r18801  
    9090 * Run from the base directory of a JOSM checkout:
    9191 * <p>
     92 * <pre>
    9293 * java -cp dist/josm-custom.jar TagInfoExtract --type mappaint
    9394 * java -cp dist/josm-custom.jar TagInfoExtract --type presets
    9495 * java -cp dist/josm-custom.jar TagInfoExtract --type external_presets
     96 * </pre>
    9597 */
    9698public class TagInfoExtract {
     
    245247                        .build());
    246248                if (options.outputFile == null) {
    247                     System.out.println(writer.toString());
     249                    System.out.println(writer);
    248250                }
    249251            }
  • trunk/scripts/TaggingPresetSchemeWikiGenerator.java

    r16644 r18801  
    2323
    2424/**
    25  * This script generates the wiki content for https://josm.openstreetmap.de/wiki/TaggingPresets#Attributes
     25 * This script generates the wiki content for <a href="https://josm.openstreetmap.de/wiki/TaggingPresets#Attributes">
     26 * TaggingPresets#Attributes</a>
    2627 */
    2728public final class TaggingPresetSchemeWikiGenerator {
  • trunk/src/org/openstreetmap/josm/actions/JosmAction.java

    r18181 r18801  
    519519        }
    520520        if ((checkRes & Command.IS_INCOMPLETE) != 0) {
    521             boolean answer = showConfirmOutlyingOperationDialog(operation + "_incomplete", incompleteDialogMessage, dialogTitle);
    522             if (!answer)
    523                 return false;
     521            return showConfirmOutlyingOperationDialog(operation + "_incomplete", incompleteDialogMessage, dialogTitle);
    524522        }
    525523        return true;
  • trunk/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java

    r17188 r18801  
    157157        result.removeIf(way -> way.getNodesCount() <= 2);
    158158
    159         if (selectedWays.isEmpty())
    160             return result;
    161         else {
    162             // Return only selected ways
     159        // Return only selected ways
     160        if (!selectedWays.isEmpty()) {
    163161            result.removeIf(way -> !selectedWays.contains(way));
    164             return result;
    165162        }
     163        return result;
    166164    }
    167165
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r18752 r18801  
    6262     * if they want to be able to veto an upload.
    6363     * <p>
    64      * Be default, the standard upload dialog is the only element in the list.
     64     * By default, the standard upload dialog is the only element in the list.
    6565     * Plugins should normally insert their code before that, so that the upload
    6666     * dialog is the last thing shown before upload really starts; on occasion
  • trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java

    r18208 r18801  
    136136     *
    137137     * @param layer the data layer from which we upload a subset of primitives
    138      * @param toUpload the primitives to upload. If null or empty returns immediatelly
     138     * @param toUpload the primitives to upload. If null or empty returns immediately
    139139     */
    140140    public void uploadPrimitives(OsmDataLayer layer, Collection<OsmPrimitive> toUpload) {
  • trunk/src/org/openstreetmap/josm/actions/corrector/ReverseWayTagCorrector.java

    r17289 r18801  
    9999
    100100                StringBuilder result = new StringBuilder();
    101                 result.append(text.substring(0, m.start(2)))
     101                result.append(text, 0, m.start(2))
    102102                      .append(leftRight.equals(a) ? b : a)
    103103                      .append(text.substring(m.end(2)));
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/AbstractChangesetDownloadTask.java

    r13927 r18801  
    104104     *    Future&lt;?&gt; future = task.download();
    105105     *    // DON'T run this on the Swing EDT or JOSM will freeze
    106      *    future.get(); // waits for the dowload task to complete
     106     *    future.get(); // waits for the download task to complete
    107107     * </pre>
    108108     *
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r18211 r18801  
    106106     *    Future&lt;?&gt; future = task.download(...);
    107107     *    // DON'T run this on the Swing EDT or JOSM will freeze
    108      *    future.get(); // waits for the dowload task to complete
     108     *    future.get(); // waits for the download task to complete
    109109     * </pre>
    110110     *
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java

    r17896 r18801  
    208208     * segments for the given pointer position (via MouseEvent) and modifiers.
    209209     * @param e current mouse event
    210      * @param modifiers extended mouse modifiers, not necessarly taken from the given mouse event
     210     * @param modifiers extended mouse modifiers, not necessarily taken from the given mouse event
    211211     */
    212212    private void addHighlighting(MouseEvent e, int modifiers) {
     
    256256     *
    257257     * @param e current mouse event
    258      * @param modifiers extended mouse modifiers, not necessarly taken from the given mouse event
     258     * @param modifiers extended mouse modifiers, not necessarily taken from the given mouse event
    259259     */
    260260    private void updateCursor(MouseEvent e, int modifiers) {
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawSnapHelper.java

    r18612 r18801  
    465465                EastNorth enOpt = null;
    466466                double dOpt = 1e5;
    467                 for (EastNorth en: pointsToProject) { // searching for besht projection
     467                for (EastNorth en: pointsToProject) { // searching for best projection
    468468                    double l1 = (en.east()-e0)*pe+(en.north()-n0)*pn;
    469469                    double d1 = Math.abs(l1-l);
  • trunk/src/org/openstreetmap/josm/actions/upload/UploadHook.java

    r13028 r18801  
    77
    88/**
    9  * Change, or block, the upload.
     9 * Change or block the upload.
    1010 *
    1111 * The UploadHook may modify the uploaded data silently, it may display a
     
    1717
    1818    /**
    19      * Check, and/or change, the data to be uploaded.
     19     * Check and/or change the data to be uploaded.
    2020     * Default implementation is to approve the upload.
    2121     * @param apiDataSet the data to upload, modify this to change the data.
  • trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java

    r18724 r18801  
    104104                    Optional<PrimitiveData> o = data.stream()
    105105                            .filter(pd -> pd.getPrimitiveId().equals(osm.getPrimitiveId())).findAny();
    106                     if (o.isPresent()) {
    107                         osm.load(o.get());
    108                     }
     106                    o.ifPresent(osm::load);
    109107                } else {
    110108                    ds.addPrimitive(osm);
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r18395 r18801  
    510510
    511511        if (ws.getWay().isClosed()) {
    512             // If the way is circular (first and last nodes are the same), the way shouldn't be splitted
     512            // If the way is circular (first and last nodes are the same), the way shouldn't be split
    513513
    514514            List<Node> n = new ArrayList<>();
  • trunk/src/org/openstreetmap/josm/data/Bounds.java

    r18695 r18801  
    502502    /**
    503503     * Determines if this Bounds object crosses the 180th Meridian.
    504      * See http://wiki.openstreetmap.org/wiki/180th_meridian
     504     * See <a href="http://wiki.openstreetmap.org/wiki/180th_meridian">180th Meridian</a>.
    505505     * @return true if this Bounds object crosses the 180th Meridian.
    506506     */
  • trunk/src/org/openstreetmap/josm/data/Version.java

    r18211 r18801  
    4646
    4747    /**
    48      * Initializes the version infos from the revision resource file
     48     * Initializes the version info from the revision resource file
    4949     *
    5050     * @param revisionInfo the revision info from a revision resource file as InputStream
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxTrackSegment.java

    r18494 r18801  
    4747        for (WayPoint tpt : wayPoints) {
    4848            if (last != null) {
    49                 Double d = last.greatCircleDistance(tpt);
    50                 if (!d.isNaN() && !d.isInfinite()) {
     49                double d = last.greatCircleDistance(tpt);
     50                if (!Double.isNaN(d) && !Double.isInfinite(d)) {
    5151                    result += d;
    5252                }
  • trunk/src/org/openstreetmap/josm/data/imagery/DefaultLayer.java

    r18723 r18801  
    99
    1010import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
     11import org.openstreetmap.josm.tools.Utils;
    1112
    1213/**
     
    3435        this.layerName = layerName == null ? "" : layerName;
    3536        this.style = style == null ? "" : style;
    36         if (imageryType != ImageryType.WMTS && !(tileMatrixSet == null || "".equals(tileMatrixSet))) {
     37        if (imageryType != ImageryType.WMTS && !Utils.isEmpty(tileMatrixSet)) {
    3738            throw new IllegalArgumentException(tr("{0} imagery has tileMatrixSet defined to: {1}", imageryType, tileMatrixSet));
    3839        }
  • trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java

    r16436 r18801  
    285285
    286286    /**
    287      * Stores the bookmakrs in the settings.
     287     * Stores the bookmarks in the settings.
    288288     */
    289289    public static void saveBookmarks() {
  • trunk/src/org/openstreetmap/josm/data/oauth/IOAuthToken.java

    r18665 r18801  
    1313     * Sign a client
    1414     * @param client The client to sign
    15      * @throws OAuthException if the OAuth token type is unknown (AKA we do't know how to handle it)
     15     * @throws OAuthException if the OAuth token type is unknown (AKA we don't know how to handle it)
    1616     */
    1717    void sign(HttpClient client) throws OAuthException;
  • trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java

    r18303 r18801  
    155155
    156156    /**
    157      * Returns the list of changesets contained in the cache.
    158      * @return the list of changesets contained in the cache
     157     * Returns the set of changesets contained in the cache.
     158     * @return the set of changesets contained in the cache
    159159     */
    160160    public Set<Changeset> getChangesets() {
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r18724 r18801  
    374374
    375375    /**
    376      * Replies the set of changeset tags to be applied when or if this is ever uploaded.
    377      * @return the set of changeset tags
     376     * Replies the map of changeset tags to be applied when or if this is ever uploaded.
     377     * @return the map of changeset tags
    378378     * @see #addChangeSetTag
    379379     */
  • trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java

    r17981 r18801  
    150150
    151151    /**
    152      * Postprocess the dataset and fix all merged references to point to the actual
    153      * data.
     152     * Postprocess the dataset and fix all merged references to point to the actual data.
    154153     */
    155154    public void fixReferences() {
  • trunk/src/org/openstreetmap/josm/data/osm/FilterMatcher.java

    r17980 r18801  
    7878
    7979        FilterInfo(Filter filter) throws SearchParseError {
    80             if (filter.mode == SearchMode.remove || filter.mode == SearchMode.in_selection) {
    81                 isDelete = true;
    82             } else {
    83                 isDelete = false;
    84             }
     80            isDelete = filter.mode == SearchMode.remove || filter.mode == SearchMode.in_selection;
    8581
    8682            Match compiled = SearchCompiler.compile(filter);
  • trunk/src/org/openstreetmap/josm/data/osm/IPrimitive.java

    r17981 r18801  
    288288     *
    289289     * @return date of last modification
    290      * @see #getInstant
     290     * @see #setInstant
    291291     */
    292292    Instant getInstant();
     
    394394    /**
    395395     * Get an object to synchronize the style cache on. This <i>should</i> be a field that does not change during paint.
    396      * By default, it returns the current object, but should be overriden to avoid some performance issues.
     396     * By default, it returns the current object, but should be overridden to avoid some performance issues.
    397397     * @return A non-{@code null} object to synchronize on when painting
    398398     */
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r18494 r18801  
    359359
    360360    /**
    361      * Replies the set of referring ways.
    362      * @return the set of referring ways
     361     * Replies the list of referring ways.
     362     * @return the list of referring ways
    363363     * @since 12031
    364364     */
  • trunk/src/org/openstreetmap/josm/data/osm/OsmDataManager.java

    r14143 r18801  
    7171        Optional<OsmDataLayer> layer = MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class).stream()
    7272                .filter(l -> l.data.equals(ds)).findFirst();
    73         if (layer.isPresent()) {
    74             MainApplication.getLayerManager().setActiveLayer(layer.get());
    75         }
     73        layer.ifPresent(osmDataLayer -> MainApplication.getLayerManager().setActiveLayer(osmDataLayer));
    7674    }
    7775
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r18516 r18801  
    992992
    993993    /**
    994      * Equal, if the id (and class) is equal.
    995      *
    996      * An primitive is equal to its incomplete counter part.
     994     * Equal if the id (and class) are equal.
     995     * <p>
     996     * A primitive is equal to its incomplete counterpart.
    997997     */
    998998    @Override
     
    10101010    /**
    10111011     * Return the id plus the class type encoded as hashcode or super's hashcode if id is 0.
    1012      *
    1013      * An primitive has the same hashcode as its incomplete counterpart.
     1012     * <p>
     1013     * A primitive has the same hashcode as its incomplete counterpart.
    10141014     */
    10151015    @Override
  • trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java

    r18208 r18801  
    3636    /**
    3737     * Discouraged synonym for {@link #TRUE_VALUE}
    38      */
     38     * @deprecated since xxx, use {@link #TRUE_VALUE} instead.
     39     */
     40    @Deprecated
    3941    public static final String trueval = TRUE_VALUE;
    4042    /**
    4143     * Discouraged synonym for {@link #FALSE_VALUE}
    42      */
     44     * @deprecated since xxx, use {@link #FALSE_VALUE} instead.
     45     */
     46    @Deprecated
    4347    public static final String falseval = FALSE_VALUE;
    4448    /**
    4549     * Discouraged synonym for {@link #REVERSE_VALUE}
    46      */
     50     * @deprecated since xxx, use {@link #REVERSE_VALUE} instead.
     51     */
     52    @Deprecated
    4753    public static final String reverseval = REVERSE_VALUE;
    4854
     
    5460     * Converts a string to a boolean value
    5561     * @param value The string to convert
    56      * @return {@link Boolean#TRUE} if that string represents a true value,
    57      *         {@link Boolean#FALSE} if it represents a false value,
    58      *         <code>null</code> otherwise.
     62     * @return {@link Boolean#TRUE} if that string represents a true value,<br>
     63     *         {@link Boolean#FALSE} if it represents a false value,<br>
     64     *         {@code null} otherwise.
    5965     */
    6066    public static Boolean getOsmBoolean(String value) {
     
    7581    public static String getNamedOsmBoolean(String value) {
    7682        Boolean res = getOsmBoolean(value);
    77         return res == null ? value : (res ? trueval : falseval);
     83        return res == null ? value : (res ? TRUE_VALUE : FALSE_VALUE);
    7884    }
    7985
     
    119125     * Check if a tag value represents a boolean false value
    120126     * @param value The value to check
    121      * @return true if it is a true value.
     127     * @return true if it is a false value.
    122128     */
    123129    public static boolean isFalse(String value) {
     
    138144    /**
    139145     * Creates a new OSM primitive around (0,0) according to the given assertion. Originally written for unit tests,
    140      * this can also be used in another places like validation of local MapCSS validator rules.
     146     * this can also be used in other places like validation of local MapCSS validator rules.
    141147     * Ways and relations created using this method are empty.
    142148     * @param assertion The assertion describing OSM primitive (ex: "way name=Foo railway=rail")
     
    151157    /**
    152158     * Creates a new OSM primitive according to the given assertion. Originally written for unit tests,
    153      * this can also be used in another places like validation of local MapCSS validator rules.
     159     * this can also be used in other places like validation of local MapCSS validator rules.
    154160     * @param assertion The assertion describing OSM primitive (ex: "way name=Foo railway=rail")
    155161     * @param around the coordinate at which the primitive will be located
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r18208 r18801  
    525525    public Collection<OsmPrimitive> getIncompleteMembers() {
    526526        return Arrays.stream(members)
    527                 .filter(rm -> rm.getMember().isIncomplete())
    528527                .map(RelationMember::getMember)
     528                .filter(OsmPrimitive::isIncomplete)
    529529                .collect(Collectors.toSet());
    530530    }
  • trunk/src/org/openstreetmap/josm/data/osm/Storage.java

    r17860 r18801  
    1515
    1616/**
    17  * A Set-like class that allows looking up equivalent preexising instance.
     17 * A Set-like class that allows looking up equivalent preexisting instance.
    1818 * It is useful wherever one would use self-mapping construct like
    1919 * <code>Map&lt;T,T&gt;.put(t,t)</code>, that is, for caches, uniqueness filters or similar.
  • trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java

    r18496 r18801  
    919919            this.key = key;
    920920            this.value = value == null ? "" : value;
    921             if ("".equals(this.value) && "*".equals(key)) {
     921            if (this.value.isEmpty() && "*".equals(key)) {
    922922                mode = Mode.NONE;
    923             } else if ("".equals(this.value)) {
     923            } else if (this.value.isEmpty()) {
    924924                if (regexp) {
    925925                    mode = Mode.MISSING_KEY_REGEXP;
  • trunk/src/org/openstreetmap/josm/data/projection/Ellipsoid.java

    r16630 r18801  
    357357        double lat0 = 2*Math.atan(Math.exp(latIso))-Math.PI/2;
    358358        double lati = lat0;
    359         double lati1 = 1.0; // random value to start the iterative processus
     359        double lati1 = 1.0; // random value to start the iterative processes
    360360        while (Math.abs(lati1-lati) >= epsilon) {
    361361            lati = lati1;
  • trunk/src/org/openstreetmap/josm/data/tagging/ac/AutoCompletionPriority.java

    r12859 r18801  
    127127            return ds;
    128128
    129         int std = Boolean.compare(inStandard, other.inStandard);
    130         if (std != 0)
    131             return std;
    132 
    133         return 0;
     129        return Boolean.compare(inStandard, other.inStandard);
    134130    }
    135131
  • trunk/src/org/openstreetmap/josm/data/validation/ValidationTask.java

    r18776 r18801  
    4343     * @param tests                     the tests to run
    4444     * @param validatedPrimitives       the collection of primitives to validate.
    45      * @param formerValidatedPrimitives the last collection of primitives being validates. May be null.
     45     * @param formerValidatedPrimitives the last collection of primitives being validated. May be null.
    4646     */
    4747    public ValidationTask(Collection<Test> tests,
     
    5858     * @param tests                     the tests to run
    5959     * @param validatedPrimitives       the collection of primitives to validate.
    60      * @param formerValidatedPrimitives the last collection of primitives being validates. May be null.
     60     * @param formerValidatedPrimitives the last collection of primitives being validated. May be null.
    6161     * @param beforeUpload              {@code true} if this is being run prior to upload
    6262     * @since 18752
  • trunk/src/org/openstreetmap/josm/data/validation/routines/EmailValidator.java

    r10338 r18801  
    126126
    127127    /**
    128      * <p>Checks if a field has a valid e-mail address.</p>
    129      *
    130      * @param email The value validation is being performed on.  A <code>null</code>
     128     * Checks if a field has a valid e-mail address.
     129     *
     130     * @param email The value validation is being performed on. A <code>null</code>
    131131     *              value is considered invalid.
    132132     * @return true if the email address is valid.
  • trunk/src/org/openstreetmap/josm/data/validation/routines/InetAddressValidator.java

    r18208 r18801  
    157157        for (int index = 0; index < octets.length; index++) {
    158158            String octet = octets[index];
    159             if (octet.length() == 0) {
     159            if (octet.isEmpty()) {
    160160                emptyOctets++;
    161161                if (emptyOctets > 1) {
  • trunk/src/org/openstreetmap/josm/data/validation/routines/UrlValidator.java

    r17374 r18801  
    258258
    259259    /**
    260      * Customizable constructor. Validation behavior is modifed by passing in options.
     260     * Customizable constructor. Validation behavior is modified by passing in options.
    261261     * @param schemes the set of valid schemes. Ignored if the ALLOW_ALL_SCHEMES option is set.
    262262     * @param authorityValidator Regular expression validator used to validate the authority part
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java

    r18284 r18801  
    9999            if (w.isClosed() && w.hasTag(HIGHWAY, CLASSIFIED_HIGHWAYS) && w.hasTag("junction", "circular", "roundabout")
    100100                    && IN_DOWNLOADED_AREA_STRICT.test(w)) {
    101                 // TODO: find out how to handle splitted roundabouts (see #12841)
     101                // TODO: find out how to handle split roundabouts (see #12841)
    102102                testWrongRoundabout(w);
    103103            }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Lanes.java

    r17863 r18801  
    6464                            .build());
    6565                }
    66             } catch (NumberFormatException ignore) {
    67                 Logging.debug(ignore.getMessage());
     66            } catch (NumberFormatException e) {
     67                Logging.debug(e.getMessage());
    6868            }
    6969        }
     
    7676        final String backward = Utils.firstNonNull(p.get("lanes:backward"), "0");
    7777        try {
    78         if (Integer.parseInt(lanes) < Integer.parseInt(forward) + Integer.parseInt(backward)) {
    79             errors.add(TestError.builder(this, Severity.WARNING, 3101)
    80                     .message(tr("Number of {0} greater than {1}", tr("{0}+{1}", "lanes:forward", "lanes:backward"), "lanes"))
    81                     .primitives(p)
    82                     .build());
    83         }
    84         } catch (NumberFormatException ignore) {
    85             Logging.debug(ignore.getMessage());
     78            if (Integer.parseInt(lanes) < Integer.parseInt(forward) + Integer.parseInt(backward)) {
     79                errors.add(TestError.builder(this, Severity.WARNING, 3101)
     80                        .message(tr("Number of {0} greater than {1}", tr("{0}+{1}", "lanes:forward", "lanes:backward"), "lanes"))
     81                        .primitives(p)
     82                        .build());
     83            }
     84        } catch (NumberFormatException e) {
     85            Logging.debug(e.getMessage());
    8686        }
    8787    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r18757 r18801  
    446446                // add frequently changing info to progress monitor so that it
    447447                // doesn't seem to hang when test takes longer than 0.5 seconds
    448                 if (cnt % 10000 == 0 && stopwatch.elapsed() >= 500) {
     448                if (cnt % 10_000 == 0 && stopwatch.elapsed() >= 500) {
    449449                    progressMonitor.setExtraText(tr(" {0}: {1} of {2} elements done", title, cnt, selection.size()));
    450450                }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java

    r18506 r18801  
    1010import java.util.EnumSet;
    1111import java.util.HashMap;
     12import java.util.HashSet;
    1213import java.util.Iterator;
    1314import java.util.LinkedHashMap;
     
    1617import java.util.List;
    1718import java.util.Map;
     19import java.util.Set;
    1820import java.util.stream.Collectors;
    1921
     
    430432
    431433    private void checkLoop(Relation parent, List<Relation> path) {
    432         if (path.contains(parent)) {
     434        Set<Relation> pathSet = new HashSet<>(path);
     435        if (pathSet.contains(parent)) {
    433436            Iterator<List<Relation>> iter = loops.iterator();
     437            Set<Relation> loop = new HashSet<>();
    434438            while (iter.hasNext()) {
    435                 List<Relation> loop = iter.next();
     439                loop.addAll(iter.next());
    436440                if (loop.size() > path.size() && loop.containsAll(path)) {
    437441                    // remove same loop with irrelevant parent
    438442                    iter.remove();
    439                 } else if (path.size() >= loop.size() && path.containsAll(loop)) {
     443                } else if (path.size() >= loop.size() && pathSet.containsAll(loop)) {
    440444                    // same or smaller loop is already known
    441445                    return;
    442446                }
     447                loop.clear();
    443448            }
    444449            if (path.get(0).equals(parent)) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r18281 r18801  
    915915        }
    916916
    917         if (fixedKey != null && !"".equals(fixedKey) && !fixedKey.equals(key)) {
     917        if (!Utils.isEmpty(fixedKey) && !fixedKey.equals(key)) {
    918918            final String proposedKey = fixedKey;
    919919            // misspelled preset key
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java

    r18176 r18801  
    113113        }
    114114
    115         // #20393 - ways tagged with just area=yes are catched by MapCSS tests
     115        // #20393 - ways tagged with just area=yes are caught by MapCSS tests
    116116        if (!w.isTagged() && !w.hasTag("area", OsmUtils.TRUE_VALUE) && !waysUsedInRelations.contains(w)) {
    117117            if (w.hasKeys()) {
  • trunk/src/org/openstreetmap/josm/data/vector/DataStore.java

    r18305 r18801  
    8080    /**
    8181     * Add a datasource to this data set
    82      * @param dataSource The data soure to add
     82     * @param dataSource The datasource to add
    8383     */
    8484    public void addDataSource(DataSource dataSource) {
  • trunk/src/org/openstreetmap/josm/data/vector/VectorDataStore.java

    r18578 r18801  
    8080                mergeWays(mergedRelation);
    8181            } else if (!(primitive instanceof IWay)) {
    82                 // Can't merge, ever (one of the childs is a node/relation)
     82                // Can't merge, ever (one of the children is a node/relation)
    8383                mergedRelation.remove(JOSM_MERGE_TYPE_KEY);
    8484            }
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r18751 r18801  
    993993
    994994        if (Config.getPref().getBoolean("debug.edt-checker.enable", Version.getInstance().isLocalBuild())) {
    995             // Repaint manager is registered so late for a reason - there is lots of violation during startup process
     995            // Repaint manager is registered so late for a reason - there are lots of violations during startup process
    996996            // but they don't seem to break anything and are difficult to fix
    997997            Logging.info("Enabled EDT checker, wrongful access to gui from non EDT thread will be printed to console");
     
    11911191        UIManager.put("OptionPane.cancelIcon", ImageProvider.getIfAvailable("cancel"));
    11921192        UIManager.put("OptionPane.noIcon", UIManager.get("OptionPane.cancelIcon"));
    1193         // Ensures caret color is the same than text foreground color, see #12257
     1193        // Ensures caret color is the same as text foreground color, see #12257
    11941194        // See https://docs.oracle.com/javase/8/docs/api/javax/swing/plaf/synth/doc-files/componentProperties.html
    11951195        for (String p : Arrays.asList(
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/AbstractListMergeModel.java

    r18221 r18801  
    635635         * participates in the current {@link ComparePairType}
    636636         *
    637          * @return true, if the if the {@link ListRole} of this {@link EntriesTableModel}
     637         * @return true, if the {@link ListRole} of this {@link EntriesTableModel}
    638638         * participates in the current {@link ComparePairType}
    639639         *
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/AbstractListMerger.java

    r17333 r18801  
    775775
    776776        /**
    777          * Java 1.5 doesn't known Action.SELECT_KEY. Wires a toggle button to this action
     777         * Java 1.5 doesn't know Action.SELECT_KEY. Wires a toggle button to this action
    778778         * such that the action gets notified about item state changes and the button gets
    779779         * notified about selection state changes of the action.
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/ComparePairType.java

    r16626 r18801  
    2323
    2424    /**
    25      * compare their version of an {@link org.openstreetmap.josm.data.osm.OsmPrimitive} with the merged veresion
     25     * compare their version of an {@link org.openstreetmap.josm.data.osm.OsmPrimitive} with the merged version
    2626     */
    2727    THEIR_WITH_MERGED(tr("Their with Merged"), THEIR_ENTRIES, MERGED_ENTRIES);
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellEditor.java

    r18221 r18801  
    217217        protected void renderValue(Object value) {
    218218            setFont(UIManager.getFont("ComboBox.font"));
    219             if (String.class.isInstance(value)) {
    220                 setText(String.class.cast(value));
    221             } else if (MultiValueDecisionType.class.isInstance(value)) {
    222                 switch(MultiValueDecisionType.class.cast(value)) {
     219            if (value instanceof String) {
     220                setText((String) value);
     221            } else if (value instanceof MultiValueDecisionType) {
     222                switch((MultiValueDecisionType) value) {
    223223                case UNDECIDED:
    224224                    setText(tr("Choose a value"));
  • trunk/src/org/openstreetmap/josm/gui/correction/CorrectionTable.java

    r10125 r18801  
    3939
    4040        final int correctionsSize = correctionTableModel.getCorrections().size();
    41         final int lines = correctionsSize > MAX_VISIBLE_LINES ? MAX_VISIBLE_LINES : correctionsSize;
     41        final int lines = Math.min(correctionsSize, MAX_VISIBLE_LINES);
    4242        setPreferredScrollableViewportSize(new Dimension(400, lines * getRowHeight()));
    4343        getColumnModel().getColumn(correctionTableModel.getApplyColumn()).setPreferredWidth(40);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java

    r18715 r18801  
    511511
    512512    /**
    513      * Action to undo or redo all commands up to (and including) the seleced item.
     513     * Action to undo or redo all commands up to (and including) the selected item.
    514514     */
    515515    protected class UndoRedoAction extends JosmAction implements IEnabledStateUpdating {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r18792 r18801  
    1414import java.util.Collections;
    1515import java.util.EnumSet;
     16import java.util.HashSet;
    1617import java.util.List;
    1718import java.util.Set;
     
    592593        public void setSelectedRelations(Collection<? extends IRelation<?>> sel) {
    593594            if (!Utils.isEmpty(sel)) {
    594                 if (!getVisibleRelations().containsAll(sel)) {
     595                if (!new HashSet<>(getVisibleRelations()).containsAll(sel)) {
    595596                    resetFilter();
    596597                }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetsInActiveDataLayerListModel.java

    r13434 r18801  
    8282        // is already registered to receive DataChangedEvents from the current edit layer
    8383        DataSet ds = e.getSource().getActiveDataSet();
    84         if (ds != null) {
    85             initFromDataSet(ds);
    86         } else {
    87             initFromDataSet(null);
    88         }
     84        initFromDataSet(ds);
    8985    }
    9086}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/UidInputFieldValidator.java

    r18208 r18801  
    6666        try {
    6767            int uid = Integer.parseInt(value.trim());
    68             if (uid > 0)
    69                 return uid;
    70             return 0;
     68            return Math.max(uid, 0);
    7169        } catch (NumberFormatException e) {
    7270            return 0;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r18692 r18801  
    136136 * If no object is selected, the dialog list is empty.
    137137 * If only one is selected, all tags of this object are selected.
    138  * If more than one object are selected, the sum of all tags are displayed. If the
     138 * If more than one object is selected, the sum of all tags is displayed. If the
    139139 * different objects share the same tag, the shared value is displayed. If they have
    140140 * different values, all of them are put in a combo box and the string "&lt;different&gt;"
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r18793 r18801  
    899899
    900900    /**
    901      * Asks confirmationbefore adding a primitive.
     901     * Asks confirmation before adding a primitive.
    902902     * @param primitive primitive to add
    903903     * @return {@code true} is user confirms the operation, {@code false} otherwise
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java

    r16495 r18801  
    2727import org.openstreetmap.josm.actions.HistoryInfoAction;
    2828import org.openstreetmap.josm.actions.ZoomToAction;
     29import org.openstreetmap.josm.data.osm.IPrimitive;
    2930import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3031import org.openstreetmap.josm.data.osm.Relation;
     
    131132            Collection<RelationMember> sel = getMemberTableModel().getSelectedMembers();
    132133            final Set<OsmPrimitive> toHighlight = sel.stream()
    133                     .filter(r -> r.getMember().isUsable())
    134134                    .map(RelationMember::getMember)
     135                    .filter(IPrimitive::isUsable)
    135136                    .collect(Collectors.toSet());
    136137            SwingUtilities.invokeLater(() -> {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java

    r18556 r18801  
    551551    public Set<OsmPrimitive> getChildPrimitives(Collection<? extends OsmPrimitive> referenceSet) {
    552552        if (referenceSet == null) return null;
     553        Collection<? extends OsmPrimitive> referenceActualSet = referenceSet instanceof Set ?
     554                (Set<? extends OsmPrimitive>) referenceSet : new HashSet<>(referenceSet);
    553555        return members.stream()
    554                 .filter(m -> referenceSet.contains(m.getMember()))
    555556                .map(RelationMember::getMember)
     557                .filter(referenceActualSet::contains)
    556558                .collect(Collectors.toSet());
    557559    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java

    r18208 r18801  
    432432    /**
    433433     * Returns the filter list
    434      * @return the list of primitives used for filtering
     434     * @return the set of primitives used for filtering
    435435     */
    436436    public Set<? extends OsmPrimitive> getFilter() {
  • trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java

    r18265 r18801  
    144144        gc.weightx = 1.0;
    145145        gc.weighty = 1.0;
    146         gc.gridx = 1;
    147146        dlg.add(new JScrollPane(bookmarks), gc);
    148147
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowser.java

    r16694 r18801  
    66import java.awt.BorderLayout;
    77import java.awt.Dimension;
    8 import java.util.Arrays;
     8import java.util.stream.Stream;
    99
    1010import javax.swing.JPanel;
     
    1919
    2020/**
    21  * HistoryBrowser is an UI component which displays history information about an {@link OsmPrimitive}.
     21 * HistoryBrowser is a UI component which displays history information about an {@link OsmPrimitive}.
    2222 *
    2323 * @since 1709
     
    162162            model = null;
    163163        }
    164         Arrays.asList(tagInfoViewer, nodeListViewer, relationMemberListViewer, coordinateInfoViewer).stream()
     164        Stream.of(tagInfoViewer, nodeListViewer, relationMemberListViewer, coordinateInfoViewer)
    165165                .filter(Destroyable.class::isInstance).forEach(Destroyable::destroy);
    166166        tagInfoViewer = null;
  • trunk/src/org/openstreetmap/josm/gui/io/ActionFlagsTableCell.java

    r17308 r18801  
    2727 * handles everything on its own, in other words it renders itself and also functions
    2828 * as editor so the checkboxes may be set by the user.
    29  *
     29 * <p>
    3030 * Intended usage is like this:
    3131 * <code>
     
    3535 * <br>col.setCellEditor(aftc);
    3636 * </code>
    37  *
     37 * <p>
    3838 * Note: Do not use the same object both as <code>TableCellRenderer</code> and
    3939 * <code>TableCellEditor</code> - this can mess up the current editor component
  • trunk/src/org/openstreetmap/josm/gui/io/ChangesetManagementPanel.java

    r18283 r18801  
    5454    private JosmComboBoxModel<Changeset> model;
    5555    private JCheckBox cbCloseAfterUpload;
    56     private JButton btnClose;
    5756
    5857    /**
     
    127126        gc.gridx++;
    128127        CloseChangesetAction closeChangesetAction = new CloseChangesetAction();
    129         btnClose = new JButton(closeChangesetAction);
     128        JButton btnClose = new JButton(closeChangesetAction);
    130129        btnClose.setPreferredSize(prefSize);
    131130        btnClose.setMinimumSize(prefSize);
     
    278277    public void changesetCacheUpdated(ChangesetCacheEvent event) {
    279278        // This listener might have been called by a background task.
    280         SwingUtilities.invokeLater(() -> refreshCombo());
     279        SwingUtilities.invokeLater(this::refreshCombo);
    281280    }
    282281}
  • trunk/src/org/openstreetmap/josm/gui/io/CloseChangesetDialog.java

    r18211 r18801  
    181181     * Sets whether this dialog is canceled
    182182     *
    183      * @param canceled true, if this dialog is canceld
     183     * @param canceled true, if this dialog is canceled
    184184     */
    185185    protected void setCanceled(boolean canceled) {
  • trunk/src/org/openstreetmap/josm/gui/io/CustomConfigurator.java

    r18208 r18801  
    131131     */
    132132    public static void processDownloadOperation(String address, String path, String parentDir, boolean mkdir, boolean unzip) {
    133         String dir = parentDir;
    134133        if (path.contains("..") || path.startsWith("/") || path.contains(":")) {
    135134            return; // some basic protection
    136135        }
    137         File fOut = new File(dir, path);
     136        File fOut = new File(parentDir, path);
    138137        DownloadFileTask downloadFileTask = new DownloadFileTask(MainApplication.getMainFrame(), address, fOut, mkdir, unzip);
    139138
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialogModel.java

    r18283 r18801  
    7676     */
    7777    String findHashTags(String comment) {
    78         String hashtags = String.join(";",
    79             Arrays.stream(comment.split("\\s", -1))
    80                 .map(s -> Utils.strip(s, ",;"))
    81                 .filter(s -> s.matches("#[a-zA-Z0-9][-_a-zA-Z0-9]+"))
    82                 .collect(Collectors.toList()));
     78        String hashtags = Arrays.stream(comment.split("\\s", -1))
     79            .map(s -> Utils.strip(s, ",;"))
     80            .filter(s -> s.matches("#[a-zA-Z0-9][-_a-zA-Z0-9]+"))
     81            .collect(Collectors.joining(";"));
    8382        return hashtags.isEmpty() ? null : hashtags;
    8483    }
     
    156155    public void putAll(Map<String, String> map) {
    157156        commitPendingEdit();
    158         map.forEach((key, value) -> doPut(key, value));
     157        map.forEach(this::doPut);
    159158        setDirty(true);
    160159        fireTableDataChanged();
  • trunk/src/org/openstreetmap/josm/gui/io/importexport/GpxExporter.java

    r18068 r18801  
    7979    @Override
    8080    public boolean acceptFile(File pathname, Layer layer) {
    81         return isSupportedLayer(layer) ? super.acceptFile(pathname, layer) : false;
     81        return isSupportedLayer(layer) && super.acceptFile(pathname, layer);
    8282    }
    8383
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r18652 r18801  
    779779        Logging.debug("zoomChanged(): {0}", currentZoomLevel);
    780780        if (tileLoader instanceof TMSCachedTileLoader) {
    781             ((TMSCachedTileLoader) tileLoader).cancelOutstandingTasks();
     781            tileLoader.cancelOutstandingTasks();
    782782        }
    783783        if (invalidate) {
     
    11491149            StringBuilder ret = new StringBuilder();
    11501150            for (String s: text.split(" ", -1)) {
    1151                 if (g.getFontMetrics().stringWidth(line.toString() + s) > tileSource.getTileSize()) {
     1151                if (g.getFontMetrics().stringWidth(line + s) > tileSource.getTileSize()) {
    11521152                    ret.append(line).append('\n');
    11531153                    line.setLength(0);
  • trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java

    r18127 r18801  
    395395        List<File> result = new ArrayList<>();
    396396        try {
    397             File[] files = autosaveDir.listFiles((FileFilter)
     397            File[] files = autosaveDir.listFiles(
    398398                    pathname -> OsmImporter.FILE_FILTER.accept(pathname) || NoteImporter.FILE_FILTER.accept(pathname));
    399399            if (files == null)
  • trunk/src/org/openstreetmap/josm/gui/layer/MainLayerManager.java

    r18691 r18801  
    2727 * The active layer is the layer the user is currently working on.
    2828 * <p>
    29  * The edit layer is an data layer that we currently work with.
     29 * The edit layer is a data layer that we currently work with.
    3030 * @author Michael Zangl
    3131 * @since 10279
     
    211211
    212212    /**
    213      * Adds a active/edit layer change listener. Fire a fake active-layer-changed-event right after adding
     213     * Adds an active/edit layer change listener. Fire a fake active-layer-changed-event right after adding
    214214     * the listener. The previous layers will be null. The listener is notified in the current thread.
    215215     * @param listener the listener.
  • trunk/src/org/openstreetmap/josm/gui/layer/ValidatorLayer.java

    r16766 r18801  
    101101                .collect(Collectors.joining());
    102102
    103         if (b.length() == 0)
     103        if (b.isEmpty())
    104104            return "<html>" + tr("No validation errors") + "</html>";
    105105        else
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/DateFilterPanel.java

    r17845 r18801  
    107107
    108108    /**
    109      * If possible, load date ragne and "zero timestamp" option from preferences
     109     * If possible, load date range and "zero timestamp" option from preferences
    110110     * Called by other components when it is needed.
    111111     */
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java

    r18211 r18801  
    1010import java.util.ArrayList;
    1111import java.util.Arrays;
    12 import java.util.Collection;
    1312import java.util.Comparator;
     13import java.util.List;
    1414import java.util.stream.Collectors;
    1515
     
    126126        boolean hasTracks = !Utils.isEmpty(layer.data.tracks);
    127127        boolean hasWaypoints = !Utils.isEmpty(layer.data.waypoints);
    128         Collection<WayPoint> waypoints = new ArrayList<>();
     128        List<WayPoint> waypoints = new ArrayList<>();
    129129        boolean timedMarkersOmitted = false;
    130130        boolean untimedMarkersOmitted = false;
     
    273273
    274274        // we must have got at least one waypoint now
    275         ((ArrayList<WayPoint>) waypoints).sort(Comparator.naturalOrder());
     275        waypoints.sort(Comparator.naturalOrder());
    276276
    277277        firstTime = -1.0; // this time of the first waypoint, not first trackpoint
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/ColorfulFilter.java

    r17983 r18801  
    1717
    1818import org.openstreetmap.josm.tools.Logging;
     19import org.openstreetmap.josm.tools.Utils;
    1920
    2021/**
     
    211212    private int mixInt(int color, double luminosity) {
    212213        int val = (int) (colorfulness * color + (1 - colorfulness) * luminosity);
    213         if (val < 0) {
    214             return 0;
    215         } else if (val > 0xff) {
    216             return 0xff;
    217         } else {
    218             return val;
    219         }
     214        return Utils.clamp(val, 0, 0xff);
    220215    }
    221216
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactory.java

    r18414 r18801  
    212212        /**
    213213         * Create a new float operation that compares two float values
    214          * @param comparatorResult A function to mapt the result of the comparison
     214         * @param comparatorResult A function to map the result of the comparison
    215215         */
    216216        Op(IntFunction<Boolean> comparatorResult) {
     
    830830         */
    831831        static boolean unclosed_multipolygon(Environment e) {
    832             return e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon() &&
     832            return e.osm instanceof Relation && e.osm.isMultipolygon() &&
    833833                    !e.osm.isIncomplete() && !((Relation) e.osm).hasIncompleteMembers() &&
    834834                    !MultipolygonCache.getInstance().get((Relation) e.osm).getOpenEnds().isEmpty();
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r18757 r18801  
    712712{
    713713    boolean not = false;
    714     KeyMatchType matchType = null;;
     714    KeyMatchType matchType = null;
    715715    String key;
    716716}
     
    733733    float f;
    734734    int i;
    735     KeyMatchType matchType = null;;
     735    KeyMatchType matchType = null;
    736736    Op op;
    737737    boolean considerValAsKey = false;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleIndex.java

    r16784 r18801  
    149149            }
    150150        } else if (p instanceof IRelation) {
    151             if (((IRelation<?>) p).isMultipolygon()) {
     151            if (p.isMultipolygon()) {
    152152                return multipolygonRules;
    153153            } else if (p.hasKey("#canvas")) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java

    r18502 r18801  
    380380        StringBuilder s = new StringBuilder(64).append("NodeElement{").append(super.toString());
    381381        if (mapImage != null) {
    382             s.append(" icon=[" + mapImage + ']');
     382            s.append(" icon=[").append(mapImage).append(']');
    383383        }
    384384        if (mapImage != null && mapImageAngle != null) {
    385             s.append(" mapImageAngle=[" + mapImageAngle + ']');
     385            s.append(" mapImageAngle=[").append(mapImageAngle).append(']');
    386386        }
    387387        if (symbol != null) {
    388             s.append(" symbol=[" + symbol + ']');
     388            s.append(" symbol=[").append(symbol).append(']');
    389389        }
    390390        s.append('}');
  • trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java

    r17972 r18801  
    199199        for (String setCookie: setCookies) {
    200200            String[] kvPairs = setCookie.split(";", -1);
    201             if (kvPairs.length == 0) {
    202                 continue;
    203             }
    204201            for (String kvPair : kvPairs) {
    205202                kvPair = kvPair.trim();
  • trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    r18471 r18801  
    12501250            if (sc.getAssignedKey() == KeyEvent.CHAR_UNDEFINED) {
    12511251                sc = null;
    1252         }
     1252            }
    12531253        }
    12541254
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AbstractTableListEditor.java

    r16960 r18801  
    108108            TableCellEditor editor = table.getCellEditor();
    109109            if (editor != null) {
    110                 ((DefaultCellEditor) editor).stopCellEditing();
     110                editor.stopCellEditing();
    111111            }
    112112            if (entryList.getSelectedIndices().length != 1) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java

    r17865 r18801  
    223223                    JOptionPane.showMessageDialog(gui, tr("Please select the row to delete."));
    224224                } else {
    225                     Integer i;
     225                    int i;
    226226                    while ((i = list.getSelectedRow()) != -1) {
    227227                        model.removeRow(i);
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryProvidersPanel.java

    r18367 r18801  
    515515        @Override
    516516        public void actionPerformed(ActionEvent e) {
    517             Integer i;
     517            int i;
    518518            while ((i = activeTable.getSelectedRow()) != -1) {
    519519                activeModel.removeRow(i);
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java

    r18213 r18801  
    145145
    146146    /**
    147      * Replies the list of selected plugin information objects
    148      *
    149      * @return the list of selected plugin information objects
     147     * Replies the set of selected plugin information objects
     148     *
     149     * @return the set of selected plugin information objects
    150150     */
    151151    public Set<String> getSelectedPluginNames() {
     
    264264
    265265    /**
    266      * Replies the set of plugins which have been added by the user to
     266     * Replies the list of plugins which have been added by the user to
    267267     * the set of activated plugins.
    268268     *
    269      * @return the set of newly activated plugins
     269     * @return the list of newly activated plugins
    270270     */
    271271    public List<PluginInformation> getNewlyActivatedPlugins() {
     
    282282
    283283    /**
    284      * Replies the set of plugins which have been removed by the user from
     284     * Replies the list of plugins which have been removed by the user from
    285285     * the set of deactivated plugins.
    286286     *
    287      * @return the set of newly deactivated plugins
     287     * @return the list of newly deactivated plugins
    288288     */
    289289    public List<PluginInformation> getNewlyDeactivatedPlugins() {
     
    295295
    296296    /**
    297      * Replies the set of all available plugins.
    298      *
    299      * @return the set of all available plugins
     297     * Replies the list of all available plugins.
     298     *
     299     * @return the list of all available plugins
    300300     */
    301301    public List<PluginInformation> getAvailablePlugins() {
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginUpdatePolicyPanel.java

    r16438 r18801  
    187187
    188188    /**
    189      * Remebers the update policy preference settings on the JOSM preferences
     189     * Remembers the update policy preference settings on the JOSM preferences
    190190     */
    191191    public void rememberInPreferences() {
  • trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/PrefJPanel.java

    r18436 r18801  
    9797                    int i = field.getInt(null);
    9898                    String s = KeyEvent.getKeyText(i);
    99                     if (s != null && s.length() > 0 && !s.contains(unknown)) {
     99                    if (s != null && !s.isEmpty() && !s.contains(unknown)) {
    100100                        list.put(Integer.valueOf(i), s);
    101101                    }
  • trunk/src/org/openstreetmap/josm/gui/progress/ProgressMonitor.java

    r12369 r18801  
    7676
    7777    /**
    78      * Can be used if method receive ProgressMonitor but it's not interested progress monitoring.
     78     * Can be used if method receives ProgressMonitor, but it's not interested progress monitoring.
    7979     * Basically replaces {@link #beginTask(String)} and {@link #finishTask()}
    8080     *
    81      * This method can be also used in finally section if method expects that some exception
     81     * This method can be also used in finally section if method expects that some exceptions
    8282     * might prevent it from passing progressMonitor away. If {@link #beginTask(String)} was
    8383     * already called then this method does nothing.
  • trunk/src/org/openstreetmap/josm/gui/progress/swing/PleaseWaitProgressMonitor.java

    r17333 r18801  
    107107
    108108    private void doInEDT(Runnable runnable) {
    109         // This must be invoke later even if current thread is EDT because inside there is dialog.setVisible
     109        // This must be invoked later even if current thread is EDT because inside there is dialog.setVisible
    110110        // which freeze current code flow until modal dialog is closed
    111111        SwingUtilities.invokeLater(() -> {
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java

    r18283 r18801  
    531531    public List<String> getKeys() {
    532532        return tags.stream()
    533                 .filter(tag -> !Utils.isStripEmpty(tag.getName()))
    534533                .map(TagModel::getName)
     534                .filter(name -> !Utils.isStripEmpty(name))
    535535                .collect(Collectors.toList());
    536536    }
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompEvent.java

    r18221 r18801  
    55
    66/**
    7  * This event is generated by an AutoCompTextField when an autocomplete occured.
     7 * This event is generated by an AutoCompTextField when an autocomplete occurred.
    88 *
    99 * @see AutoCompTextField
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java

    r18305 r18801  
    1515import java.util.Objects;
    1616import java.util.Set;
    17 import java.util.function.Function;
    1817import java.util.stream.Collectors;
    1918
     
    4241import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset;
    4342import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    44 import org.openstreetmap.josm.gui.tagging.presets.items.Roles.Role;
    4543import org.openstreetmap.josm.tools.CheckParameterUtil;
    4644import org.openstreetmap.josm.tools.MultiMap;
     
    294292            for (TaggingPreset tp : presets) {
    295293                if (tp.roles != null) {
    296                     list.add(Utils.transform(tp.roles.roles, (Function<Role, String>) x -> x.key), AutoCompletionPriority.IS_IN_STANDARD);
     294                    list.add(Utils.transform(tp.roles.roles, x -> x.key), AutoCompletionPriority.IS_IN_STANDARD);
    297295                }
    298296            }
     
    427425     * @param keys the tag keys
    428426     * @param comparator the custom comparator used to sort the list
    429      * @return a set of tag values
     427     * @return a list of tag values
    430428     * @since 12859
    431429     */
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItemGuiSupport.java

    r18260 r18801  
    2525
    2626    private final Collection<OsmPrimitive> selected;
    27     /** True if all selected primitives matched this preset at the moment it was openend. */
     27    /** True if all selected primitives matched this preset at the moment it was opened. */
    2828    private final boolean presetInitiallyMatches;
    2929    private final Supplier<Collection<Tag>> changedTagsSupplier;
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java

    r18260 r18801  
    1111import java.util.Arrays;
    1212import java.util.Collection;
    13 import java.util.Collections;
    1413import java.util.List;
    1514import java.util.Map;
     
    154153     *      must be escaped within one entry
    155154     * @param s the string
    156      * @return splitted items
     155     * @return split items
    157156     */
    158157    public static List<String> splitEscaped(char delimiter, String s) {
     
    312311
    313312        if (values_sort && TaggingPresets.SORT_MENU.get()) {
    314             Collections.sort(presetListEntries, (a, b) -> AlphanumComparator.getInstance().compare(a.getDisplayValue(), b.getDisplayValue()));
     313            presetListEntries.sort((a, b) -> AlphanumComparator.getInstance().compare(a.getDisplayValue(), b.getDisplayValue()));
    315314        }
    316315    }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/PresetLink.java

    r18221 r18801  
    4646
    4747    /**
    48      * Creates a label to be inserted aboive this link
     48     * Creates a label to be inserted above this link
    4949     * @return a label
    5050     */
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/PresetListEntry.java

    r18648 r18801  
    7676     *
    7777     * This is the contents that would be displayed in the current view plus a short description to
    78      * aid the user.  The whole contents is wrapped to {@code width}.
     78     * aid the user. The whole content is wrapped to {@code width}.
    7979     *
    8080     * @param width the width in px
     
    8383    public String getListDisplay(int width) {
    8484        String displayValue = getDisplayValue();
    85         Integer count = getCount();
     85        int count = getCount();
    8686
    8787        if (count > 0 && cms.usage.getSelectedCount() > 1) {
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java

    r18313 r18801  
    7979        keys.add(key);
    8080        if (alternative_autocomplete_keys != null) {
    81             for (String k : alternative_autocomplete_keys.split(",", -1)) {
    82                 keys.add(k);
    83             }
     81            Collections.addAll(keys, alternative_autocomplete_keys.split(",", -1));
    8482        }
    8583        getAllForKeys(keys).forEach(model::addElement);
     
    270268     * Set the value template.
    271269     * @param pattern The value_template pattern.
    272      * @throws SAXException If an error occured while parsing.
     270     * @throws SAXException If an error occurred while parsing.
    273271     */
    274272    public void setValue_template(String pattern) throws SAXException { // NOPMD
  • trunk/src/org/openstreetmap/josm/gui/util/imagery/Vector3D.java

    r18255 r18801  
    138138
    139139    /**
    140      * Get the polar angle cossine (inclination)
     140     * Get the polar angle cosine (inclination)
    141141     *
    142142     * @return The polar angle cosine
  • trunk/src/org/openstreetmap/josm/gui/widgets/AbstractFileChooser.java

    r18113 r18801  
    8181     * Returns a list of selected files if the file chooser is
    8282     * set to allow multiple selection.
    83      * @return a list of selected files if the file chooser is
     83     * @return an array of selected files if the file chooser is
    8484     * set to allow multiple selection, or an empty array otherwise.
    8585     */
     
    9898     * If false, the <code>AcceptAll</code> file filter is removed from
    9999     * the list of available file filters.
    100      * If true, the <code>AcceptAll</code> file filter will become the
     100     * If true, the <code>AcceptAll</code> file filter will become
    101101     * the actively used file filter.
    102102     * @param b whether the <code>AcceptAll FileFilter</code> is used
  • trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitLayout.java

    r16630 r18801  
    119119
    120120    /**
    121      * Replies list of property change listeners.
    122      * @return list of property change listeners
     121     * Replies array of property change listeners.
     122     * @return array of property change listeners
    123123     */
    124124    public PropertyChangeListener[] getPropertyChangeListeners() {
     
    10651065            StringBuilder sb = new StringBuilder("MultiSplitLayout.Split");
    10661066            sb.append(isRowLayout() ? " ROW [" : " COLUMN [")
    1067               .append(nChildren + ((nChildren == 1) ? " child" : " children"))
     1067              .append(nChildren)
     1068              .append((nChildren == 1) ? " child" : " children")
    10681069              .append("] ")
    10691070              .append(getBounds());
  • trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java

    r18208 r18801  
    265265     * <code>d</code> d is a date relative to the current time zone.
    266266     *
    267      * @param d the date . Must not be null.
     267     * @param d the date. Must not be null.
    268268     * @return the restricted changeset query
    269269     * @throws IllegalArgumentException if d is null
     
    570570         * see <a href="http://wiki.openstreetmap.org/wiki/API_v0.6#Query:_GET_.2Fapi.2F0.6.2Fchangesets">OSM API</a>.
    571571         *
    572          * Example for an query string:<br>
     572         * Example for a query string:<br>
    573573         * <pre>
    574574         *    uid=1234&amp;open=true
  • trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java

    r18663 r18801  
    6060     * is defined <strong>at startup</strong>. It has no effect if the property is set
    6161     * later by the application.
    62      *
    63      * We therefore read the property at class loading time and remember it's value.
     62     * <p>
     63     * We therefore read the property at class loading time and remember its value.
    6464     */
    6565    private static boolean jvmWillUseSystemProxies;
  • trunk/src/org/openstreetmap/josm/io/DiffResultProcessor.java

    r18623 r18801  
    105105    /**
    106106     * Postprocesses the diff result read and parsed from the server.
    107      *
     107     * <p>
    108108     * Uploaded objects are assigned their new id (if they got assigned a new
    109109     * id by the server), their new version (if the version was incremented),
  • trunk/src/org/openstreetmap/josm/io/IGpxReader.java

    r18179 r18801  
    3333
    3434    /**
    35      * Returns the number of coordinates that have been successfuly read.
    36      * @return the number of coordinates that have been successfuly read
     35     * Returns the number of coordinates that have been successfully read.
     36     * @return the number of coordinates that have been successfully read
    3737     * @since 18179
    3838     */
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r18779 r18801  
    809809                    errorHeader = response.getHeaderField("Error");
    810810                    Logging.error("Error header: " + errorHeader);
    811                 } else if (retCode != HttpURLConnection.HTTP_OK && responseBody.length() > 0) {
     811                } else if (retCode != HttpURLConnection.HTTP_OK && !responseBody.isEmpty()) {
    812812                    Logging.error("Error body: " + responseBody);
    813813                }
     
    815815
    816816                errorHeader = errorHeader == null ? null : errorHeader.trim();
    817                 String errorBody = responseBody.length() == 0 ? null : responseBody.trim();
     817                String errorBody = responseBody.isEmpty() ? null : responseBody.trim();
    818818                switch(retCode) {
    819819                case HttpURLConnection.HTTP_OK:
  • trunk/src/org/openstreetmap/josm/io/OsmReader.java

    r18695 r18801  
    487487
    488488    /**
    489      * Exception thrown after user cancelation.
     489     * Exception thrown after user cancellation.
    490490     */
    491491    private static final class OsmParsingCanceledException extends XmlStreamParsingException implements ImportCancelException {
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r18780 r18801  
    509509                        }
    510510                        // TODO should we handle also POST?
    511                         if ("GET".equalsIgnoreCase(mode) && getMapUrl != null && !"".equals(getMapUrl)) {
     511                        if ("GET".equalsIgnoreCase(mode) && getMapUrl != null && !getMapUrl.isEmpty()) {
    512512                            try {
    513513                                String query = new URL(getMapUrl).getQuery();
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java

    r18211 r18801  
    160160
    161161    /**
    162      * Returns usage examples for the given command. To be overriden only my handlers that define several commands.
     162     * Returns usage examples for the given command. To be overridden only my handlers that define several commands.
    163163     * @param cmd The command asked
    164164     * @return Usage examples for the given command
     
    203203        if (GLOBAL_CONFIRMATION.get()) {
    204204            // Ensure dialog box does not exceed main window size
    205             Integer maxWidth = (int) Math.max(200, MainApplication.getMainFrame().getWidth()*0.6);
     205            int maxWidth = (int) Math.max(200, MainApplication.getMainFrame().getWidth() * 0.6);
    206206            String message = "<html><div>" + getPermissionMessage() +
    207207                    "<br/>" + tr("Do you want to allow this?") + "</div></html>";
     
    357357        DownloadParams result = new DownloadParams();
    358358        if (args != null) {
    359             result = result
    360                 .withNewLayer(isLoadInNewLayer())
    361                 .withLayerName(args.get("layer_name"))
    362                 .withLocked(get("layer_locked"))
    363                 .withDownloadPolicy(get("download_policy", DownloadPolicy::of, () -> DownloadPolicy.NORMAL))
    364                 .withUploadPolicy(get("upload_policy", UploadPolicy::of, () -> UploadPolicy.NORMAL));
     359            result.withNewLayer(isLoadInNewLayer())
     360                    .withLayerName(args.get("layer_name"))
     361                    .withLocked(get("layer_locked"))
     362                    .withDownloadPolicy(get("download_policy", DownloadPolicy::of, () -> DownloadPolicy.NORMAL))
     363                    .withUploadPolicy(get("upload_policy", UploadPolicy::of, () -> UploadPolicy.NORMAL));
    365364        }
    366365        return result;
     
    498497
    499498    /**
    500      * Handler that takes an URL as parameter.
     499     * Handler that takes a URL as a parameter.
    501500     */
    502501    public abstract static class RawURLParseRequestHandler extends RequestHandler {
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r18792 r18801  
    1414import java.awt.event.ActionEvent;
    1515import java.io.File;
    16 import java.io.FilenameFilter;
    1716import java.io.IOException;
    1817import java.net.MalformedURLException;
     
    468467            long tim = System.currentTimeMillis();
    469468            long last = Config.getPref().getLong("pluginmanager.lastupdate", 0);
    470             Integer maxTime = Config.getPref().getInt("pluginmanager.time-based-update.interval", DEFAULT_TIME_BASED_UPDATE_INTERVAL);
     469            int maxTime = Config.getPref().getInt("pluginmanager.time-based-update.interval", DEFAULT_TIME_BASED_UPDATE_INTERVAL);
    471470            long d = TimeUnit.MILLISECONDS.toDays(tim - last);
    472471            if ((last <= 0) || (maxTime <= 0)) {
     
    977976     *
    978977     * @param monitor the progress monitor. Defaults to {@link NullProgressMonitor#INSTANCE} if null.
    979      * @return the list of locally available plugin information, null in case of errors
     978     * @return the map of locally available plugin information, null in case of errors
    980979     *
    981980     */
     
    10281027
    10291028    /**
    1030      * Builds the set of plugins to load. Deprecated and unmaintained plugins are filtered
     1029     * Builds the list of plugins to load. Deprecated and unmaintained plugins are filtered
    10311030     * out. This involves user interaction. This method displays alert and confirmation
    10321031     * messages.
     
    10341033     * @param parent The parent component to be used for the displayed dialog
    10351034     * @param monitor the progress monitor. Defaults to {@link NullProgressMonitor#INSTANCE} if null.
    1036      * @return the set of plugins to load (as set of plugin names)
     1035     * @return the list of plugins to load (as set of plugin names)
    10371036     */
    10381037    public static List<PluginInformation> buildListOfPluginsToLoad(Component parent, ProgressMonitor monitor) {
     
    13491348            return;
    13501349
    1351         final File[] files = pluginDir.listFiles((FilenameFilter) (dir, name) -> name.endsWith(".jar.new"));
     1350        final File[] files = pluginDir.listFiles((dir, name) -> name.endsWith(".jar.new"));
    13521351        if (files == null)
    13531352            return;
  • trunk/src/org/openstreetmap/josm/tools/ColorScale.java

    r18738 r18801  
    249249        fh = fm.getHeight()/2;
    250250        if (colorBarTitles != null && colorBarTitles.length > 0) {
    251              fw = Arrays.asList(colorBarTitles).stream().mapToInt(title -> fm.stringWidth(title)).max().orElse(50);
     251             fw = Arrays.stream(colorBarTitles).mapToInt(fm::stringWidth).max().orElse(50);
    252252        } else {
    253253            fw = fm.stringWidth(
  • trunk/src/org/openstreetmap/josm/tools/Destroyable.java

    r10600 r18801  
    44/**
    55 * Some objects like layers (when they are removed) or the whole map frame (when the last layer has
    6  * been removed) have an definite set of actions to execute. This is the "destructor" interface called
     6 * been removed) have a definite set of actions to execute. This is the "destructor" interface called
    77 * on those objects.
    88 *
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r18675 r18801  
    9797     *              Will be filled with commands that add intersection nodes to
    9898     *              the ways.
    99      * @return list of new nodes, if test is true the list might not contain all intersections
     99     * @return set of new nodes, if test is true the list might not contain all intersections
    100100     */
    101101    public static Set<Node> addIntersections(List<Way> ways, boolean test, List<Command> cmds) {
     
    131131                List<Node> way2Nodes = newNodes[seg2Way];
    132132
    133                 //iterate over primary segmemt
     133                //iterate over primary segment
    134134                for (int seg1Pos = 0; seg1Pos + 1 < way1Nodes.size(); seg1Pos++) {
    135135
     
    351351
    352352    /**
    353      * Get the segment segment intersection of two line segments
     353     * Get the segment-segment intersection of two line segments
    354354     * @param x1 The x coordinate of the first point (first segment)
    355355     * @param y1 The y coordinate of the first point (first segment)
     
    833833        if (osm instanceof Way && ((Way) osm).isClosed()) {
    834834            return closedWayArea((Way) osm);
    835         } else if (osm instanceof Relation && ((Relation) osm).isMultipolygon() && !((Relation) osm).hasIncompleteMembers()) {
     835        } else if (osm instanceof Relation && osm.isMultipolygon() && !((Relation) osm).hasIncompleteMembers()) {
    836836            return multipolygonArea((Relation) osm);
    837837        } else {
     
    922922
    923923    /**
    924      * Get angles in radians and return it's value in range [0, 180].
     924     * Get angles in radians and return its value in range [0, 180].
    925925     *
    926926     * @param angle the angle in radians
     
    993993
    994994    /**
    995      * Compute center of the circle closest to different nodes.
     995     * Compute the center of the circle closest to different nodes.
    996996     *
    997997     * Ensure exact center computation in case nodes are already aligned in circle.
  • trunk/src/org/openstreetmap/josm/tools/GuiSizesHelper.java

    r16486 r18801  
    1111 * Support class to handle size information of Gui elements
    1212 * This is needed, because display resolution may vary a lot and a common set
    13  * of sizes wont work for all users alike.
     13 * of sizes won't work for all users alike.
    1414 * @since 12682 (moved from {@code gui.util} package)
    1515 * @since 10358
     
    2222
    2323    /** cache value for screen resolution */
    24     private static float screenDPI = -1;
     24    private static volatile float screenDPI = -1;
    2525
    2626    /**
  • trunk/src/org/openstreetmap/josm/tools/HttpClient.java

    r18656 r18801  
    3636
    3737/**
    38  * Provides a uniform access for a HTTP/HTTPS server. This class should be used in favour of {@link HttpURLConnection}.
     38 * Provides uniform access for a HTTP/HTTPS server. This class should be used in favour of {@link HttpURLConnection}.
    3939 * @since 9168
    4040 */
  • trunk/src/org/openstreetmap/josm/tools/OptionParser.java

    r16913 r18801  
    280280
    281281        /**
    282          * Called once if the parameter is encountered, afer basic validation.
     282         * Called once if the parameter is encountered, after basic validation.
    283283         * @param parameter The parameter if {@link #requiresParameter()} is true, <code>null</code> otherwise.
    284284         */
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java

    r18580 r18801  
    487487                        Logging.warn("extended font config - overriding ''{0}={1}'' with ''{2}''", key, prevValue, value);
    488488                    }
    489                     w.append(key + '=' + value + '\n');
     489                    w.append(key).append('=').append(value).append('\n');
    490490                }
    491491                w.append('\n');
     
    500500                        Logging.warn("extended font config - overriding ''{0}={1}'' with ''{2}''", key, prevValue, value);
    501501                    }
    502                     w.append(key + '=' + value + '\n');
     502                    w.append(key).append('=').append(value).append('\n');
    503503                }
    504504                w.append('\n');
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r18116 r18801  
    267267        if (keyStroke == null) return "";
    268268        String modifText = KeyEvent.getModifiersExText(keyStroke.getModifiers());
    269         if ("".equals(modifText)) return KeyEvent.getKeyText(keyStroke.getKeyCode());
     269        if (modifText.isEmpty()) return KeyEvent.getKeyText(keyStroke.getKeyCode());
    270270        return modifText + '+' + KeyEvent.getKeyText(keyStroke.getKeyCode());
    271271    }
     
    522522    private static Shortcut registerShortcut(String shortText, String longText, int requestedKey, int requestedGroup, Integer modifier) {
    523523        doInit();
    524         Integer defaultModifier = findModifier(requestedGroup, modifier);
     524        int defaultModifier = findModifier(requestedGroup, modifier);
    525525        final Optional<Shortcut> existing = findShortcutByKeyOrShortText(requestedKey, defaultModifier, shortText);
    526526        if (existing.isPresent() && shortText.equals(existing.get().getShortText())) {
  • trunk/src/org/openstreetmap/josm/tools/Territories.java

    r18723 r18801  
    200200                    for (JsonValue feature : json.getObject().getJsonArray("features")) {
    201201                        ofNullable(feature.asJsonObject().getJsonObject("properties")).ifPresent(props ->
    202                         ofNullable(props.getJsonObject("urls")).ifPresent(urls ->
    203                         ofNullable(urls.getString(TAGINFO)).ifPresent(taginfo -> {
     202                        ofNullable(props.getJsonObject("urls")).flatMap(urls ->
     203                        ofNullable(urls.getString(TAGINFO))).ifPresent(taginfo -> {
    204204                            JsonArray iso1 = props.getJsonArray(ISO3166_1_LC);
    205205                            JsonArray iso2 = props.getJsonArray(ISO3166_2_LC);
     
    209209                                readExternalTaginfo(taginfoGeofabrikCache, taginfo, iso2, source);
    210210                            }
    211                         })));
     211                        }));
    212212                    }
    213213                }
  • trunk/src/org/openstreetmap/josm/tools/TextAnalyzer.java

    r13544 r18801  
    8282                    s.append(c); // just add ", not open
    8383                } else {
    84                     s.delete(0, s.length()); // forget that empty characthers and start reading "....
     84                    s.delete(0, s.length()); // forget that empty characters and start reading "....
    8585                    quotesStarted = true;
    8686                }
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r18580 r18801  
    174174
    175175    /**
    176      * Return the modulus in the range [0, n)
    177      * @param a dividend
    178      * @param n divisor
    179      * @return modulo (remainder of the Euclidian division of a by n)
     176     * Returns the modulo in the range [0, n) for the given dividend and divisor.
     177     * @param a the dividend
     178     * @param n the divisor
     179     * @return the modulo, which is the remainder of the Euclidean division of a by n, in the range [0, n)
     180     * @throws IllegalArgumentException if n is less than or equal to 0
    180181     */
    181182    public static int mod(int a, int n) {
    182183        if (n <= 0)
    183             throw new IllegalArgumentException("n must be <= 0 but is "+n);
     184            throw new IllegalArgumentException("n must be <= 0 but is " + n);
    184185        int res = a % n;
    185186        if (res < 0) {
     
    290291     * @param in The source directory
    291292     * @param out The destination directory
    292      * @throws IOException if any I/O error ooccurs
     293     * @throws IOException if any I/O error occurs
    293294     * @throws IllegalArgumentException if {@code in} or {@code out} is {@code null}
    294295     * @since 7835
     
    10051006
    10061007    /**
    1007      * Cast an object savely.
     1008     * Cast an object safely.
    10081009     * @param <T> the target type
    10091010     * @param o the object to cast
     
    10881089     * @param <T> type of elements
    10891090     * @param elements collection to shorten
    1090      * @param maxElements maximum number of elements to keep (including including the {@code overflowIndicator})
     1091     * @param maxElements maximum number of elements to keep (including the {@code overflowIndicator})
    10911092     * @param overflowIndicator the element used to indicate that the collection has been shortened
    10921093     * @return the shortened collection
     
    17621763        int pPos = version.indexOf('+');
    17631764        try {
    1764             return Integer.parseInt(version.substring(bPos > -1 ? bPos + 1 : pPos + 1, version.length()));
     1765            return Integer.parseInt(version.substring(bPos > -1 ? bPos + 1 : pPos + 1));
    17651766        } catch (NumberFormatException e) {
    17661767            Logging.trace(e);
     
    18281829    /**
    18291830     * Determines if a class can be found for the given name.
    1830      * @param className class nmae to find
     1831     * @param className class name to find
    18311832     * @return {@code true} if the class can be found, {@code false} otherwise
    18321833     * @since 17692
     
    19211922
    19221923    /**
    1923      * Convenient method to open an URL stream, using JOSM HTTP client if neeeded.
     1924     * Convenient method to open an URL stream, using JOSM HTTP client if needed.
    19241925     * @param url URL for reading from
    19251926     * @return an input stream for reading from the URL
  • trunk/src/org/openstreetmap/josm/tools/WikiReader.java

    r16436 r18801  
    137137                // add a border="0" attribute to images, otherwise the internal help browser
    138138                // will render a thick  border around images inside an <a> element
    139                 // remove width information to avoid distorded images (fix #11262)
     139                // remove width information to avoid distorted images (fix #11262)
    140140                b.append(line.replace("<img ", "<img border=\"0\" ")
    141141                         .replaceAll("width=\"(\\d+)\"", "")
  • trunk/src/org/openstreetmap/josm/tools/template_engine/TemplateParser.java

    r13206 r18801  
    55
    66import java.util.ArrayList;
    7 import java.util.Arrays;
    87import java.util.Collection;
     8import java.util.Collections;
    99import java.util.List;
    1010
     
    2121    private final Tokenizer tokenizer;
    2222
    23     private static final Collection<TokenType> EXPRESSION_END_TOKENS = Arrays.asList(TokenType.EOF);
    24     private static final Collection<TokenType> CONDITION_WITH_APOSTROPHES_END_TOKENS = Arrays.asList(TokenType.APOSTROPHE);
     23    private static final Collection<TokenType> EXPRESSION_END_TOKENS = Collections.singletonList(TokenType.EOF);
     24    private static final Collection<TokenType> CONDITION_WITH_APOSTROPHES_END_TOKENS = Collections.singletonList(TokenType.APOSTROPHE);
    2525
    2626    /**
  • trunk/test/unit/org/openstreetmap/josm/data/protobuf/ProtobufPackedTest.java

    r18695 r18801  
    33
    44import static org.junit.jupiter.api.Assertions.assertArrayEquals;
    5 
    6 import java.io.ByteArrayOutputStream;
    75
    86import org.junit.jupiter.api.Test;
     
    1412    @Test
    1513    void testSingleByteNumbers() {
    16         long[] numbers = new ProtobufPacked(new ByteArrayOutputStream(), ProtobufTest.toByteArray(new int[]{0, 0, 1, 1, 2, 2, 3, 3, 4, 4}))
     14        long[] numbers = new ProtobufPacked(ProtobufTest.toByteArray(new int[]{0, 0, 1, 1, 2, 2, 3, 3, 4, 4}))
    1715                .getArray();
    1816        assertArrayEquals(new long[] {0, 0, 1, 1, 2, 2, 3, 3, 4, 4}, numbers);
     
    2220    void testMultipleByteNumbers() {
    2321        byte[] bytes = ProtobufTest.toByteArray(new int[] {-128, 64, -18, 49, -70, 3});
    24         long[] numbers = new ProtobufPacked(new ByteArrayOutputStream(), bytes).getArray();
     22        long[] numbers = new ProtobufPacked(bytes).getArray();
    2523        assertArrayEquals(new long[] {8192, 6382, 442}, numbers);
    2624    }
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/DirectionNodesTest.java

    r18690 r18801  
    1010
    1111/**
    12  * JUnit Test of Multipolygon validation test.
     12 * JUnit Test of {@link DirectionNodes} validation test.
    1313 */
    1414class DirectionNodesTest {
    15 
    1615
    1716    /**
     
    2726     */
    2827    @Test
    29     void testDirectionsNodesTestFile() throws Exception {
     28    void testDirectionNodesTestFile() throws Exception {
    3029        final DirectionNodes test = new DirectionNodes();
    3130        ValidatorTestUtils.testSampleFile("nodist/data/direction-nodes.osm", DataSet::getNodes, null, test);
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/SelfIntersectingWayTest.java

    r18690 r18801  
    2323
    2424/**
    25  * JUnit Test of Multipolygon validation test.
     25 * JUnit Test of {@link SelfIntersectingWay} validation test.
    2626 */
    2727class SelfIntersectingWayTest {
  • trunk/test/unit/org/openstreetmap/josm/io/GpxReaderTest.java

    r18037 r18801  
    77
    88import java.io.ByteArrayInputStream;
    9 import java.io.File;
    109import java.io.FileInputStream;
    1110import java.io.IOException;
     
    3938    public static GpxData parseGpxData(String filename) throws IOException, SAXException {
    4039        final GpxData result;
    41         try (FileInputStream in = new FileInputStream(new File(filename))) {
     40        try (FileInputStream in = new FileInputStream(filename)) {
    4241            GpxReader reader = new GpxReader(in);
    4342            assertTrue(reader.parse(false));
  • trunk/test/unit/org/openstreetmap/josm/testutils/mockers/EDTAssertionMocker.java

    r17090 r18801  
    1717        final Throwable cause = t.getCause();
    1818        if (cause instanceof AssertionError) {
    19             throw (AssertionError) cause;
     19            throw cause;
    2020        }
    2121
Note: See TracChangeset for help on using the changeset viewer.