Changeset 10721 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2016-08-03T17:54:36+02:00 (8 years ago)
Author:
simon04
Message:

Remove too specific Utils functions

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/SimilarNamedWays.java

    r10680 r10721  
    2424import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    2525import org.openstreetmap.josm.tools.MultiMap;
    26 import org.openstreetmap.josm.tools.Utils;
    2726
    2827/**
     
    158157
    159158                // Step 6
    160                 d[i][j] = Utils.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
     159                d[i][j] = Math.min(Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1), d[i - 1][j - 1] + cost);
    161160            }
    162161        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java

    r10680 r10721  
    77import java.awt.Stroke;
    88import java.util.Objects;
     9import java.util.stream.IntStream;
    910
    1011import org.openstreetmap.josm.Main;
     
    324325                }
    325326
    326                 final int size = Utils.max(selected ? settings.getSelectedNodeSize() : 0,
     327                final int size = max(
     328                        selected ? settings.getSelectedNodeSize() : 0,
    327329                        n.isTagged() ? settings.getTaggedNodeSize() : 0,
    328330                        isConnection ? settings.getConnectionNodeSize() : 0,
     
    350352            // This is only executed once, so no performance concerns.
    351353            // However, it would be better, if the settings could be changed at runtime.
    352             int size = Utils.max(
     354            int size = max(
    353355                    Main.pref.getInteger("mappaint.node.selected-size", 5),
    354356                    Main.pref.getInteger("mappaint.node.unselected-size", 3),
     
    358360            return new SimpleBoxProvider(new Rectangle(-size/2, -size/2, size, size));
    359361        }
     362    }
     363
     364    private static int max(int... elements) {
     365        return IntStream.of(elements).max().orElseThrow(IllegalStateException::new);
    360366    }
    361367
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r10718 r10721  
    223223
    224224    /**
    225      * Returns the minimum of three values.
    226      * @param   a   an argument.
    227      * @param   b   another argument.
    228      * @param   c   another argument.
    229      * @return  the smaller of {@code a}, {@code b} and {@code c}.
    230      */
    231     public static int min(int a, int b, int c) {
    232         if (b < c) {
    233             if (a < b)
    234                 return a;
    235             return b;
    236         } else {
    237             if (a < c)
    238                 return a;
    239             return c;
    240         }
    241     }
    242 
    243     /**
    244      * Returns the greater of four {@code int} values. That is, the
    245      * result is the argument closer to the value of
    246      * {@link Integer#MAX_VALUE}. If the arguments have the same value,
    247      * the result is that same value.
    248      *
    249      * @param   a   an argument.
    250      * @param   b   another argument.
    251      * @param   c   another argument.
    252      * @param   d   another argument.
    253      * @return  the larger of {@code a}, {@code b}, {@code c} and {@code d}.
    254      */
    255     public static int max(int a, int b, int c, int d) {
    256         return Math.max(Math.max(a, b), Math.max(c, d));
    257     }
    258 
    259     /**
    260225     * Ensures a logical condition is met. Otherwise throws an assertion error.
    261226     * @param condition the condition to be met
     
    565530     */
    566531    public static void close(ZipFile zip) {
    567         if (zip == null) return;
    568         try {
    569             zip.close();
    570         } catch (IOException e) {
    571             Main.warn(e);
    572         }
     532        close((Closeable) zip);
    573533    }
    574534
Note: See TracChangeset for help on using the changeset viewer.