Index: /trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java	(revision 16436)
@@ -6,5 +6,4 @@
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Objects;
@@ -20,5 +19,4 @@
 import org.openstreetmap.josm.data.osm.PrimitiveData;
 import org.openstreetmap.josm.tools.CheckParameterUtil;
-import org.openstreetmap.josm.tools.JosmRuntimeException;
 
 /**
@@ -160,10 +158,7 @@
             return createdPrimitives;
 
-        Collection<OsmPrimitive> prims = new HashSet<>();
-        for (PrimitiveData d : data) {
-            prims.add(Optional.ofNullable(getAffectedDataSet().getPrimitiveById(d)).orElseThrow(
-                    () -> new JosmRuntimeException("No primitive found for " + d)));
-        }
-        return prims;
+        return data.stream()
+                .map(d -> Objects.requireNonNull(getAffectedDataSet().getPrimitiveById(d), () -> "No primitive found for " + d))
+                .collect(Collectors.toSet());
     }
 
Index: /trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java	(revision 16436)
@@ -229,13 +229,8 @@
             }
         } else {
-            boolean allnull = true;
-            for (Map.Entry<String, String> tag : this.tags.entrySet()) {
-                if (tag.getValue() != null && !tag.getValue().isEmpty()) {
-                    allnull = false;
-                    break;
-                }
-            }
-
-            if (allnull) {
+            boolean allNull = this.tags.entrySet().stream()
+                    .allMatch(tag -> tag.getValue() == null || tag.getValue().isEmpty());
+
+            if (allNull) {
                 /* I18n: plural form detected for objects only (but value < 2 not possible!), try to do your best for tags */
                 text = trn("Deleted {0} tags for {1} object", "Deleted {0} tags for {1} objects", objects.size(), tags.size(), objects.size());
Index: /trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/DeleteCommand.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/command/DeleteCommand.java	(revision 16436)
@@ -10,5 +10,4 @@
 import java.util.Collection;
 import java.util.Collections;
-import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -224,10 +223,6 @@
     }
 
-    private EnumSet<OsmPrimitiveType> getTypesToDelete() {
-        EnumSet<OsmPrimitiveType> typesToDelete = EnumSet.noneOf(OsmPrimitiveType.class);
-        for (OsmPrimitive osm : toDelete) {
-            typesToDelete.add(OsmPrimitiveType.from(osm));
-        }
-        return typesToDelete;
+    private Set<OsmPrimitiveType> getTypesToDelete() {
+        return toDelete.stream().map(OsmPrimitiveType::from).collect(Collectors.toSet());
     }
 
@@ -278,10 +273,5 @@
             return null;
         else {
-            List<PseudoCommand> children = new ArrayList<>(toDelete.size());
-            for (final OsmPrimitive osm : toDelete) {
-                children.add(new DeleteChildCommand(osm));
-            }
-            return children;
-
+            return toDelete.stream().map(DeleteChildCommand::new).collect(Collectors.toList());
         }
     }
@@ -369,11 +359,5 @@
                 Collection<OsmPrimitive> referringPrimitives = n.getReferrers();
                 referringPrimitives.removeAll(primitivesToDelete);
-                int count = 0;
-                for (OsmPrimitive p : referringPrimitives) {
-                    if (!p.isDeleted()) {
-                        count++;
-                    }
-                }
-                if (count == 0) {
+                if (referringPrimitives.stream().allMatch(OsmPrimitive::isDeleted)) {
                     nodesToDelete.add(n);
                 }
Index: /trunk/src/org/openstreetmap/josm/command/PurgeCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/PurgeCommand.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/command/PurgeCommand.java	(revision 16436)
@@ -13,4 +13,5 @@
 import java.util.Objects;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import javax.swing.Icon;
@@ -26,5 +27,4 @@
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.RelationData;
-import org.openstreetmap.josm.data.osm.RelationMember;
 import org.openstreetmap.josm.data.osm.Storage;
 import org.openstreetmap.josm.data.osm.Way;
@@ -222,10 +222,5 @@
             }
         }
-        Set<Relation> childlessR = new HashSet<>();
-        for (Relation r : inR) {
-            if (numChilds.get(r).equals(0)) {
-                childlessR.add(r);
-            }
-        }
+        Set<Relation> childlessR = inR.stream().filter(r -> numChilds.get(r).equals(0)).collect(Collectors.toSet());
 
         List<Relation> outR = new ArrayList<>(inR.size());
@@ -409,9 +404,6 @@
     private static boolean hasOnlyIncompleteMembers(
             Relation r, Collection<OsmPrimitive> toPurge, Collection<? extends OsmPrimitive> moreToPurge) {
-        for (RelationMember m : r.getMembers()) {
-            if (!m.getMember().isIncomplete() && !toPurge.contains(m.getMember()) && !moreToPurge.contains(m.getMember()))
-                return false;
-        }
-        return true;
+        return r.getMembers().stream()
+                .allMatch(m -> m.getMember().isIncomplete() || toPurge.contains(m.getMember()) || moreToPurge.contains(m.getMember()));
     }
 }
Index: /trunk/src/org/openstreetmap/josm/command/conflict/TagConflictResolveCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/conflict/TagConflictResolveCommand.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/command/conflict/TagConflictResolveCommand.java	(revision 16436)
@@ -34,11 +34,5 @@
      */
     public int getNumDecidedConflicts() {
-        int n = 0;
-        for (TagMergeItem item: mergeItems) {
-            if (item.getMergeDecision() != MergeDecisionType.UNDECIDED) {
-                n++;
-            }
-        }
-        return n;
+        return (int) mergeItems.stream().filter(item -> item.getMergeDecision() != MergeDecisionType.UNDECIDED).count();
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/APIDataSet.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/APIDataSet.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/APIDataSet.java	(revision 16436)
@@ -267,11 +267,6 @@
         List<Relation> ret = new LinkedList<>();
         for (Relation relation: relations) {
-            boolean refersToNewRelation = false;
-            for (RelationMember m : relation.getMembers()) {
-                if (m.isRelation() && m.getMember().isNewOrUndeleted()) {
-                    refersToNewRelation = true;
-                    break;
-                }
-            }
+            boolean refersToNewRelation = relation.getMembers().stream()
+                    .anyMatch(m -> m.isRelation() && m.getMember().isNewOrUndeleted());
             if (!refersToNewRelation) {
                 ret.add(relation);
Index: /trunk/src/org/openstreetmap/josm/data/DataSource.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/DataSource.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/DataSource.java	(revision 16436)
@@ -4,8 +4,8 @@
 import java.awt.geom.Area;
 import java.awt.geom.Path2D;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 import org.openstreetmap.josm.tools.CheckParameterUtil;
@@ -104,11 +104,7 @@
             return null;
         }
-        List<Bounds> ret = new ArrayList<>(dataSources.size());
-        for (DataSource ds : dataSources) {
-            if (ds.bounds != null) {
-                ret.add(ds.bounds);
-            }
-        }
-        return ret;
+        return dataSources.stream()
+                .filter(ds -> ds.bounds != null).map(ds -> ds.bounds)
+                .collect(Collectors.toList());
     }
 }
Index: /trunk/src/org/openstreetmap/josm/data/ImageData.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/ImageData.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/ImageData.java	(revision 16436)
@@ -10,4 +10,5 @@
 
 import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.gpx.GpxImageEntry;
 import org.openstreetmap.josm.gui.layer.geoimage.ImageEntry;
 import org.openstreetmap.josm.tools.ListenerList;
@@ -75,10 +76,5 @@
      */
     public boolean isModified() {
-        for (ImageEntry e : data) {
-            if (e.hasNewGpsData()) {
-                return true;
-            }
-        }
-        return false;
+        return data.stream().anyMatch(GpxImageEntry::hasNewGpsData);
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/StructUtils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/StructUtils.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/StructUtils.java	(revision 16436)
@@ -123,11 +123,6 @@
         if (l == null)
             return null;
-        List<Map<String, String>> vals = new ArrayList<>();
-        for (T struct : l) {
-            if (struct != null) {
-                vals.add(serializeStruct(struct, klass));
-            }
-        }
-        return vals;
+        return l.stream().filter(Objects::nonNull)
+                .map(struct -> serializeStruct(struct, klass)).collect(Collectors.toList());
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/Version.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/Version.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/Version.java	(revision 16436)
@@ -6,7 +6,7 @@
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.Properties;
+import java.util.stream.Collectors;
 
 import org.openstreetmap.josm.tools.LanguageInfo;
@@ -94,9 +94,7 @@
         // the revision info
         //
-        StringBuilder sb = new StringBuilder();
-        for (Entry<Object, Object> property: properties.entrySet()) {
-            sb.append(property.getKey()).append(':').append(property.getValue()).append('\n');
-        }
-        releaseDescription = sb.toString();
+        releaseDescription = properties.entrySet().stream()
+                .map(property -> property.getKey() + ":" + property.getValue() + "\n")
+                .collect(Collectors.joining());
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java	(revision 16436)
@@ -380,10 +380,5 @@
 
     private boolean anySegmentOverlapsWith(GpxTrackSegmentSpan other) {
-        for (GpxTrackSegmentSpan s : getSegmentSpans()) {
-            if (s.overlapsWith(other)) {
-                return true;
-            }
-        }
-        return false;
+        return getSegmentSpans().stream().anyMatch(s -> s.overlapsWith(other));
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/gpx/GpxExtension.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/gpx/GpxExtension.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/gpx/GpxExtension.java	(revision 16436)
@@ -136,11 +136,8 @@
             return this;
         } else {
-            for (GpxExtension child : getExtensions()) {
-                GpxExtension ext = child.findExtension(sPrefix, sKey);
-                if (ext != null) {
-                    return ext;
-                }
-            }
-            return null;
+            return getExtensions().stream()
+                    .map(child -> child.findExtension(sPrefix, sKey))
+                    .filter(Objects::nonNull)
+                    .findFirst().orElse(null);
         }
     }
