Changeset 15736 in josm


Ignore:
Timestamp:
2020-01-19T23:02:13+01:00 (4 years ago)
Author:
simon04
Message:

Java 8: simplify Stream API usage

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r15693 r15736  
    412412            }
    413413            if (!i.serverProjections.isEmpty()) {
    414                 projections = i.serverProjections.stream().collect(Collectors.joining(","));
     414                projections = String.join(",", i.serverProjections);
    415415            }
    416416            if (i.noTileHeaders != null && !i.noTileHeaders.isEmpty()) {
  • trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java

    r14399 r15736  
    77import java.text.DecimalFormatSymbols;
    88import java.text.NumberFormat;
     9import java.util.Arrays;
    910import java.util.Locale;
    1011import java.util.Map;
     
    170171        Matcher m = PATTERN_PARAM.matcher(url);
    171172        while (m.find()) {
    172             boolean isSupportedPattern = false;
    173             for (Pattern pattern : ALL_PATTERNS) {
    174                 if (pattern.matcher(m.group()).matches()) {
    175                     isSupportedPattern = true;
    176                     break;
    177                 }
    178             }
     173            boolean isSupportedPattern = Arrays.stream(ALL_PATTERNS)
     174                    .anyMatch(pattern -> pattern.matcher(m.group()).matches());
    179175            if (!isSupportedPattern) {
    180176                throw new IllegalArgumentException(
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/UrlBasedQueryPanel.java

    r14119 r15736  
    9292                + "<p><strong>" + tr("Examples") + "</strong></p>"
    9393                + "<ul>"
    94                 + String.join("", getExamples().stream().map(
    95                         s -> "<li><a href=\""+s+"\">"+s+"</a></li>").collect(Collectors.toList()))
     94                + getExamples().stream()
     95                        .map(s -> "<li><a href=\""+s+"\">"+s+"</a></li>")
     96                        .collect(Collectors.joining(""))
    9697                + "</ul>"
    9798                + tr("Note that changeset queries are currently always submitted to ''{0}'', regardless of the "
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r15646 r15736  
    305305        if (Logging.isDebugEnabled() && !data.getLayerPrefs().isEmpty()) {
    306306            info.append("<br><br>")
    307                 .append(String.join("<br>", data.getLayerPrefs().entrySet().stream()
    308                         .map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.toList())));
     307                .append(data.getLayerPrefs().entrySet().stream()
     308                        .map(e -> e.getKey() + "=" + e.getValue())
     309                        .collect(Collectors.joining("<br>")));
    309310        }
    310311
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java

    r14502 r15736  
    1616import java.util.Set;
    1717import java.util.function.Function;
    18 import java.util.stream.Collectors;
    1918
    2019import org.openstreetmap.josm.data.osm.DataSet;
     
    347346
    348347    private static List<AutoCompletionItem> setToList(AutoCompletionSet set, Comparator<AutoCompletionItem> comparator) {
    349         List<AutoCompletionItem> list = set.stream().collect(Collectors.toList());
     348        List<AutoCompletionItem> list = new ArrayList<>(set);
    350349        list.sort(comparator);
    351350        return list;
  • trunk/src/org/openstreetmap/josm/io/GpxWriter.java

    r15502 r15736  
    397397                // but otherwise the file is invalid and can't even be parsed by SAX anymore
    398398                String k = (e.getPrefix().isEmpty() ? "" : e.getPrefix() + ":") + e.getKey();
    399                 String attr = String.join(" ", e.getAttributes().entrySet().stream()
    400                         .map(a -> encode(a.getKey()) + "=\"" + encode(a.getValue().toString()) + "\"").sorted().collect(Collectors.toList()));
     399                String attr = e.getAttributes().entrySet().stream()
     400                        .map(a -> encode(a.getKey()) + "=\"" + encode(a.getValue().toString()) + "\"")
     401                        .sorted()
     402                        .collect(Collectors.joining(" "));
    401403                if (e.getValue() == null && e.getExtensions().isEmpty()) {
    402404                    inline(k, attr);
  • trunk/test/unit/org/openstreetmap/josm/io/GeoJSONReaderTest.java

    r15442 r15736  
    129129                assertEquals(24, primitives.size());
    130130                assertTrue(primitives.stream()
    131                         .filter(it -> areEqualNodes(it, new Node(new LatLon(52.5840213, 13.1724145))))
    132                         .findAny().isPresent());
     131                        .anyMatch(it -> areEqualNodes(it, new Node(new LatLon(52.5840213, 13.1724145)))));
    133132        }
    134133    }
Note: See TracChangeset for help on using the changeset viewer.