Changeset 17003 in josm


Ignore:
Timestamp:
2020-09-02T22:23:24+02:00 (3 weeks ago)
Author:
simon04
Message:

Java 8: use Stream

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
2 edited

Legend:

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

    r16557 r17003  
    308308    private static void showErrors(List<TestError> errors) {
    309309        if (!errors.isEmpty()) {
    310             StringBuilder sb = new StringBuilder();
    311             Set<String> errorMessages = new LinkedHashSet<>();
    312             errors.forEach(e-> errorMessages.add(e.getMessage()));
    313             Iterator<String> iter = errorMessages.iterator();
    314             while (iter.hasNext()) {
    315                 sb.append(iter.next());
    316                 if (iter.hasNext())
    317                     sb.append('\n');
    318             }
    319             GuiHelper.runInEDT(() -> new Notification(sb.toString()).setIcon(JOptionPane.INFORMATION_MESSAGE).show());
     310            String errorMessages = errors.stream()
     311                    .map(TestError::getMessage)
     312                    .distinct()
     313                    .collect(Collectors.joining("\n"));
     314            GuiHelper.runInEDT(() -> new Notification(errorMessages).setIcon(JOptionPane.INFORMATION_MESSAGE).show());
    320315        }
    321316    }
  • trunk/src/org/openstreetmap/josm/actions/MergeLayerAction.java

    r16509 r17003  
    5353     */
    5454    protected Future<?> doMerge(List<? extends Layer> targetLayers, final Collection<? extends Layer> sourceLayers) {
    55         final boolean onlygpx = targetLayers.stream().noneMatch(l -> !(l instanceof GpxLayer));
     55        final boolean onlygpx = targetLayers.stream().allMatch(l -> l instanceof GpxLayer);
    5656        final TargetLayerDialogResult<Layer> res = askTargetLayer(targetLayers, onlygpx,
    5757                tr("Cut timewise overlapping parts of tracks"),
Note: See TracChangeset for help on using the changeset viewer.