Index: /trunk/src/org/openstreetmap/josm/data/gpx/GpxExtensionCollection.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/gpx/GpxExtensionCollection.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/gpx/GpxExtensionCollection.java	(revision 16436)
@@ -202,11 +202,7 @@
      */
     public GpxExtension find(String prefix, String key) {
-        for (GpxExtension child : this) {
-            GpxExtension ext = child.findExtension(prefix, key);
-            if (ext != null) {
-                return ext;
-            }
-        }
-        return null;
+        return this.stream()
+                .map(child -> child.findExtension(prefix, key)).filter(Objects::nonNull)
+                .findFirst().orElse(null);
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java	(revision 16436)
@@ -3,5 +3,4 @@
 
 import java.awt.Color;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -15,4 +14,5 @@
 import org.openstreetmap.josm.tools.ListenerList;
 import org.openstreetmap.josm.tools.Logging;
+import org.openstreetmap.josm.tools.StreamUtils;
 
 /**
@@ -37,11 +37,8 @@
      */
     public GpxTrack(Collection<Collection<WayPoint>> trackSegs, Map<String, Object> attributes) {
-        List<IGpxTrackSegment> newSegments = new ArrayList<>();
-        for (Collection<WayPoint> trackSeg: trackSegs) {
-            if (trackSeg != null && !trackSeg.isEmpty()) {
-                newSegments.add(new GpxTrackSegment(trackSeg));
-            }
-        }
-        this.segments = Collections.unmodifiableList(newSegments);
+        this.segments = trackSegs.stream()
+                .filter(trackSeg -> trackSeg != null && !trackSeg.isEmpty())
+                .map(GpxTrackSegment::new)
+                .collect(StreamUtils.toUnmodifiableList());
         this.length = calculateLength();
         this.bounds = calculateBounds();
@@ -65,10 +62,5 @@
 
     private double calculateLength() {
-        double result = 0.0; // in meters
-
-        for (IGpxTrackSegment trkseg : segments) {
-            result += trkseg.length();
-        }
-        return result;
+        return segments.stream().mapToDouble(IGpxTrackSegment::length).sum();
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/imagery/GetCapabilitiesParseHelper.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/GetCapabilitiesParseHelper.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/GetCapabilitiesParseHelper.java	(revision 16436)
@@ -5,4 +5,5 @@
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Arrays;
 import java.util.Locale;
 import java.util.function.BiPredicate;
@@ -35,10 +36,7 @@
 
         static TransferMode fromString(String s) {
-            for (TransferMode type : TransferMode.values()) {
-                if (type.getTypeString().equals(s)) {
-                    return type;
-                }
-            }
-            return null;
+            return Arrays.stream(TransferMode.values())
+                    .filter(type -> type.getTypeString().equals(s))
+                    .findFirst().orElse(null);
         }
     }
Index: /trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java	(revision 16436)
@@ -48,4 +48,5 @@
 import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.MultiMap;
+import org.openstreetmap.josm.tools.StreamUtils;
 import org.openstreetmap.josm.tools.Utils;
 
@@ -95,10 +96,7 @@
          */
         public static ImageryType fromString(String s) {
-            for (ImageryType type : ImageryType.values()) {
-                if (type.getTypeString().equals(s)) {
-                    return type;
-                }
-            }
-            return null;
+            return Arrays.stream(ImageryType.values())
+                    .filter(type -> type.getTypeString().equals(s))
+                    .findFirst().orElse(null);
         }
     }
@@ -170,10 +168,7 @@
          */
         public static ImageryCategory fromString(String s) {
-            for (ImageryCategory category : ImageryCategory.values()) {
-                if (category.getCategoryString().equals(s)) {
-                    return category;
-                }
-            }
-            return null;
+            return Arrays.stream(ImageryCategory.values())
+                    .filter(category -> category.getCategoryString().equals(s))
+                    .findFirst().orElse(null);
         }
     }
