Ignore:
Timestamp:
2023-08-09T15:30:01+02:00 (3 years 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)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.