@@ -403,13 +398,7 @@
             if (i.bounds != null) {
                 bounds = i.bounds.encodeAsString(",");
-                StringBuilder shapesString = new StringBuilder();
-                for (Shape s : i.bounds.getShapes()) {
-                    if (shapesString.length() > 0) {
-                        shapesString.append(';');
-                    }
-                    shapesString.append(s.encodeAsString(","));
-                }
-                if (shapesString.length() > 0) {
-                    shapes = shapesString.toString();
+                String shapesString = Shape.encodeAsString(i.bounds.getShapes());
+                if (!shapesString.isEmpty()) {
+                    shapes = shapesString;
                 }
             }
@@ -1093,18 +1082,17 @@
      */
     public static Collection<String> getActiveIds() {
-        ArrayList<String> ids = new ArrayList<>();
         IPreferences pref = Config.getPref();
-        if (pref != null) {
-            List<ImageryPreferenceEntry> entries = StructUtils.getListOfStructs(
-                pref, "imagery.entries", null, ImageryPreferenceEntry.class);
-            if (entries != null) {
-                for (ImageryPreferenceEntry prefEntry : entries) {
-                    if (prefEntry.id != null && !prefEntry.id.isEmpty())
-                        ids.add(prefEntry.id);
-                }
-                Collections.sort(ids);
-            }
-        }
-        return ids;
+        if (pref == null) {
+            return Collections.emptyList();
+        }
+        List<ImageryPreferenceEntry> entries = StructUtils.getListOfStructs(pref, "imagery.entries", null, ImageryPreferenceEntry.class);
+        if (entries == null) {
+            return Collections.emptyList();
+        }
+        return entries.stream()
+                .filter(prefEntry -> prefEntry.id != null && !prefEntry.id.isEmpty())
+                .map(prefEntry -> prefEntry.id)
+                .sorted()
+                .collect(Collectors.toList());
     }
 
@@ -1230,5 +1218,5 @@
         this.serverProjections = serverProjections.stream()
                 .map(String::intern)
-                .collect(Collectors.collectingAndThen(Collectors.toList(), Utils::toUnmodifiableList));
+                .collect(StreamUtils.toUnmodifiableList());
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java	(revision 16436)
@@ -17,4 +17,5 @@
 import java.util.TreeSet;
 import java.util.concurrent.ExecutorService;
+import java.util.stream.Collectors;
 
 import org.openstreetmap.josm.data.StructUtils;
@@ -266,10 +267,5 @@
                     if (def.getId() != null) {
                         newKnownDefaults.add(def.getId());
-                        for (ImageryInfo i : layers) {
-                            if (isSimilar(def, i)) {
-                                isInUserList = true;
-                                break;
-                            }
-                        }
+                        isInUserList = layers.stream().anyMatch(i -> isSimilar(def, i));
                     } else {
                         Logging.error("Default imagery ''{0}'' has no id. Skipping.", def.getName());
@@ -362,8 +358,7 @@
      */
     public void save() {
-        List<ImageryPreferenceEntry> entries = new ArrayList<>();
-        for (ImageryInfo info : layers) {
-            entries.add(new ImageryPreferenceEntry(info));
-        }
+        List<ImageryPreferenceEntry> entries = layers.stream()
+                .map(ImageryPreferenceEntry::new)
+                .collect(Collectors.toList());
         StructUtils.putListOfStructs(Config.getPref(), "imagery.entries", entries, ImageryPreferenceEntry.class);
     }
Index: /trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java	(revision 16436)
@@ -348,9 +348,7 @@
      */
     public static OffsetBookmark getBookmarkByName(ImageryLayer layer, String name) {
-        for (OffsetBookmark b : allBookmarks) {
-            if (b.isUsable(layer) && name.equals(b.name))
-                return b;
-        }
-        return null;
+        return allBookmarks.stream()
+                .filter(b -> b.isUsable(layer) && name.equals(b.name))
+                .findFirst().orElse(null);
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/imagery/Shape.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/Shape.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/Shape.java	(revision 16436)
@@ -8,4 +8,6 @@
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import org.openstreetmap.gui.jmapviewer.Coordinate;
@@ -43,13 +45,24 @@
     }
 
+    /**
+     * Encodes this as a string so that it may be parsed using {@link #Shape(String, String)}
+     * @param separator The separator
+     * @return The string encoded shape
+     */
     public String encodeAsString(String separator) {
-        StringBuilder sb = new StringBuilder();
-        for (Coordinate c : coords) {
-            if (sb.length() != 0) {
-                sb.append(separator);
-            }
-            sb.append(c.getLat()).append(separator).append(c.getLon());
-        }
-        return sb.toString();
+        return coords.stream()
+                .flatMap(c -> Stream.of(c.getLat(), c.getLon()))
+                .map(String::valueOf)
+                .collect(Collectors.joining(separator));
+    }
+
+    /**
+     * Encodes the shapes as a string using {@code ,} and {@code ;} as separators
+     * @return The string encoded shapes
+     */
+    public static String encodeAsString(List<Shape> shapes) {
+        return shapes.stream()
+                .map(s -> s.encodeAsString(","))
+                .collect(Collectors.joining(";"));
     }
 
@@ -61,8 +74,7 @@
         if (latlon == null)
             return false;
-        List<Node> nodes = new ArrayList<>(coords.size());
-        for (Coordinate c : coords) {
-            nodes.add(new Node(new LatLon(c.getLat(), c.getLon())));
-        }
+        List<Node> nodes = coords.stream()
+                .map(c -> new Node(new LatLon(c.getLat(), c.getLon())))
+                .collect(Collectors.toList());
         return Geometry.nodeInsidePolygon(new Node(latlon), nodes);
     }
Index: /trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java	(revision 16436)
@@ -856,8 +856,7 @@
         if (this.currentLayer != null) {
             this.currentTileMatrixSet = this.currentLayer.tileMatrixSet;
-            Collection<Double> scales = new ArrayList<>(currentTileMatrixSet.tileMatrix.size());
-            for (TileMatrix tileMatrix : currentTileMatrixSet.tileMatrix) {
-                scales.add(tileMatrix.scaleDenominator * 0.28e-03);
-            }
+            Collection<Double> scales = currentTileMatrixSet.tileMatrix.stream()
+                    .map(tileMatrix -> tileMatrix.scaleDenominator * 0.28e-03)
+                    .collect(Collectors.toList());
             this.nativeScaleList = new ScaleList(scales);
         }
@@ -1061,11 +1060,5 @@
         Matcher m = Pattern.compile("\\{[^}]*\\}").matcher(url);
         while (m.find()) {
-            boolean isSupportedPattern = false;
-            for (String pattern : ALL_PATTERNS) {
-                if (m.group().matches(pattern)) {
-                    isSupportedPattern = true;
-                    break;
-                }
-            }
+            boolean isSupportedPattern = Arrays.stream(ALL_PATTERNS).anyMatch(pattern -> m.group().matches(pattern));
             if (!isSupportedPattern) {
                 throw new IllegalArgumentException(
@@ -1089,17 +1082,8 @@
      */
     public Collection<String> getSupportedProjections() {
-        Collection<String> ret = new LinkedHashSet<>();
-        if (currentLayer == null) {
-            for (Layer layer: this.layers) {
-                ret.add(layer.tileMatrixSet.crs);
-            }
-        } else {
-            for (Layer layer: this.layers) {
-                if (currentLayer.identifier.equals(layer.identifier)) {
-                    ret.add(layer.tileMatrixSet.crs);
-                }
-            }
-        }
-        return ret;
+        return this.layers.stream()
+                .filter(layer -> currentLayer == null || currentLayer.identifier.equals(layer.identifier))
+                .map(layer -> layer.tileMatrixSet.crs)
+                .collect(Collectors.toCollection(LinkedHashSet::new));
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java	(revision 16436)
@@ -14,4 +14,5 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.IntStream;
 
 import org.openstreetmap.josm.data.Bounds;
@@ -521,20 +522,8 @@
             }
         }
-        boolean isCentric = true;
-        for (Double param : towgs84Param) {
-            if (param != 0) {
-                isCentric = false;
-                break;
-            }
-        }
+        boolean isCentric = towgs84Param.stream().noneMatch(param -> param != 0);
         if (isCentric)
             return Ellipsoid.WGS84.equals(ellps) ? WGS84Datum.INSTANCE : new CentricDatum(null, null, ellps);
-        boolean is3Param = true;
-        for (int i = 3; i < towgs84Param.size(); i++) {
-            if (towgs84Param.get(i) != 0) {
-                is3Param = false;
-                break;
-            }
-        }
+        boolean is3Param = IntStream.range(3, towgs84Param.size()).noneMatch(i -> towgs84Param.get(i) != 0);
         if (is3Param)
             return new ThreeParameterDatum(null, null, ellps,
Index: /trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2Proj4DirGridShiftFileSource.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2Proj4DirGridShiftFileSource.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2Proj4DirGridShiftFileSource.java	(revision 16436)
@@ -43,13 +43,9 @@
     @Override
     public InputStream getNTV2GridShiftFile(String gridFileName) {
-        File grid = null;
         // Check is the grid is installed in default PROJ.4 directories
-        for (File dir : Platform.determinePlatform().accept(this)) {
-            File file = new File(dir, gridFileName);
-            if (file.exists() && file.isFile()) {
-                grid = file;
-                break;
-            }
-        }
+        File grid = Platform.determinePlatform().accept(this).stream()
+                .map(dir -> new File(dir, gridFileName))
+                .filter(file -> file.exists() && file.isFile())
+                .findFirst().orElse(null);
         // If not, search into PROJ_LIB directory
         if (grid == null) {
Index: /trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java	(revision 16436)
@@ -24,4 +24,5 @@
 import java.io.Serializable;
 import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
 
 import org.openstreetmap.josm.tools.Logging;
@@ -171,16 +172,12 @@
      */
     public NTV2SubGrid getSubGridForCoord(double lon, double lat) {
-        if (isCoordWithin(lon, lat)) {
-            if (subGrid == null)
-                return this;
-            else {
-                for (NTV2SubGrid aSubGrid : subGrid) {
-                    if (aSubGrid.isCoordWithin(lon, lat))
-                        return aSubGrid.getSubGridForCoord(lon, lat);
-                }
-                return this;
-            }
-        } else
-            return null;
+        return !isCoordWithin(lon, lat)
+                ? null
+                : subGrid == null
+                ? this
+                : Arrays.stream(subGrid)
+                .filter(aSubGrid -> aSubGrid.isCoordWithin(lon, lat))
+                .map(aSubGrid -> aSubGrid.getSubGridForCoord(lon, lat))
+                .findFirst().orElse(this);
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/autofilter/AutoFilterManager.java	(revision 16436)
@@ -343,10 +343,7 @@
      */
     public synchronized AutoFilterRule getAutoFilterRule(String key) {
-        for (AutoFilterRule r : rules) {
-            if (key.equals(r.getKey())) {
-                return r;
-            }
-        }
-        return null;
+        return rules.stream()
+                .filter(r -> Objects.equals(key, r.getKey()))
+                .findFirst().orElse(null);
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/conflict/pair/AbstractListMergeModel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/conflict/pair/AbstractListMergeModel.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/conflict/pair/AbstractListMergeModel.java	(revision 16436)
@@ -18,4 +18,6 @@
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 import javax.swing.AbstractListModel;
@@ -369,8 +371,5 @@
 
     protected void alertCopyFailedForDeletedPrimitives(List<PrimitiveId> deletedIds) {
-        List<String> items = new ArrayList<>();
-        for (int i = 0; i < Math.min(MAX_DELETED_PRIMITIVE_IN_DIALOG, deletedIds.size()); i++) {
-            items.add(deletedIds.get(i).toString());
-        }
+        List<String> items = deletedIds.stream().limit(MAX_DELETED_PRIMITIVE_IN_DIALOG).map(Object::toString).collect(Collectors.toList());
         if (deletedIds.size() > MAX_DELETED_PRIMITIVE_IN_DIALOG) {
             items.add(tr("{0} more...", deletedIds.size() - MAX_DELETED_PRIMITIVE_IN_DIALOG));
@@ -422,8 +421,5 @@
         getMergedEntries().clear();
 
-        int[] rows = new int[entries.get(source).size()];
-        for (int i = 0; i < rows.length; i++) {
-            rows[i] = i;
-        }
+        int[] rows = IntStream.range(0, entries.get(source).size()).toArray();
         copy(source, rows, 0);
     }
@@ -588,11 +584,6 @@
      */
     protected boolean myAndTheirEntriesEqual() {
-        if (getMyEntriesSize() != getTheirEntriesSize())
-            return false;
-        for (int i = 0; i < getMyEntriesSize(); i++) {
-            if (!isEqualEntry(getMyEntries().get(i), getTheirEntries().get(i)))
-                return false;
-        }
-        return true;
+        return getMyEntriesSize() == getTheirEntriesSize()
+                && IntStream.range(0, getMyEntriesSize()).allMatch(i -> isEqualEntry(getMyEntries().get(i), getTheirEntries().get(i)));
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java	(revision 16436)
@@ -19,4 +19,5 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
+import java.util.stream.Collectors;
 
 import javax.swing.AbstractAction;
@@ -305,10 +306,7 @@
             if (ds == null || ids == null)
                 return;
-            Set<OsmPrimitive> sel = new HashSet<>();
-            for (OsmPrimitive p: ds.allPrimitives()) {
-                if (ids.contains(p.getChangesetId())) {
-                    sel.add(p);
-                }
-            }
+            Set<OsmPrimitive> sel = ds.allPrimitives().stream()
+                    .filter(p -> ids.contains(p.getChangesetId()))
+                    .collect(Collectors.toSet());
             ds.setSelected(sel);
         }
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java	(revision 16436)
@@ -18,5 +18,4 @@
 import java.awt.event.WindowEvent;
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Objects;
@@ -739,11 +738,9 @@
             return;
         }
-        Set<Changeset> toSelect = new HashSet<>();
         ChangesetCache cc = ChangesetCache.getInstance();
-        for (int id: ids) {
-            if (cc.contains(id)) {
-                toSelect.add(cc.get(id));
-            }
-        }
+        Set<Changeset> toSelect = ids.stream()
+                .filter(cc::contains)
+                .map(cc::get)
+                .collect(Collectors.toSet());
         setSelectedChangesets(toSelect);
     }
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerModel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerModel.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerModel.java	(revision 16436)
@@ -7,7 +7,7 @@
 import java.util.Collection;
 import java.util.Comparator;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import javax.swing.DefaultListSelectionModel;
@@ -102,9 +102,5 @@
      */
     public Set<Integer> getSelectedChangesetIds() {
-        Set<Integer> ret = new HashSet<>();
-        for (Changeset cs: getSelectedChangesets()) {
-            ret.add(cs.getId());
-        }
-        return ret;
+        return getSelectedChangesets().stream().map(Changeset::getId).collect(Collectors.toSet());
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java	(revision 16436)
@@ -12,5 +12,4 @@
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -263,11 +262,7 @@
 
         protected List<HistoryOsmPrimitive> filterPrimitivesWithUnloadedHistory(Collection<HistoryOsmPrimitive> primitives) {
-            List<HistoryOsmPrimitive> ret = new ArrayList<>(primitives.size());
-            for (HistoryOsmPrimitive p: primitives) {
-                if (HistoryDataSet.getInstance().getHistory(p.getPrimitiveId()) == null) {
-                    ret.add(p);
-                }
-            }
-            return ret;
+            return primitives.stream()
+                    .filter(p -> HistoryDataSet.getInstance().getHistory(p.getPrimitiveId()) == null)
+                    .collect(Collectors.toList());
         }
 
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java	(revision 16436)
@@ -3,8 +3,9 @@
 
 import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import javax.swing.DefaultListSelectionModel;
@@ -65,10 +66,8 @@
      */
     public Set<HistoryOsmPrimitive> getSelectedPrimitives(JTable table) {
-        Set<HistoryOsmPrimitive> ret = new HashSet<>();
         int[] selection = table.getSelectedRows();
-        for (int i = 0; i < selection.length; i++) {
-            ret.add(data.get(table.convertRowIndexToModel(selection[i])).getPrimitive());
-        }
-        return ret;
+        return Arrays.stream(selection)
+                .mapToObj(i -> data.get(table.convertRowIndexToModel(i)).getPrimitive())
+                .collect(Collectors.toSet());
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDetailPanel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDetailPanel.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDetailPanel.java	(revision 16436)
@@ -16,6 +16,6 @@
 import java.util.Collections;
 import java.util.Date;
-import java.util.HashSet;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import javax.swing.AbstractAction;
@@ -372,10 +372,7 @@
                 return;
             }
-            Set<OsmPrimitive> target = new HashSet<>();
-            for (OsmPrimitive p: ds.allPrimitives()) {
-                if (p.isUsable() && p.getChangesetId() == currentChangeset.getId()) {
-                    target.add(p);
-                }
-            }
+            Set<OsmPrimitive> target = ds.allPrimitives().stream()
+                    .filter(p -> p.isUsable() && p.getChangesetId() == currentChangeset.getId())
+                    .collect(Collectors.toSet());
             if (target.isEmpty()) {
                 alertNoPrimitivesToSelect();
@@ -431,10 +428,7 @@
                 return;
             }
-            Set<OsmPrimitive> target = new HashSet<>();
-            for (OsmPrimitive p: ds.allPrimitives()) {
-                if (p.isUsable() && p.getChangesetId() == currentChangeset.getId()) {
-                    target.add(p);
-                }
-            }
+            Set<OsmPrimitive> target = ds.allPrimitives().stream()
+                    .filter(p -> p.isUsable() && p.getChangesetId() == currentChangeset.getId())
+                    .collect(Collectors.toSet());
             if (target.isEmpty()) {
                 alertNoPrimitivesToZoomTo();
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetListModel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetListModel.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetListModel.java	(revision 16436)
@@ -5,11 +5,13 @@
 import java.util.Collection;
 import java.util.Comparator;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 import javax.swing.DefaultListModel;
 import javax.swing.DefaultListSelectionModel;
 
+import org.openstreetmap.josm.data.osm.AbstractPrimitive;
 import org.openstreetmap.josm.data.osm.Changeset;
 import org.openstreetmap.josm.data.osm.ChangesetCache;
@@ -42,11 +44,6 @@
      */
     public synchronized Set<Changeset> getSelectedChangesets() {
-        Set<Changeset> ret = new HashSet<>();
-        for (int i = 0; i < getSize(); i++) {
-            if (selectionModel.isSelectedIndex(i)) {
-                ret.add(data.get(i));
-            }
-        }
-        return ret;
+        return IntStream.range(0, getSize()).filter(selectionModel::isSelectedIndex)
+                .mapToObj(data::get).collect(Collectors.toSet());
     }
 
@@ -56,11 +53,6 @@
      */
     public synchronized Set<Integer> getSelectedChangesetIds() {
-        Set<Integer> ret = new HashSet<>();
-        for (int i = 0; i < getSize(); i++) {
-            if (selectionModel.isSelectedIndex(i)) {
-                ret.add(data.get(i).getId());
-            }
-        }
-        return ret;
+        return IntStream.range(0, getSize()).filter(selectionModel::isSelectedIndex)
+                .mapToObj(data::get).map(Changeset::getId).collect(Collectors.toSet());
     }
 
@@ -115,11 +107,6 @@
             return;
         }
-        Set<Changeset> changesets = new HashSet<>(ids.size());
-        for (int id: ids) {
-            if (id <= 0) {
-                continue;
-            }
-            changesets.add(new Changeset(id));
-        }
+        Set<Changeset> changesets = ids.stream().mapToInt(id -> id)
+                .filter(id -> id > 0).mapToObj(Changeset::new).collect(Collectors.toSet());
         setChangesets(changesets);
     }
@@ -134,12 +121,5 @@
             return;
         }
-        Set<Changeset> changesets = new HashSet<>();
-        for (OsmPrimitive p: primitives) {
-            if (p.getChangesetId() <= 0) {
-                continue;
-            }
-            changesets.add(new Changeset(p.getChangesetId()));
-        }
-        setChangesets(changesets);
+        initFromChangesetIds(primitives.stream().map(AbstractPrimitive::getChangesetId).collect(Collectors.toList()));
     }
 
@@ -153,12 +133,5 @@
             return;
         }
-        Set<Changeset> changesets = new HashSet<>();
-        for (OsmPrimitive p: ds.allPrimitives()) {
-            if (p.getChangesetId() <= 0) {
-                continue;
-            }
-            changesets.add(new Changeset(p.getChangesetId()));
-        }
-        setChangesets(changesets);
+        initFromChangesetIds(ds.allPrimitives().stream().map(AbstractPrimitive::getChangesetId).collect(Collectors.toList()));
     }
 
@@ -192,14 +165,9 @@
      */
     public synchronized List<Changeset> getSelectedOpenChangesets() {
-        List<Changeset> ret = new ArrayList<>();
-        for (int i = 0; i < getSize(); i++) {
-            if (selectionModel.isSelectedIndex(i)) {
-                Changeset cs = data.get(i);
-                if (cs.isOpen()) {
-                    ret.add(cs);
-                }
-            }
-        }
-        return ret;
+        return IntStream.range(0, getSize())
+                .filter(selectionModel::isSelectedIndex)
+                .mapToObj(data::get)
+                .filter(Changeset::isOpen)
+                .collect(Collectors.toList());
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/BasicChangesetQueryPanel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/BasicChangesetQueryPanel.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/BasicChangesetQueryPanel.java	(revision 16436)
@@ -10,4 +10,5 @@
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.util.Arrays;
 import java.util.EnumMap;
 import java.util.Map;
@@ -178,9 +179,7 @@
 
     protected BasicQuery getSelectedQuery() {
-        for (BasicQuery q : BasicQuery.values()) {
-            if (rbQueries.get(q).isSelected())
-                return q;
-        }
-        return null;
+        return Arrays.stream(BasicQuery.values())
+                .filter(q -> rbQueries.get(q).isSelected())
+                .findFirst().orElse(null);
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java	(revision 16436)
@@ -14,5 +14,4 @@
 import java.io.IOException;
 import java.util.Arrays;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -302,8 +301,7 @@
             if (selection == null || selection.length == 0)
                 return;
-            Set<Relation> relations = new HashSet<>();
-            for (TreePath aSelection : selection) {
-                relations.add((Relation) aSelection.getLastPathComponent());
-            }
+            Set<Relation> relations = Arrays.stream(selection)
+                    .map(s -> (Relation) s.getLastPathComponent())
+                    .collect(Collectors.toSet());
             MainApplication.worker.submit(new DownloadRelationSetTask(getParentDialog(), relations));
         }
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java	(revision 16436)
@@ -479,11 +479,5 @@
      */
     public int getNumMembersWithPrimitive(OsmPrimitive primitive) {
-        int count = 0;
-        for (RelationMember member : members) {
-            if (member.getMember().equals(primitive)) {
-                count++;
-            }
-        }
-        return count;
+        return (int) members.stream().filter(member -> member.getMember().equals(primitive)).count();
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java	(revision 16436)
@@ -1701,10 +1701,8 @@
      */
     private List<Action> getMenuAdditions() {
-        final LinkedList<Action> menuAdds = new LinkedList<>();
-        for (MenuAddition menuAdd: menuAdditions) {
-            if (menuAdd.clazz.isInstance(this)) {
-                menuAdds.add(menuAdd.addition);
-            }
-        }
+        final LinkedList<Action> menuAdds = menuAdditions.stream()
+                .filter(menuAdd -> menuAdd.clazz.isInstance(this))
+                .map(menuAdd -> menuAdd.addition)
+                .collect(Collectors.toCollection(LinkedList::new));
         if (!menuAdds.isEmpty()) {
             menuAdds.addFirst(SeparatorLayerAction.INSTANCE);
Index: /trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java	(revision 16436)
@@ -178,12 +178,5 @@
         while (true) {
             String filename = getFileName(layer.layer.getName(), index);
-            boolean foundTheSame = false;
-            for (AutosaveLayerInfo<?> info: layersInfo) {
-                if (info != layer && filename.equals(info.layerFileName)) {
-                    foundTheSame = true;
-                    break;
-                }
-            }
-
+            boolean foundTheSame = layersInfo.stream().anyMatch(info -> info != layer && filename.equals(info.layerFileName));
             if (!foundTheSame) {
                 layer.layerFileName = filename;
Index: /trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java	(revision 16436)
@@ -14,5 +14,4 @@
 import java.awt.event.MouseListener;
 import java.io.Serializable;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Comparator;
@@ -21,4 +20,5 @@
 import java.util.Objects;
 import java.util.Optional;
+import java.util.stream.Collectors;
 
 import javax.swing.AbstractAction;
@@ -297,11 +297,9 @@
             protected void buttonAction(int buttonIndex, ActionEvent evt) {
                 if (buttonIndex == 0) {
-                    List<IGpxTrack> trks = new ArrayList<>();
-                    for (int i : table.getSelectedRows()) {
-                        Object trk = content[i][5];
-                        if (trk != null && trk instanceof IGpxTrack) {
-                            trks.add((IGpxTrack) trk);
-                        }
-                    }
+                    List<IGpxTrack> trks = Arrays.stream(table.getSelectedRows())
+                            .mapToObj(i -> content[i][5])
+                            .filter(trk -> trk instanceof IGpxTrack)
+                            .map(IGpxTrack.class::cast)
+                            .collect(Collectors.toList());
                     showColorDialog(trks);
                 } else {
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java	(revision 16436)
@@ -10,4 +10,5 @@
 import java.util.TreeSet;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 import org.openstreetmap.josm.gui.mappaint.mapcss.CSSColors;
@@ -240,5 +241,4 @@
     @Override
     public String toString() {
-        StringBuilder res = new StringBuilder("Cascade{ ");
         // List properties in alphabetical order to be deterministic, without changing "prop" to a TreeMap
         // (no reason too, not sure about the potential memory/performance impact of such a change)
@@ -257,8 +257,5 @@
             props.add(sb.toString());
         }
-        for (String s : props) {
-            res.append(s);
-        }
-        return res.append('}').toString();
+        return props.stream().collect(Collectors.joining("", "Cascade{ ", "}"));
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java	(revision 16436)
@@ -16,4 +16,5 @@
 import java.util.Set;
 import java.util.function.Function;
+import java.util.stream.Collectors;
 
 import org.openstreetmap.josm.data.osm.DataSet;
@@ -233,10 +234,8 @@
 
     protected Collection<String> getUserInputKeys() {
-        List<String> keys = new ArrayList<>();
-        for (UserInputTag tag : USER_INPUT_TAG_CACHE) {
-            if (!tag.defaultKey) {
-                keys.add(tag.key);
-            }
-        }
+        List<String> keys = USER_INPUT_TAG_CACHE.stream()
+                .filter(tag -> !tag.defaultKey)
+                .map(tag -> tag.key)
+                .collect(Collectors.toList());
         Collections.reverse(keys);
         return new LinkedHashSet<>(keys);
@@ -255,10 +254,8 @@
 
     protected static Collection<String> getUserInputValues(String key) {
-        List<String> values = new ArrayList<>();
-        for (UserInputTag tag : USER_INPUT_TAG_CACHE) {
-            if (key.equals(tag.key)) {
-                values.add(tag.value);
-            }
-        }
+        List<String> values = USER_INPUT_TAG_CACHE.stream()
+                .filter(tag -> Objects.equals(key, tag.key))
+                .map(tag -> tag.value)
+                .collect(Collectors.toList());
         Collections.reverse(values);
         return new LinkedHashSet<>(values);
Index: /trunk/src/org/openstreetmap/josm/io/Capabilities.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/Capabilities.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/io/Capabilities.java	(revision 16436)
@@ -218,11 +218,5 @@
      */
     public boolean isOnImageryBlacklist(String url) {
-        if (url != null && imageryBlacklist != null) {
-            for (String blacklistRegex : imageryBlacklist) {
-                if (url.matches(blacklistRegex))
-                    return true;
-            }
-        }
-        return false;
+        return url != null && imageryBlacklist.stream().anyMatch(url::matches);
     }
 
Index: /trunk/src/org/openstreetmap/josm/io/CertificateAmendment.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/CertificateAmendment.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/io/CertificateAmendment.java	(revision 16436)
@@ -288,11 +288,7 @@
             throws KeyStoreException, InvalidAlgorithmParameterException {
         PKIXParameters params = new PKIXParameters(keyStore);
-        String id = crt.getSubjectX500Principal().getName();
-        for (TrustAnchor ta : params.getTrustAnchors()) {
-            X509Certificate cert = ta.getTrustedCert();
-            if (Objects.equals(id, cert.getSubjectX500Principal().getName()))
-                return false;
-        }
-        return true;
+        return params.getTrustAnchors().stream()
+                .map(TrustAnchor::getTrustedCert)
+                .noneMatch(c -> Objects.equals(crt.getSubjectX500Principal().getName(), c.getSubjectX500Principal().getName()));
     }
 }
Index: /trunk/src/org/openstreetmap/josm/io/OsmServerUserInfoReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmServerUserInfoReader.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/io/OsmServerUserInfoReader.java	(revision 16436)
@@ -5,6 +5,7 @@
 
 import java.time.DateTimeException;
-import java.util.LinkedList;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 import javax.xml.xpath.XPath;
@@ -109,8 +110,7 @@
             NodeList xmlNodeList = (NodeList) xpath.compile("/osm/user[1]/languages[1]/lang/text()").evaluate(document, XPathConstants.NODESET);
             if (xmlNodeList != null) {
-                List<String> languages = new LinkedList<>();
-                for (int i = 0; i < xmlNodeList.getLength(); i++) {
-                    languages.add(xmlNodeList.item(i).getNodeValue());
-                }
+                List<String> languages = IntStream.range(0, xmlNodeList.getLength())
+                        .mapToObj(i -> xmlNodeList.item(i).getNodeValue())
+                        .collect(Collectors.toList());
                 userInfo.setLanguages(languages);
             }
Index: /trunk/src/org/openstreetmap/josm/io/nmea/NmeaReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/nmea/NmeaReader.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/io/nmea/NmeaReader.java	(revision 16436)
@@ -10,4 +10,5 @@
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -295,10 +296,6 @@
      */
     static boolean isSentence(String address, Sentence formatter) {
-        for (TalkerId talker : TalkerId.values()) {
-            if (address.equals('$' + talker.name() + formatter.name())) {
-                return true;
-            }
-        }
-        return false;
+        return Arrays.stream(TalkerId.values())
+                .anyMatch(talker -> address.equals('$' + talker.name() + formatter.name()));
     }
 
Index: /trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java	(revision 16436)
@@ -15,6 +15,6 @@
 import java.util.HashSet;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import javax.swing.AbstractAction;
@@ -104,28 +104,11 @@
         @Override
         public String toString() {
-            StringBuilder sb = new StringBuilder();
-            for (String k: valueCount.keySet()) {
-                if (sb.length() > 0) sb.append(", ");
-                sb.append(k);
-            }
-            return sb.toString();
+            return String.join(", ", valueCount.keySet());
         }
 
         private String getToolTip() {
-            StringBuilder sb = new StringBuilder(64);
-            sb.append("<html>")
-              .append(tr("Old values of"))
-              .append(" <b>")
-              .append(tag)
-              .append("</b><br/>");
-            for (Entry<String, Integer> e : valueCount.entrySet()) {
-                sb.append("<b>")
-                  .append(e.getValue())
-                  .append(" x </b>")
-                  .append(e.getKey())
-                  .append("<br/>");
-            }
-            sb.append("</html>");
-            return sb.toString();
+            return valueCount.entrySet().stream()
+                    .map(e -> "<b>" + e.getValue() + " x </b>" + e.getKey() + "<br/>")
+                    .collect(Collectors.joining("", "<html>" + tr("Old values of") + " <b>" + tag + "</b><br/>", "</html>"));
         }
     }
Index: /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java	(revision 16436)
@@ -49,10 +49,7 @@
 
     protected static ImageryInfo findBingEntry() {
-        for (ImageryInfo i : ImageryLayerInfo.instance.getDefaultLayers()) {
-            if (ImageryType.BING == i.getImageryType()) {
-                return i;
-            }
-        }
-        return null;
+        return ImageryLayerInfo.instance.getDefaultLayers().stream()
+                .filter(i -> ImageryType.BING == i.getImageryType())
+                .findFirst().orElse(null);
     }
 
Index: /trunk/src/org/openstreetmap/josm/io/session/ImagerySessionImporter.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/session/ImagerySessionImporter.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/io/session/ImagerySessionImporter.java	(revision 16436)
@@ -5,6 +5,7 @@
 
 import java.io.IOException;
-import java.util.HashMap;
 import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 import org.openstreetmap.josm.data.StructUtils;
@@ -87,14 +88,9 @@
 
     private static Map<String, String> readProperties(Element elem) {
-        Map<String, String> attributes = new HashMap<>();
         NodeList nodes = elem.getChildNodes();
-        for (int i = 0; i < nodes.getLength(); ++i) {
-            Node node = nodes.item(i);
-            if (node.getNodeType() == Node.ELEMENT_NODE && node.getChildNodes().getLength() <= 1) {
-                Element e = (Element) node;
-                attributes.put(e.getTagName(), e.getTextContent());
-            }
-        }
-        return attributes;
+        return IntStream.range(0, nodes.getLength()).mapToObj(nodes::item)
+                .filter(node -> node.getNodeType() == Node.ELEMENT_NODE && node.getChildNodes().getLength() <= 1)
+                .map(node -> (Element) node)
+                .collect(Collectors.toMap(Element::getTagName, Node::getTextContent, (a, b) -> b));
     }
 }
Index: /trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/session/SessionReader.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/io/session/SessionReader.java	(revision 16436)
@@ -24,4 +24,6 @@
 import java.util.Map.Entry;
 import java.util.TreeMap;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipException;
@@ -651,11 +653,9 @@
         Element parametersEl = getElementByTagName(projectionChoiceEl, "parameters");
         if (parametersEl == null) return null;
-        Collection<String> parameters = new ArrayList<>();
         NodeList paramNl = parametersEl.getElementsByTagName("param");
         int length = paramNl.getLength();
-        for (int i = 0; i < length; i++) {
-            Element paramEl = (Element) paramNl.item(i);
-            parameters.add(paramEl.getTextContent());
-        }
+        Collection<String> parameters = IntStream.range(0, length)
+                .mapToObj(i -> (Element) paramNl.item(i)).map(Node::getTextContent)
+                .collect(Collectors.toList());
         return new SessionProjectionChoiceData(id, parameters);
     }
Index: /trunk/src/org/openstreetmap/josm/spi/preferences/AbstractPreferences.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/spi/preferences/AbstractPreferences.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/spi/preferences/AbstractPreferences.java	(revision 16436)
@@ -7,4 +7,5 @@
 import java.util.Map.Entry;
 import java.util.TreeMap;
+import java.util.stream.Collectors;
 
 import org.openstreetmap.josm.tools.Logging;
@@ -158,11 +159,7 @@
      */
     public Map<String, String> getAllPrefix(String prefix) {
-        final Map<String, String> all = new TreeMap<>();
-        for (final Entry<String, Setting<?>> e : getAllSettings().entrySet()) {
-            if (e.getKey().startsWith(prefix) && (e.getValue() instanceof StringSetting)) {
-                all.put(e.getKey(), ((StringSetting) e.getValue()).getValue());
-            }
-        }
-        return all;
+        return getAllSettings().entrySet().stream()
+                .filter(e -> e.getKey().startsWith(prefix) && (e.getValue() instanceof StringSetting))
+                .collect(Collectors.toMap(Entry::getKey, e -> ((StringSetting) e.getValue()).getValue(), (a, b) -> b, TreeMap::new));
     }
 
@@ -173,11 +170,8 @@
      */
     public List<String> getAllPrefixCollectionKeys(String prefix) {
-        final List<String> all = new LinkedList<>();
-        for (Entry<String, Setting<?>> entry : getAllSettings().entrySet()) {
-            if (entry.getKey().startsWith(prefix) && entry.getValue() instanceof ListSetting) {
-                all.add(entry.getKey());
-            }
-        }
-        return all;
+        return getAllSettings().entrySet().stream()
+                .filter(entry -> entry.getKey().startsWith(prefix) && entry.getValue() instanceof ListSetting)
+                .map(Entry::getKey)
+                .collect(Collectors.toCollection(LinkedList::new));
     }
 }
Index: /trunk/src/org/openstreetmap/josm/spi/preferences/ListListSetting.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/spi/preferences/ListListSetting.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/spi/preferences/ListListSetting.java	(revision 16436)
@@ -4,6 +4,9 @@
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
+
+import org.openstreetmap.josm.tools.StreamUtils;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -29,8 +32,7 @@
     public static ListListSetting create(Collection<Collection<String>> value) {
         if (value != null) {
-            List<List<String>> valueList = new ArrayList<>(value.size());
-            for (Collection<String> lst : value) {
-                valueList.add(new ArrayList<>(lst));
-            }
+            List<List<String>> valueList = value.stream()
+                    .map(ArrayList::new)
+                    .collect(Collectors.toList());
             return new ListListSetting(valueList);
         }
@@ -43,10 +45,8 @@
             return new ListListSetting(null);
 
-        List<List<String>> copy = new ArrayList<>(value.size());
-        for (Collection<String> lst : value) {
-            List<String> lstCopy = new ArrayList<>(lst);
-            copy.add(Collections.unmodifiableList(lstCopy));
-        }
-        return new ListListSetting(Collections.unmodifiableList(copy));
+        List<List<String>> copy = value.stream()
+                .map(Utils::toUnmodifiableList)
+                .collect(StreamUtils.toUnmodifiableList());
+        return new ListListSetting(copy);
     }
 
Index: /trunk/src/org/openstreetmap/josm/spi/preferences/MapListSetting.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/spi/preferences/MapListSetting.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/spi/preferences/MapListSetting.java	(revision 16436)
@@ -2,10 +2,11 @@
 package org.openstreetmap.josm.spi.preferences;
 
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.SortedMap;
+
+import org.openstreetmap.josm.tools.StreamUtils;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -28,10 +29,9 @@
         if (value == null)
             return new MapListSetting(null);
-        List<Map<String, String>> copy = new ArrayList<>(value.size());
-        for (Map<String, String> map : value) {
-            Map<String, String> mapCopy = new LinkedHashMap<>(map);
-            copy.add(Collections.unmodifiableMap(mapCopy));
-        }
-        return new MapListSetting(Collections.unmodifiableList(copy));
+        List<Map<String, String>> copy = value.stream()
+                .map(LinkedHashMap::new)
+                .map(Utils::toUnmodifiableMap)
+                .collect(StreamUtils.toUnmodifiableList());
+        return new MapListSetting(copy);
     }
 
Index: /trunk/src/org/openstreetmap/josm/tools/Geometry.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Geometry.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/tools/Geometry.java	(revision 16436)
@@ -760,10 +760,8 @@
      */
     public static double multipolygonArea(Relation multipolygon) {
-        double area = 0.0;
         final Multipolygon mp = MultipolygonCache.getInstance().get(multipolygon);
-        for (Multipolygon.PolyData pd : mp.getCombinedPolygons()) {
-            area += pd.getAreaAndPerimeter(Projections.getProjectionByCode("EPSG:54008")).getArea();
-        }
-        return area;
+        return mp.getCombinedPolygons().stream()
+                .mapToDouble(pd -> pd.getAreaAndPerimeter(Projections.getProjectionByCode("EPSG:54008")).getArea())
+                .sum();
     }
 
@@ -1053,15 +1051,10 @@
                     ? nodeInsidePolygon(nodes.get(0), out.nodes)
                     : PolygonIntersection.FIRST_INSIDE_SECOND == polygonIntersection(a1, out.area)) {
-                boolean insideInner = false;
                 // If inside an outer, check it is not inside an inner
-                for (JoinedPolygon in : outerInner.b) {
-                    if (a1 == null ? nodeInsidePolygon(nodes.get(0), in.nodes)
-                            : in.area.getBounds2D().contains(a1.getBounds2D())
-                                    && polygonIntersection(a1, in.area) == PolygonIntersection.FIRST_INSIDE_SECOND
-                                    && polygonIntersection(in.area, out.area) == PolygonIntersection.FIRST_INSIDE_SECOND) {
-                        insideInner = true;
-                        break;
-                    }
-                }
+                boolean insideInner = outerInner.b.stream().anyMatch(in -> a1 == null
+                        ? nodeInsidePolygon(nodes.get(0), in.nodes)
+                        : in.area.getBounds2D().contains(a1.getBounds2D())
+                        && polygonIntersection(a1, in.area) == PolygonIntersection.FIRST_INSIDE_SECOND
+                        && polygonIntersection(in.area, out.area) == PolygonIntersection.FIRST_INSIDE_SECOND);
                 if (!insideInner) {
                     // Final check using predicate
@@ -1184,12 +1177,7 @@
             } else if (p.isMultipolygon()) {
                 Multipolygon mp = new Multipolygon((Relation) p);
-                boolean inside = true;
                 // a (valid) multipolygon is inside multiPolygon if all outer rings are inside
-                for (PolyData outer : mp.getOuterPolygons()) {
-                    if (!outer.isClosed() || !isPolygonInsideMultiPolygon(outer.getNodes(), outerInner, null)) {
-                        inside = false;
-                        break;
-                    }
-                }
+                boolean inside = mp.getOuterPolygons().stream()
+                        .allMatch(outer -> outer.isClosed() && isPolygonInsideMultiPolygon(outer.getNodes(), outerInner, null));
                 if (inside) {
                     res.add(p);
Index: /trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 16436)
@@ -53,4 +53,5 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.IntStream;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
@@ -1967,9 +1968,6 @@
 
     private static Color parseRGB(String... s) {
-        int[] rgb = new int[3];
         try {
-            for (int i = 0; i < 3; i++) {
-                rgb[i] = Integer.parseInt(s[i]);
-            }
+            int[] rgb = IntStream.range(0, 3).map(i -> Integer.parseInt(s[i])).toArray();
             return new Color(rgb[0], rgb[1], rgb[2]);
         } catch (IllegalArgumentException e) {
Index: /trunk/src/org/openstreetmap/josm/tools/ReflectionUtils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/ReflectionUtils.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/tools/ReflectionUtils.java	(revision 16436)
@@ -7,4 +7,5 @@
 import java.util.Collection;
 import java.util.function.Function;
+import java.util.stream.IntStream;
 
 import org.openstreetmap.josm.plugins.PluginHandler;
@@ -63,11 +64,8 @@
     private static <T extends Object> T findCaller(Function<StackTraceElement, T> getter, Collection<T> exclusions) {
         StackTraceElement[] stack = Thread.currentThread().getStackTrace();
-        for (int i = 3; i < stack.length; i++) {
-            T t = getter.apply(stack[i]);
-            if (exclusions == null || !exclusions.contains(t)) {
-                return t;
-            }
-        }
-        return null;
+        return IntStream.range(3, stack.length)
+                .mapToObj(i -> getter.apply(stack[i]))
+                .filter(t -> exclusions == null || !exclusions.contains(t))
+                .findFirst().orElse(null);
     }
 }
Index: /trunk/src/org/openstreetmap/josm/tools/StreamUtils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/StreamUtils.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/tools/StreamUtils.java	(revision 16436)
@@ -6,4 +6,5 @@
 import java.util.StringJoiner;
 import java.util.stream.Collector;
+import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import java.util.stream.Stream;
@@ -58,3 +59,15 @@
         );
     }
+
+    /**
+     * Creates a new Collector that collects the items in an unmodifiable list
+     * @param <T> the type of the input elements
+     * @return a new Collector that collects the items in an unmodifiable list
+     * @see Utils#toUnmodifiableList
+     * @since xxx
+     */
+    public static <T> Collector<T, ?, List<T>> toUnmodifiableList() {
+        // Java 10: use java.util.stream.Collectors.toUnmodifiableList
+        return Collectors.collectingAndThen(Collectors.toList(), Utils::toUnmodifiableList);
+    }
 }
Index: /trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 16436)
@@ -48,4 +48,5 @@
 import java.util.Locale;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
@@ -156,10 +157,6 @@
     @SafeVarargs
     public static <T> T firstNonNull(T... items) {
-        for (T i : items) {
-            if (i != null) {
-                return i;
-            }
-        }
-        return null;
+        return Arrays.stream(items).filter(Objects::nonNull)
+                .findFirst().orElse(null);
     }
 
@@ -586,11 +583,7 @@
         List<T> sorted = new ArrayList<>();
         for (int i = 0; i < size; ++i) {
-            T parentless = null;
-            for (T key : deps.keySet()) {
-                if (deps.get(key).isEmpty()) {
-                    parentless = key;
-                    break;
-                }
-            }
+            T parentless = deps.keySet().stream()
+                    .filter(key -> deps.get(key).isEmpty())
+                    .findFirst().orElse(null);
             if (parentless == null) throw new JosmRuntimeException("parentless");
             sorted.add(parentless);
@@ -723,10 +716,7 @@
      */
     public static String firstNotEmptyString(String defaultString, String... candidates) {
-        for (String candidate : candidates) {
-            if (!Utils.isStripEmpty(candidate)) {
-                return candidate;
-            }
-        }
-        return defaultString;
+        return Arrays.stream(candidates)
+                .filter(candidate -> !Utils.isStripEmpty(candidate))
+                .findFirst().orElse(defaultString);
     }
 
@@ -739,12 +729,5 @@
      */
     public static boolean isStripEmpty(String str) {
-        if (str != null) {
-            for (int i = 0; i < str.length(); i++) {
-                if (!isStrippedChar(str.charAt(i), null)) {
-                    return false;
-                }
-            }
-        }
-        return true;
+        return str == null || IntStream.range(0, str.length()).allMatch(i -> isStrippedChar(str.charAt(i), null));
     }
 
Index: /trunk/src/org/openstreetmap/josm/tools/WikiReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/WikiReader.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/tools/WikiReader.java	(revision 16436)
@@ -5,4 +5,5 @@
 import java.io.IOException;
 import java.net.URL;
+import java.util.stream.Collectors;
 
 import org.openstreetmap.josm.spi.preferences.Config;
@@ -103,12 +104,9 @@
     }
 
-    private static String readNormal(BufferedReader in, boolean html) throws IOException {
-        StringBuilder b = new StringBuilder();
-        for (String line = in.readLine(); line != null; line = in.readLine()) {
-            if (!line.contains("[[TranslatedPages]]")) {
-                b.append(line.replace(" />", ">")).append('\n');
-            }
-        }
-        return html ? "<html>" + b + "</html>" : b.toString();
+    private static String readNormal(BufferedReader in, boolean html) {
+        String string = in.lines()
+                .filter(line -> !line.contains("[[TranslatedPages]]"))
+                .map(line -> line.replace(" />", ">") + '\n').collect(Collectors.joining());
+        return html ? "<html>" + string + "</html>" : string;
     }
 
Index: /trunk/src/org/openstreetmap/josm/tools/XmlUtils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/XmlUtils.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/tools/XmlUtils.java	(revision 16436)
@@ -4,4 +4,5 @@
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.stream.IntStream;
 
 import javax.xml.XMLConstants;
@@ -171,11 +172,8 @@
     public static Element getFirstChildElement(Node parent) {
         NodeList children = parent.getChildNodes();
-        for (int i = 0; i < children.getLength(); i++) {
-            Node child = children.item(i);
-            if (child instanceof Element) {
-                return (Element) child;
-            }
-        }
-        return null;
+        return (Element) IntStream.range(0, children.getLength())
+                .mapToObj(children::item)
+                .filter(child -> child instanceof Element)
+                .findFirst().orElse(null);
     }
 }
Index: /trunk/src/org/openstreetmap/josm/tools/template_engine/CompoundTemplateEntry.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/template_engine/CompoundTemplateEntry.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/tools/template_engine/CompoundTemplateEntry.java	(revision 16436)
@@ -3,4 +3,5 @@
 
 import java.util.Arrays;
+import java.util.stream.Collectors;
 
 /**
@@ -41,18 +42,10 @@
     @Override
     public boolean isValid(TemplateEngineDataProvider dataProvider) {
-        for (TemplateEntry te: entries) {
-            if (!te.isValid(dataProvider))
-                return false;
-        }
-        return true;
+        return Arrays.stream(entries).allMatch(te -> te.isValid(dataProvider));
     }
 
     @Override
     public String toString() {
-        StringBuilder result = new StringBuilder();
-        for (TemplateEntry te: entries) {
-            result.append(te);
-        }
-        return result.toString();
+        return Arrays.stream(entries).map(String::valueOf).collect(Collectors.joining());
     }
 
Index: /trunk/src/org/openstreetmap/josm/tools/template_engine/Condition.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/template_engine/Condition.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/tools/template_engine/Condition.java	(revision 16436)
@@ -46,11 +46,5 @@
     @Override
     public boolean isValid(TemplateEngineDataProvider dataProvider) {
-
-        for (TemplateEntry entry: entries) {
-            if (entry.isValid(dataProvider))
-                return true;
-        }
-
-        return false;
+        return entries.stream().anyMatch(entry -> entry.isValid(dataProvider));
     }
 
Index: /trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java	(revision 16435)
+++ /trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java	(revision 16436)
@@ -8,4 +8,6 @@
 import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import org.openstreetmap.josm.data.osm.Node;
@@ -94,13 +96,8 @@
             }
 
-            List<OsmPrimitive> result = new ArrayList<>();
-            for (OsmPrimitive child: children) {
-                for (OsmPrimitive parent: child.getReferrers(true)) {
-                    if (condition == null || condition.match(parent)) {
-                        result.add(parent);
-                    }
-                }
-            }
-            return result;
+            return children.stream()
+                    .flatMap(child -> child.getReferrers(true).stream())
+                    .filter(parent -> condition == null || condition.match(parent))
+                    .collect(Collectors.toList());
         }
 
@@ -205,16 +202,8 @@
         @Override
         List<OsmPrimitive> getPrimitives(OsmPrimitive root) {
-            List<OsmPrimitive> result = new ArrayList<>();
-            for (OsmPrimitive o: lhs.getPrimitives(root)) {
-                if (condition == null || condition.match(o)) {
-                    result.add(o);
-                }
-            }
-            for (OsmPrimitive o: rhs.getPrimitives(root)) {
-                if (condition == null || (condition.match(o) && !result.contains(o))) {
-                    result.add(o);
-                }
-            }
-            return result;
+            return Stream.concat(lhs.getPrimitives(root).stream(), rhs.getPrimitives(root).stream())
+                    .filter(o -> condition == null || condition.match(o))
+                    .distinct()
+                    .collect(Collectors.toList());
         }
 
@@ -265,12 +254,9 @@
         @Override
         List<OsmPrimitive> getPrimitives(OsmPrimitive root) {
-            List<OsmPrimitive> result = new ArrayList<>();
             List<OsmPrimitive> lhsList = lhs.getPrimitives(root);
-            for (OsmPrimitive o: rhs.getPrimitives(root)) {
-                if (lhsList.contains(o) && (condition == null || condition.match(o))) {
-                    result.add(o);
-                }
-            }
-            return result;
+            return rhs.getPrimitives(root).stream()
+                    .filter(lhsList::contains)
+                    .filter(o -> condition == null || condition.match(o))
+                    .collect(Collectors.toList());
         }
 
Index: /trunk/test/unit/org/openstreetmap/josm/data/imagery/ShapeTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/imagery/ShapeTest.java	(revision 16436)
+++ /trunk/test/unit/org/openstreetmap/josm/data/imagery/ShapeTest.java	(revision 16436)
@@ -0,0 +1,31 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.data.imagery;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+
+import org.junit.Test;
+
+/**
+ * Unit tests for class {@link Shape}.
+ */
+public class ShapeTest {
+
+    /**
+     * Tests string conversion
+     */
+    @Test
+    public void test() {
+        Shape shape = new Shape();
+        shape.addPoint("47.1", "11.1");
+        shape.addPoint("47.2", "11.2");
+        shape.addPoint("47.3", "11.3");
+        String shapeString = "47.1 11.1 47.2 11.2 47.3 11.3";
+        Shape fromString = new Shape(shapeString, " ");
+        assertEquals(shape, fromString);
+        assertEquals(shapeString, shape.encodeAsString(" "));
+        assertEquals("47.1//11.1//47.2//11.2//47.3//11.3", shape.encodeAsString("//"));
+        assertEquals("47.1,11.1,47.2,11.2,47.3,11.3;47.1,11.1,47.2,11.2,47.3,11.3", Shape.encodeAsString(Arrays.asList(shape, shape)));
+    }
+}
Index: /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java	(revision 16435)
+++ /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java	(revision 16436)
@@ -13,4 +13,6 @@
 import java.util.HashMap;
 import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 import org.junit.Assert;
@@ -65,9 +67,6 @@
         // Add a map with too long values => IllegalArgumentException
         keys = new HashMap<>();
-        StringBuilder b = new StringBuilder(MAX_CHANGESET_TAG_LENGTH + 1);
-        for (int i = 0; i < MAX_CHANGESET_TAG_LENGTH + 1; i++) {
-           b.append("x");
-        }
-        keys.put("test", b.toString());
+        // Java 11: use String.repeat
+        keys.put("test", IntStream.range(0, MAX_CHANGESET_TAG_LENGTH + 1).mapToObj(i -> "x").collect(Collectors.joining()));
         try {
             cs.setKeys(keys);
Index: /trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java	(revision 16435)
+++ /trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java	(revision 16436)
@@ -13,5 +13,4 @@
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -19,4 +18,5 @@
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.stream.Collectors;
 
 import org.junit.BeforeClass;
@@ -160,8 +160,5 @@
     public void testNonRegression() throws IOException {
         List<TestData> allData = readData();
-        Set<String> dataCodes = new HashSet<>();
-        for (TestData data : allData) {
-            dataCodes.add(data.code);
-        }
+        Set<String> dataCodes = allData.stream().map(data -> data.code).collect(Collectors.toSet());
 
         StringBuilder fail = new StringBuilder();
Index: /trunk/test/unit/org/openstreetmap/josm/io/GeoJSONReaderTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/io/GeoJSONReaderTest.java	(revision 16435)
+++ /trunk/test/unit/org/openstreetmap/josm/io/GeoJSONReaderTest.java	(revision 16436)
@@ -15,4 +15,5 @@
 import java.util.List;
 import java.util.Optional;
+import java.util.stream.IntStream;
 
 import org.junit.Rule;
@@ -160,10 +161,6 @@
             return false;
         }
-        for (int i = 0; i < ((Way) p1).getNodes().size(); i++) {
-            if (!areEqualNodes(((Way) p1).getNode(i), ((Way) p2).getNode(i))) {
-                return false;
-            }
-        }
-        return true;
+        return IntStream.range(0, ((Way) p1).getNodes().size())
+                .allMatch(i -> areEqualNodes(((Way) p1).getNode(i), ((Way) p2).getNode(i)));
     }
 }
Index: /trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java	(revision 16435)
+++ /trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java	(revision 16436)
@@ -13,4 +13,5 @@
 import java.security.GeneralSecurityException;
 import java.security.KeyStore.TrustedCertificateEntry;
+import java.util.stream.Collectors;
 
 import org.junit.After;
@@ -88,13 +89,9 @@
         try (InputStream is = connection.getErrorStream()) {
             // TODO this code should be refactored somewhere in Utils as it is used in several JOSM classes
-            StringBuilder responseBody = new StringBuilder();
+            String responseBody;
             try (BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
-                String s;
-                while ((s = in.readLine()) != null) {
-                    responseBody.append(s);
-                    responseBody.append("\n");
-                }
+                responseBody = in.lines().collect(Collectors.joining("\n"));
             }
-            assert responseBody.toString().contains(RequestProcessor.getUsageAsHtml());
+            assert responseBody.contains(RequestProcessor.getUsageAsHtml());
         }
     }
