Index: trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java	(revision 11553)
@@ -17,4 +17,5 @@
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.Set;
 import java.util.Stack;
@@ -520,8 +521,5 @@
 
         protected List<NodePair> getOutboundPairs(Node node) {
-            List<NodePair> l = successors.get(node);
-            if (l == null)
-                return Collections.emptyList();
-            return l;
+            return Optional.ofNullable(successors.get(node)).orElseGet(Collections::emptyList);
         }
 
Index: trunk/src/org/openstreetmap/josm/actions/HelpAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/HelpAction.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/actions/HelpAction.java	(revision 11553)
@@ -8,4 +8,5 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
+import java.util.Optional;
 
 import javax.swing.SwingUtilities;
@@ -62,9 +63,5 @@
                 topic = HelpUtil.getContextSpecificHelpTopic(SwingUtilities.getDeepestComponentAt(Main.parent, mouse.x, mouse.y));
             }
-            if (topic == null) {
-                HelpBrowser.setUrlForHelpTopic("/");
-            } else {
-                HelpBrowser.setUrlForHelpTopic(topic);
-            }
+            HelpBrowser.setUrlForHelpTopic(Optional.ofNullable(topic).orElse("/"));
         } else {
             HelpBrowser.setUrlForHelpTopic("/");
Index: trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java	(revision 11553)
@@ -15,4 +15,5 @@
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.Set;
 
@@ -176,10 +177,6 @@
             lastNode = n;
         }
-        if (targetNode == null) {
-            targetNode = oldestNode != null ? oldestNode : lastNode;
-        }
-        return targetNode;
-    }
-
+        return Optional.ofNullable(targetNode).orElse(oldestNode != null ? oldestNode : lastNode);
+    }
 
     /**
Index: trunk/src/org/openstreetmap/josm/actions/PurgeAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/PurgeAction.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/actions/PurgeAction.java	(revision 11553)
@@ -307,9 +307,5 @@
     protected void updateEnabledState() {
         DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            setEnabled(!ds.selectionEmpty());
-        }
+        setEnabled(ds != null && !ds.selectionEmpty());
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java	(revision 11553)
@@ -18,4 +18,5 @@
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -562,8 +563,5 @@
             }
             Relation c = null;
-            String type = r.get("type");
-            if (type == null) {
-                type = "";
-            }
+            String type = Optional.ofNullable(r.get("type")).orElse("");
 
             int ic = 0;
Index: trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java	(revision 11553)
@@ -10,4 +10,5 @@
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Optional;
 
 import javax.swing.JOptionPane;
@@ -72,10 +73,9 @@
     public static void updatePrimitive(PrimitiveId id) {
         ensureParameterNotNull(id, "id");
-        if (Main.getLayerManager().getEditLayer() == null)
-            throw new IllegalStateException(tr("No current dataset found"));
-        OsmPrimitive primitive = Main.getLayerManager().getEditLayer().data.getPrimitiveById(id);
-        if (primitive == null)
-            throw new IllegalStateException(tr("Did not find an object with id {0} in the current dataset", id));
-        updatePrimitives(Collections.singleton(primitive));
+        updatePrimitives(Collections.singleton(Optional.ofNullable(Optional.ofNullable(
+                Main.getLayerManager().getEditLayer()).orElseThrow(
+                        () -> new IllegalStateException(tr("No current dataset found")))
+                .data.getPrimitiveById(id)).orElseThrow(
+                        () -> new IllegalStateException(tr("Did not find an object with id {0} in the current dataset", id)))));
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/ValidateAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/ValidateAction.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/actions/ValidateAction.java	(revision 11553)
@@ -10,4 +10,5 @@
 import java.util.Collection;
 import java.util.List;
+import java.util.Optional;
 
 import org.openstreetmap.josm.Main;
@@ -55,6 +56,5 @@
      * <p>
      * If getSelectedItems is true, the selected items (or all items, if no one
-     * is selected) are validated. If it is false, last selected items are
-     * revalidated
+     * is selected) are validated. If it is false, last selected items are revalidated
      *
      * @param getSelectedItems If selected or last selected items must be validated
@@ -83,13 +83,9 @@
             }
         } else {
-            if (lastSelection == null) {
-                selection = Main.getLayerManager().getEditDataSet().allNonDeletedPrimitives();
-            } else {
-                selection = lastSelection;
-            }
+            selection = Optional.ofNullable(lastSelection).orElseGet(
+                    () -> Main.getLayerManager().getEditDataSet().allNonDeletedPrimitives());
         }
 
-        ValidationTask task = new ValidationTask(tests, selection, lastSelection);
-        Main.worker.submit(task);
+        Main.worker.submit(new ValidationTask(tests, selection, lastSelection));
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java	(revision 11553)
@@ -8,4 +8,5 @@
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Optional;
 import java.util.concurrent.Future;
 import java.util.regex.Matcher;
@@ -270,8 +271,5 @@
             OsmDataLayer layer = addNewLayerIfRequired(newLayerName);
             if (layer == null) {
-                layer = getEditLayer();
-                if (layer == null) {
-                    layer = getFirstDataLayer();
-                }
+                layer = Optional.ofNullable(getEditLayer()).orElseGet(this::getFirstDataLayer);
                 layer.mergeFrom(dataSet);
                 if (zoomAfterDownload) {
Index: trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java	(revision 11553)
@@ -1261,7 +1261,5 @@
      */
     protected static <T> Collection<T> asColl(T o) {
-        if (o == null)
-            return Collections.emptySet();
-        return Collections.singleton(o);
+        return o == null ? Collections.emptySet() : Collections.singleton(o);
     }
 }
Index: trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java	(revision 11553)
@@ -16,4 +16,5 @@
 import java.util.Locale;
 import java.util.Map;
+import java.util.Optional;
 import java.util.function.Predicate;
 import java.util.regex.Matcher;
@@ -419,9 +420,5 @@
         @Override
         public boolean match(Tagged osm) {
-            Boolean ret = OsmUtils.getOsmBoolean(osm.get(key));
-            if (ret == null)
-                return defaultValue;
-            else
-                return ret;
+            return Optional.ofNullable(OsmUtils.getOsmBoolean(osm.get(key))).orElse(defaultValue);
         }
 
@@ -949,6 +946,5 @@
             this.type = OsmPrimitiveType.from(type);
             if (this.type == null)
-                throw new ParseError(tr("Unknown primitive type: {0}. Allowed values are node, way or relation",
-                        type));
+                throw new ParseError(tr("Unknown primitive type: {0}. Allowed values are node, way or relation", type));
         }
 
@@ -1623,9 +1619,7 @@
      */
     public Match parse() throws ParseError {
-        Match m = parseExpression();
+        Match m = Optional.ofNullable(parseExpression()).orElse(Always.INSTANCE);
         if (!tokenizer.readIfEqual(Token.EOF))
             throw new ParseError(tr("Unexpected token: {0}", tokenizer.nextToken()));
-        if (m == null)
-            m = Always.INSTANCE;
         Main.debug("Parsed search expression is {0}", m);
         return m;
@@ -1758,9 +1752,5 @@
 
     private Match parseFactor(String errorMessage) throws ParseError {
-        Match fact = parseFactor();
-        if (fact == null)
-            throw new ParseError(errorMessage);
-        else
-            return fact;
+        return Optional.ofNullable(parseFactor()).orElseThrow(() -> new ParseError(errorMessage));
     }
 
Index: trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java
===================================================================
--- trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java	(revision 11553)
@@ -9,4 +9,5 @@
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 
 import javax.swing.Icon;
@@ -169,8 +170,6 @@
         Collection<OsmPrimitive> prims = new HashSet<>();
         for (PrimitiveData d : data) {
-            OsmPrimitive osm = getAffectedDataSet().getPrimitiveById(d);
-            if (osm == null)
-                throw new JosmRuntimeException("No primitive found for " + d);
-            prims.add(osm);
+            prims.add(Optional.ofNullable(getAffectedDataSet().getPrimitiveById(d)).orElseThrow(
+                    () -> new JosmRuntimeException("No primitive found for " + d)));
         }
         return prims;
Index: trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 11553)
@@ -283,9 +283,7 @@
      */
     public void removeKeyPreferenceChangeListener(String key, PreferenceChangedListener listener) {
-        ListenerList<PreferenceChangedListener> keyListener = keyListeners.get(key);
-        if (keyListener == null) {
-            throw new IllegalArgumentException("There are no listeners registered for " + key);
-        }
-        keyListener.removeListener(listener);
+        Optional.ofNullable(keyListeners.get(key)).orElseThrow(
+                () -> new IllegalArgumentException("There are no listeners registered for " + key))
+        .removeListener(listener);
     }
 
@@ -1151,9 +1149,5 @@
      */
     public <T> List<T> getListOfStructs(String key, Class<T> klass) {
-        List<T> r = getListOfStructs(key, null, klass);
-        if (r == null)
-            return Collections.emptyList();
-        else
-            return r;
+        return Optional.ofNullable(getListOfStructs(key, null, klass)).orElseGet(Collections::emptyList);
     }
 
@@ -1171,10 +1165,5 @@
         if (prop == null)
             return def == null ? null : new ArrayList<>(def);
-        List<T> lst = new ArrayList<>();
-        for (Map<String, String> entries : prop) {
-            T struct = deserializeStruct(entries, klass);
-            lst.add(struct);
-        }
-        return lst;
+        return prop.stream().map(p -> deserializeStruct(p, klass)).collect(Collectors.toList());
     }
 
@@ -1204,8 +1193,7 @@
         Collection<Map<String, String>> vals = new ArrayList<>();
         for (T struct : l) {
-            if (struct == null) {
-                continue;
-            }
-            vals.add(serializeStruct(struct, klass));
+            if (struct != null) {
+                vals.add(serializeStruct(struct, klass));
+            }
         }
         return vals;
Index: trunk/src/org/openstreetmap/josm/data/SystemOfMeasurement.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/SystemOfMeasurement.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/SystemOfMeasurement.java	(revision 11553)
@@ -9,4 +9,5 @@
 import java.util.Locale;
 import java.util.Map;
+import java.util.Optional;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -115,8 +116,6 @@
      */
     public static SystemOfMeasurement getSystemOfMeasurement() {
-        SystemOfMeasurement som = SystemOfMeasurement.ALL_SYSTEMS.get(ProjectionPreference.PROP_SYSTEM_OF_MEASUREMENT.get());
-        if (som == null)
-            return SystemOfMeasurement.METRIC;
-        return som;
+        return Optional.ofNullable(SystemOfMeasurement.ALL_SYSTEMS.get(ProjectionPreference.PROP_SYSTEM_OF_MEASUREMENT.get()))
+                .orElse(SystemOfMeasurement.METRIC);
     }
 
Index: trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java	(revision 11553)
@@ -5,4 +5,5 @@
 import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.Optional;
 
 import org.openstreetmap.josm.Main;
@@ -74,9 +75,5 @@
      */
     public synchronized void add(final Command c) {
-        DataSet ds = c.getAffectedDataSet();
-        if (ds == null) {
-            // old, legacy behaviour
-            ds = Main.getLayerManager().getEditDataSet();
-        }
+        DataSet ds = Optional.ofNullable(c.getAffectedDataSet()).orElseGet(() -> Main.getLayerManager().getEditDataSet());
         Collection<? extends OsmPrimitive> oldSelection = null;
         if (ds != null) {
Index: trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrack.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrack.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrack.java	(revision 11553)
@@ -70,8 +70,5 @@
     @Override
     public Bounds getBounds() {
-        if (bounds == null)
-            return null;
-        else
-            return new Bounds(bounds);
+        return bounds == null ? null : new Bounds(bounds);
     }
 
Index: trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrackSegment.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrackSegment.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrackSegment.java	(revision 11553)
@@ -54,8 +54,5 @@
     @Override
     public Bounds getBounds() {
-        if (bounds == null)
-            return null;
-        else
-            return new Bounds(bounds);
+        return bounds == null ? null : new Bounds(bounds);
     }
 
Index: trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java	(revision 11553)
@@ -11,4 +11,5 @@
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
@@ -90,9 +91,6 @@
         if (tile != null) {
             TileSource tileSource = tile.getTileSource();
-            String tsName = tileSource.getName();
-            if (tsName == null) {
-                tsName = "";
-            }
-            return tsName.replace(':', '_') + ':' + tileSource.getTileId(tile.getZoom(), tile.getXtile(), tile.getYtile());
+            return Optional.ofNullable(tileSource.getName()).orElse("").replace(':', '_') + ':'
+                    + tileSource.getTileId(tile.getZoom(), tile.getXtile(), tile.getYtile());
         }
         return null;
Index: trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java	(revision 11553)
@@ -17,4 +17,5 @@
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Optional;
 import java.util.Set;
 import java.util.SortedSet;
@@ -479,11 +480,7 @@
      */
     private static TileMatrix parseTileMatrix(XMLStreamReader reader, String matrixCrs) throws XMLStreamException {
-        Projection matrixProj = Projections.getProjectionByCode(matrixCrs);
+        Projection matrixProj = Optional.ofNullable(Projections.getProjectionByCode(matrixCrs))
+                .orElseGet(Main::getProjection); // use current projection if none found. Maybe user is using custom string
         TileMatrix ret = new TileMatrix();
-
-        if (matrixProj == null) {
-            // use current projection if none found. Maybe user is using custom string
-            matrixProj = Main.getProjection();
-        }
         for (int event = reader.getEventType();
                 reader.hasNext() && !(event == XMLStreamReader.END_ELEMENT && QN_TILEMATRIX.equals(reader.getName()));
Index: trunk/src/org/openstreetmap/josm/data/osm/Relation.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/Relation.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/osm/Relation.java	(revision 11553)
@@ -9,4 +9,5 @@
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
@@ -264,8 +265,6 @@
             List<RelationMember> newMembers = new ArrayList<>();
             for (RelationMemberData member : relationData.getMembers()) {
-                OsmPrimitive primitive = getDataSet().getPrimitiveById(member);
-                if (primitive == null)
-                    throw new AssertionError("Data consistency problem - relation with missing member detected");
-                newMembers.add(new RelationMember(member.getRole(), primitive));
+                newMembers.add(new RelationMember(member.getRole(), Optional.ofNullable(getDataSet().getPrimitiveById(member))
+                        .orElseThrow(() -> new AssertionError("Data consistency problem - relation with missing member detected"))));
             }
             setMembers(newMembers);
Index: trunk/src/org/openstreetmap/josm/data/osm/RelationMember.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/RelationMember.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/osm/RelationMember.java	(revision 11553)
@@ -4,4 +4,5 @@
 import java.util.Arrays;
 import java.util.Objects;
+import java.util.Optional;
 
 import org.openstreetmap.josm.tools.CheckParameterUtil;
@@ -133,8 +134,5 @@
     public RelationMember(String role, OsmPrimitive member) {
         CheckParameterUtil.ensureParameterNotNull(member, "member");
-        if (role == null) {
-            role = "";
-        }
-        this.role = role;
+        this.role = Optional.ofNullable(role).orElse("");
         this.member = member;
     }
@@ -150,5 +148,6 @@
     }
 
-    @Override public String toString() {
+    @Override
+    public String toString() {
         return '"' + role + "\"=" + member;
     }
Index: trunk/src/org/openstreetmap/josm/data/osm/TagMap.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/TagMap.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/osm/TagMap.java	(revision 11553)
@@ -13,4 +13,5 @@
 import java.util.Map;
 import java.util.NoSuchElementException;
+import java.util.Objects;
 import java.util.Set;
 
@@ -193,10 +194,6 @@
     @Override
     public synchronized String put(String key, String value) {
-        if (key == null) {
-            throw new NullPointerException();
-        }
-        if (value == null) {
-            throw new NullPointerException();
-        }
+        Objects.requireNonNull(key);
+        Objects.requireNonNull(value);
         int index = indexOfKey(tags, key);
         int newTagArrayLength = tags.length;
Index: trunk/src/org/openstreetmap/josm/data/osm/event/DataChangedEvent.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/event/DataChangedEvent.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/osm/event/DataChangedEvent.java	(revision 11553)
@@ -13,4 +13,9 @@
     private final List<AbstractDatasetChangedEvent> events;
 
+    /**
+     * Constructs a new {@code DataChangedEvent}
+     * @param dataSet data set
+     * @param events list of change events
+     */
     public DataChangedEvent(DataSet dataSet, List<AbstractDatasetChangedEvent> events) {
         super(dataSet);
@@ -18,4 +23,8 @@
     }
 
+    /**
+     * Constructs a new {@code DataChangedEvent}
+     * @param dataSet data set
+     */
     public DataChangedEvent(DataSet dataSet) {
         this(dataSet, null);
@@ -29,8 +38,5 @@
     @Override
     public Collection<OsmPrimitive> getPrimitives() {
-        if (dataSet == null)
-            return Collections.emptyList();
-        else
-            return dataSet.allPrimitives();
+        return dataSet == null ? Collections.emptyList() : dataSet.allPrimitives();
     }
 
@@ -41,5 +47,5 @@
 
     /**
-     *
+     * Returns list of events that caused this DataChangedEvent.
      * @return List of events that caused this DataChangedEvent. Might be null
      */
@@ -47,4 +53,3 @@
         return events;
     }
-
 }
Index: trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java	(revision 11553)
@@ -197,6 +197,5 @@
 
     /**
-     * Sets the tags for this history primitive. Removes all
-     * tags if <code>tags</code> is null.
+     * Sets the tags for this history primitive. Removes all tags if <code>tags</code> is null.
      *
      * @param tags the tags. May be null.
Index: trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/PaintColors.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/PaintColors.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/PaintColors.java	(revision 11553)
@@ -6,4 +6,5 @@
 import java.awt.Color;
 import java.util.List;
+import java.util.Optional;
 
 import org.openstreetmap.josm.data.preferences.CachingProperty;
@@ -79,4 +80,8 @@
     }
 
+    /**
+     * Returns the background color.
+     * @return the background color
+     */
     public static Color getBackgroundColor() {
         if (backgroundColorCache != null)
@@ -92,9 +97,5 @@
             }
         }
-        if (backgroundColorCache == null) {
-            return BACKGROUND.get();
-        } else {
-            return backgroundColorCache;
-        }
+        return Optional.ofNullable(backgroundColorCache).orElseGet(BACKGROUND::get);
     }
 
Index: trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java	(revision 11553)
@@ -1118,8 +1118,5 @@
                     lastNode = tmp;
                 } else {
-                    onewayvia = OsmUtils.getOsmBoolean(onewayviastr);
-                    if (onewayvia == null) {
-                        onewayvia = Boolean.FALSE;
-                    }
+                    onewayvia = Optional.ofNullable(OsmUtils.getOsmBoolean(onewayviastr)).orElse(Boolean.FALSE);
                 }
             }
Index: trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java	(revision 11553)
@@ -11,4 +11,5 @@
 import java.util.Iterator;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 
@@ -668,9 +669,6 @@
 
             for (PolyData pdInner: innerPolygons) {
-                PolyData o = findOuterPolygon(pdInner, combinedPolygons);
-                if (o == null) {
-                    o = outerPolygons.get(0);
-                }
-                o.addInner(pdInner);
+                Optional.ofNullable(findOuterPolygon(pdInner, combinedPolygons)).orElseGet(() -> outerPolygons.get(0))
+                    .addInner(pdInner);
             }
         }
Index: trunk/src/org/openstreetmap/josm/data/preferences/AbstractProperty.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/preferences/AbstractProperty.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/preferences/AbstractProperty.java	(revision 11553)
@@ -38,7 +38,5 @@
             if (this == obj)
                 return true;
-            if (obj == null)
-                return false;
-            if (getClass() != obj.getClass())
+            if (obj == null || getClass() != obj.getClass())
                 return false;
             @SuppressWarnings("unchecked")
@@ -285,7 +283,5 @@
         if (this == obj)
             return true;
-        if (obj == null)
-            return false;
-        if (getClass() != obj.getClass())
+        if (obj == null || getClass() != obj.getClass())
             return false;
         AbstractProperty<?> other = (AbstractProperty<?>) obj;
Index: trunk/src/org/openstreetmap/josm/data/preferences/PreferencesReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/preferences/PreferencesReader.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/preferences/PreferencesReader.java	(revision 11553)
@@ -16,4 +16,5 @@
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.SortedMap;
 import java.util.TreeMap;
@@ -173,9 +174,6 @@
                         setting = new StringSetting(null);
                     } else {
-                        String value = parser.getAttributeValue(null, "value");
-                        if (value == null) {
-                            throw new XMLStreamException(tr("value expected"), parser.getLocation());
-                        }
-                        setting = new StringSetting(value);
+                        setting = new StringSetting(Optional.ofNullable(parser.getAttributeValue(null, "value"))
+                                .orElseThrow(() -> new XMLStreamException(tr("value expected"), parser.getLocation())));
                     }
                     if (defaults) {
Index: trunk/src/org/openstreetmap/josm/data/preferences/PreferencesWriter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/preferences/PreferencesWriter.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/preferences/PreferencesWriter.java	(revision 11553)
@@ -6,4 +6,5 @@
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.stream.Stream;
 
@@ -68,8 +69,5 @@
     private void addTime(Setting<?> setting) {
         if (defaults) {
-            Long time = setting.getTime();
-            if (time == null)
-                throw new IllegalStateException();
-            out.write("' time='" + time);
+            out.write("' time='" + Optional.ofNullable(setting.getTime()).orElseThrow(IllegalStateException::new));
         }
     }
Index: trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java	(revision 11553)
@@ -10,4 +10,5 @@
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.regex.Matcher;
@@ -22,5 +23,4 @@
 import org.openstreetmap.josm.data.projection.datum.Datum;
 import org.openstreetmap.josm.data.projection.datum.NTV2Datum;
-import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileWrapper;
 import org.openstreetmap.josm.data.projection.datum.NullDatum;
 import org.openstreetmap.josm.data.projection.datum.SevenParameterDatum;
@@ -252,10 +252,8 @@
             // "utm" is a shortcut for a set of parameters
             if ("utm".equals(parameters.get(Param.proj.key))) {
-                String zoneStr = parameters.get(Param.zone.key);
-                if (zoneStr == null)
-                    throw new ProjectionConfigurationException(tr("UTM projection (''+proj=utm'') requires ''+zone=...'' parameter."));
                 Integer zone;
                 try {
-                    zone = Integer.valueOf(zoneStr);
+                    zone = Integer.valueOf(Optional.ofNullable(parameters.get(Param.zone.key)).orElseThrow(
+                            () -> new ProjectionConfigurationException(tr("UTM projection (''+proj=utm'') requires ''+zone=...'' parameter."))));
                 } catch (NumberFormatException e) {
                     zone = null;
@@ -394,10 +392,9 @@
         String initKey = parameters.get(Param.init.key);
         if (initKey != null) {
-            String init = Projections.getInit(initKey);
-            if (init == null)
-                throw new ProjectionConfigurationException(tr("Value ''{0}'' for option +init not supported.", initKey));
             Map<String, String> initp;
             try {
-                initp = parseParameterList(init, ignoreUnknownParameter);
+                initp = parseParameterList(Optional.ofNullable(Projections.getInit(initKey)).orElseThrow(
+                        () -> new ProjectionConfigurationException(tr("Value ''{0}'' for option +init not supported.", initKey))),
+                        ignoreUnknownParameter);
                 initp = resolveInits(initp, ignoreUnknownParameter);
             } catch (ProjectionConfigurationException ex) {
@@ -419,10 +416,6 @@
         String code = parameters.get(Param.ellps.key);
         if (code != null) {
-            Ellipsoid ellipsoid = Projections.getEllipsoid(code);
-            if (ellipsoid == null) {
-                throw new ProjectionConfigurationException(tr("Ellipsoid ''{0}'' not supported.", code));
-            } else {
-                return ellipsoid;
-            }
+            return Optional.ofNullable(Projections.getEllipsoid(code)).orElseThrow(
+                () -> new ProjectionConfigurationException(tr("Ellipsoid ''{0}'' not supported.", code)));
         }
         String s = parameters.get(Param.a.key);
@@ -465,7 +458,6 @@
         String datumId = parameters.get(Param.datum.key);
         if (datumId != null) {
-            Datum datum = Projections.getDatum(datumId);
-            if (datum == null) throw new ProjectionConfigurationException(tr("Unknown datum identifier: ''{0}''", datumId));
-            return datum;
+            return Optional.ofNullable(Projections.getDatum(datumId)).orElseThrow(
+                    () -> new ProjectionConfigurationException(tr("Unknown datum identifier: ''{0}''", datumId)));
         }
         if (ellps == null) {
@@ -483,8 +475,7 @@
             if ("null".equals(nadgridsId))
                 return new NullDatum(null, ellps);
-            NTV2GridShiftFileWrapper nadgrids = Projections.getNTV2Grid(nadgridsId);
-            if (nadgrids == null)
-                throw new ProjectionConfigurationException(tr("Grid shift file ''{0}'' for option +nadgrids not supported.", nadgridsId));
-            return new NTV2Datum(nadgridsId, null, ellps, nadgrids);
+            final String fNadgridsId = nadgridsId;
+            return new NTV2Datum(fNadgridsId, null, ellps, Optional.ofNullable(Projections.getNTV2Grid(fNadgridsId)).orElseThrow(
+                    () -> new ProjectionConfigurationException(tr("Grid shift file ''{0}'' for option +nadgrids not supported.", fNadgridsId))));
         }
 
@@ -627,9 +618,7 @@
         if (!parameters.containsKey(parameterName))
             throw new ProjectionConfigurationException(tr("Unknown parameter ''{0}''", parameterName));
-        String doubleStr = parameters.get(parameterName);
-        if (doubleStr == null)
-            throw new ProjectionConfigurationException(
-                    tr("Expected number argument for parameter ''{0}''", parameterName));
-        return parseDouble(doubleStr, parameterName);
+        return parseDouble(Optional.ofNullable(parameters.get(parameterName)).orElseThrow(
+                () -> new ProjectionConfigurationException(tr("Expected number argument for parameter ''{0}''", parameterName))),
+                parameterName);
     }
 
Index: trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java	(revision 11553)
@@ -274,5 +274,5 @@
 
     public int getSubGridCount() {
-        return (subGrid == null) ? 0 : subGrid.length;
+        return subGrid == null ? 0 : subGrid.length;
     }
 
Index: trunk/src/org/openstreetmap/josm/data/validation/Test.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/Test.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/validation/Test.java	(revision 11553)
@@ -9,4 +9,5 @@
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.function.Predicate;
 
@@ -149,9 +150,5 @@
      */
     public void startTest(ProgressMonitor progressMonitor) {
-        if (progressMonitor == null) {
-            this.progressMonitor = NullProgressMonitor.INSTANCE;
-        } else {
-            this.progressMonitor = progressMonitor;
-        }
+        this.progressMonitor = Optional.ofNullable(progressMonitor).orElse(NullProgressMonitor.INSTANCE);
         String startMessage = tr("Running test {0}", name);
         this.progressMonitor.beginTask(startMessage);
Index: trunk/src/org/openstreetmap/josm/data/validation/util/MultipleNameVisitor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/util/MultipleNameVisitor.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/data/validation/util/MultipleNameVisitor.java	(revision 11553)
@@ -5,4 +5,5 @@
 
 import java.util.Collection;
+import java.util.Optional;
 
 import javax.swing.Icon;
@@ -42,8 +43,5 @@
         multipleClassname = null;
         for (OsmPrimitive osm : data) {
-            String name = osm.get("name");
-            if (name == null) {
-                name = osm.get("ref");
-            }
+            String name = Optional.ofNullable(osm.get("name")).orElseGet(() -> osm.get("ref"));
             if (name != null && !name.isEmpty() && multipleName.length() <= MULTIPLE_NAME_MAX_LENGTH) {
                 if (multipleName.length() > 0) {
Index: trunk/src/org/openstreetmap/josm/gui/IconToggleButton.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/IconToggleButton.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/IconToggleButton.java	(revision 11553)
@@ -4,4 +4,5 @@
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.util.Optional;
 
 import javax.swing.Action;
@@ -152,8 +153,5 @@
     @Override
     public Icon getIcon() {
-        Object o = getSafeActionValue(Action.LARGE_ICON_KEY);
-        if (o == null)
-            o = getSafeActionValue(Action.SMALL_ICON);
-        return (Icon) o;
+        return (Icon) Optional.ofNullable(getSafeActionValue(Action.LARGE_ICON_KEY)).orElseGet(() -> getSafeActionValue(Action.SMALL_ICON));
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/MapMover.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MapMover.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/MapMover.java	(revision 11553)
@@ -12,4 +12,5 @@
 import java.awt.event.MouseWheelEvent;
 import java.util.ArrayList;
+import java.util.Optional;
 
 import javax.swing.AbstractAction;
@@ -73,10 +74,8 @@
         public void actionPerformed(ActionEvent e) {
             if (".".equals(action) || ",".equals(action)) {
-                Point mouse = nc.getMousePosition();
-                if (mouse == null)
-                    mouse = new Point((int) nc.getBounds().getCenterX(), (int) nc.getBounds().getCenterY());
-                MouseWheelEvent we = new MouseWheelEvent(nc, e.getID(), e.getWhen(), e.getModifiers(), mouse.x, mouse.y, 0, false,
-                        MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, ",".equals(action) ? -1 : 1);
-                mouseWheelMoved(we);
+                Point mouse = Optional.ofNullable(nc.getMousePosition()).orElseGet(
+                    () -> new Point((int) nc.getBounds().getCenterX(), (int) nc.getBounds().getCenterY()));
+                mouseWheelMoved(new MouseWheelEvent(nc, e.getID(), e.getWhen(), e.getModifiers(), mouse.x, mouse.y, 0, false,
+                        MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, ",".equals(action) ? -1 : 1));
             } else {
                 EastNorth center = nc.getCenter();
Index: trunk/src/org/openstreetmap/josm/gui/MapViewState.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MapViewState.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/MapViewState.java	(revision 11553)
@@ -12,4 +12,5 @@
 import java.io.Serializable;
 import java.util.Objects;
+import java.util.Optional;
 
 import javax.swing.JComponent;
@@ -376,8 +377,6 @@
 
     private static EastNorth calculateDefaultCenter() {
-        Bounds b = DownloadDialog.getSavedDownloadBounds();
-        if (b == null) {
-            b = Main.getProjection().getWorldBoundsLatLon();
-        }
+        Bounds b = Optional.ofNullable(DownloadDialog.getSavedDownloadBounds()).orElseGet(
+                () -> Main.getProjection().getWorldBoundsLatLon());
         return Main.getProjection().latlon2eastNorth(b.getCenter());
     }
Index: trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueResolutionDecision.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueResolutionDecision.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueResolutionDecision.java	(revision 11553)
@@ -9,4 +9,5 @@
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 
 import org.openstreetmap.josm.command.ChangePropertyCommand;
@@ -122,10 +123,6 @@
      */
     public void setNew(String value) {
-        if (value == null) {
-            value = "";
-        }
-        this.value = value;
+        this.value = Optional.ofNullable(value).orElse("");
         this.type = MultiValueDecisionType.KEEP_ONE;
-
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecision.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecision.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecision.java	(revision 11553)
@@ -6,4 +6,5 @@
 
 import java.util.Objects;
+import java.util.Optional;
 
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -58,8 +59,5 @@
 
     public void decide(RelationMemberConflictDecisionType decision) {
-        if (decision == null) {
-            decision = UNDECIDED;
-        }
-        this.decision = decision;
+        this.decision = Optional.ofNullable(decision).orElse(UNDECIDED);
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/LatLonDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/LatLonDialog.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/LatLonDialog.java	(revision 11553)
@@ -12,4 +12,5 @@
 import java.awt.event.WindowEvent;
 import java.util.Arrays;
+import java.util.Optional;
 
 import javax.swing.BorderFactory;
@@ -168,10 +169,8 @@
 
     public void setCoordinates(LatLon ll) {
-        if (ll == null) {
-            ll = LatLon.ZERO;
-        }
-        this.latLonCoordinates = ll;
-        tfLatLon.setText(ll.latToString(CoordinateFormat.getDefaultFormat()) + ' ' + ll.lonToString(CoordinateFormat.getDefaultFormat()));
-        EastNorth en = Main.getProjection().latlon2eastNorth(ll);
+        latLonCoordinates = Optional.ofNullable(ll).orElse(LatLon.ZERO);
+        tfLatLon.setText(latLonCoordinates.latToString(CoordinateFormat.getDefaultFormat()) + ' ' +
+                         latLonCoordinates.lonToString(CoordinateFormat.getDefaultFormat()));
+        EastNorth en = Main.getProjection().latlon2eastNorth(latLonCoordinates);
         tfEastNorth.setText(Double.toString(en.east()) + ' ' + Double.toString(en.north()));
         setOkEnabled(true);
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java	(revision 11553)
@@ -12,4 +12,5 @@
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -41,14 +42,8 @@
 
     static {
-        Color selectionBackground = UIManager.getColor("Table.selectionBackground");
-        if (selectionBackground == null) {
-            selectionBackground = Color.BLUE;
-        }
-        SELECTED_BG = new ColorProperty(marktr("Discardable key: selection Background"), selectionBackground).cached();
-        Color background = UIManager.getColor("Table.background");
-        if (background == null) {
-            background = Color.WHITE;
-        }
-        NORMAL_BG = new ColorProperty(marktr("Discardable key: background"), background).cached();
+        SELECTED_BG = new ColorProperty(marktr("Discardable key: selection Background"),
+                Optional.ofNullable(UIManager.getColor("Table.selectionBackground")).orElse(Color.BLUE)).cached();
+        NORMAL_BG = new ColorProperty(marktr("Discardable key: background"),
+                Optional.ofNullable(UIManager.getColor("Table.background")).orElse(Color.WHITE)).cached();
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java	(revision 11553)
@@ -28,4 +28,5 @@
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Optional;
 import java.util.Set;
 import java.util.TreeMap;
@@ -556,9 +557,5 @@
 
         // Ignore parameter as we do not want to operate always on real selection here, especially in draw mode
-        Collection<OsmPrimitive> newSel = Main.main.getInProgressSelection();
-        if (newSel == null) {
-            newSel = Collections.<OsmPrimitive>emptyList();
-        }
-
+        Collection<OsmPrimitive> newSel = Optional.ofNullable(Main.main.getInProgressSelection()).orElseGet(Collections::emptyList);
         String selectedTag;
         Relation selectedRelation = null;
@@ -616,8 +613,5 @@
                 if (ref instanceof Relation && !ref.isIncomplete() && !ref.isDeleted()) {
                     Relation r = (Relation) ref;
-                    MemberInfo mi = roles.get(r);
-                    if (mi == null) {
-                        mi = new MemberInfo(newSel);
-                    }
+                    MemberInfo mi = Optional.ofNullable(roles.get(r)).orElseGet(() -> new MemberInfo(newSel));
                     roles.put(r, mi);
                     int i = 1;
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java	(revision 11553)
@@ -7,4 +7,5 @@
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 
 import javax.swing.JOptionPane;
@@ -125,11 +126,7 @@
 
     protected void showLastException() {
-        String msg = lastException.getMessage();
-        if (msg == null) {
-            msg = lastException.toString();
-        }
         JOptionPane.showMessageDialog(
                 Main.parent,
-                msg,
+                Optional.ofNullable(lastException.getMessage()).orElseGet(lastException::toString),
                 tr("Error"),
                 JOptionPane.ERROR_MESSAGE
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java	(revision 11553)
@@ -10,4 +10,5 @@
 import java.util.Map.Entry;
 import java.util.Objects;
+import java.util.Optional;
 
 import org.openstreetmap.josm.Main;
@@ -92,6 +93,5 @@
 
     /**
-     * Register the relation editor for a relation managed by a
-     * {@link OsmDataLayer}.
+     * Register the relation editor for a relation managed by a {@link OsmDataLayer}.
      *
      * @param layer the layer
@@ -100,9 +100,5 @@
      */
     public void register(OsmDataLayer layer, Relation relation, RelationEditor editor) {
-        if (relation == null) {
-            relation = new Relation();
-        }
-        DialogContext context = new DialogContext(layer, relation);
-        openDialogs.put(context, editor);
+        openDialogs.put(new DialogContext(layer, Optional.ofNullable(relation).orElseGet(Relation::new)), editor);
         editor.addWindowListener(this);
     }
@@ -110,5 +106,4 @@
     public void updateContext(OsmDataLayer layer, Relation relation, RelationEditor editor) {
         // lookup the entry for editor and remove it
-        //
         for (Iterator<Entry<DialogContext, RelationEditor>> it = openDialogs.entrySet().iterator(); it.hasNext();) {
             Entry<DialogContext, RelationEditor> entry = it.next();
@@ -119,7 +114,5 @@
         }
         // don't add a window listener. Editor is already known to the relation dialog manager
-        //
-        DialogContext context = new DialogContext(layer, relation);
-        openDialogs.put(context, editor);
+        openDialogs.put(new DialogContext(layer, relation), editor);
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/help/ContextSensitiveHelpAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/help/ContextSensitiveHelpAction.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/help/ContextSensitiveHelpAction.java	(revision 11553)
@@ -6,4 +6,5 @@
 
 import java.awt.event.ActionEvent;
+import java.util.Optional;
 
 import javax.swing.AbstractAction;
@@ -28,7 +29,5 @@
      */
     public void setHelpTopic(String relativeHelpTopic) {
-        if (relativeHelpTopic == null)
-            relativeHelpTopic = "/";
-        this.helpTopic = relativeHelpTopic;
+        helpTopic = Optional.ofNullable(relativeHelpTopic).orElse("/");
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java	(revision 11553)
@@ -309,6 +309,5 @@
             throw new IllegalArgumentException(
                     tr("Failed to set reference. Reference ID {0} does not match history ID {1}.", reference.getId(), history.getId()));
-        HistoryOsmPrimitive primitive = history.getByVersion(reference.getVersion());
-        if (primitive == null)
+        if (history.getByVersion(reference.getVersion()) == null)
             throw new IllegalArgumentException(
                     tr("Failed to set reference. Reference version {0} not available in history.", reference.getVersion()));
@@ -340,6 +339,5 @@
             throw new IllegalArgumentException(
                     tr("Failed to set reference. Reference ID {0} does not match history ID {1}.", current.getId(), history.getId()));
-        HistoryOsmPrimitive primitive = history.getByVersion(current.getVersion());
-        if (primitive == null)
+        if (history.getByVersion(current.getVersion()) == null)
             throw new IllegalArgumentException(
                     tr("Failed to set current primitive. Current version {0} not available in history.", current.getVersion()));
@@ -389,6 +387,5 @@
     /**
      * Returns true if <code>primitive</code> is the latest primitive
-     * representing the version currently edited in the current data
-     * layer.
+     * representing the version currently edited in the current data layer.
      *
      * @param primitive the primitive to check
@@ -396,7 +393,5 @@
      */
     public boolean isLatest(HistoryOsmPrimitive primitive) {
-        if (primitive == null)
-            return false;
-        return primitive == latest;
+        return primitive != null && primitive == latest;
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/history/HistoryLoadTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/history/HistoryLoadTask.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/history/HistoryLoadTask.java	(revision 11553)
@@ -135,8 +135,7 @@
         CheckParameterUtil.ensureParameterNotNull(primitives, "primitives");
         for (OsmPrimitive primitive: primitives) {
-            if (primitive == null) {
-                continue;
+            if (primitive != null) {
+                add(primitive);
             }
-            add(primitive);
         }
         return this;
Index: trunk/src/org/openstreetmap/josm/gui/io/CloseChangesetTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/CloseChangesetTask.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/io/CloseChangesetTask.java	(revision 11553)
@@ -8,4 +8,5 @@
 import java.util.Collection;
 import java.util.List;
+import java.util.Optional;
 
 import javax.swing.SwingUtilities;
@@ -38,8 +39,5 @@
     public CloseChangesetTask(Collection<Changeset> changesets) {
         super(tr("Closing changeset"), false /* don't ignore exceptions */);
-        if (changesets == null) {
-            changesets = new ArrayList<>();
-        }
-        this.changesets = changesets;
+        this.changesets = Optional.ofNullable(changesets).orElseGet(ArrayList::new);
         this.closedChangesets = new ArrayList<>();
     }
Index: trunk/src/org/openstreetmap/josm/gui/io/SaveLayerTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/SaveLayerTask.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/io/SaveLayerTask.java	(revision 11553)
@@ -3,4 +3,6 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Optional;
 
 import org.openstreetmap.josm.Main;
@@ -38,9 +40,6 @@
     protected SaveLayerTask(SaveLayerInfo layerInfo, ProgressMonitor monitor) {
         CheckParameterUtil.ensureParameterNotNull(layerInfo, "layerInfo");
-        if (monitor == null) {
-            monitor = NullProgressMonitor.INSTANCE;
-        }
         this.layerInfo = layerInfo;
-        this.parentMonitor = monitor;
+        this.parentMonitor = Optional.ofNullable(monitor).orElse(NullProgressMonitor.INSTANCE);
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java	(revision 11553)
@@ -4,4 +4,5 @@
 import java.awt.BorderLayout;
 import java.util.Map;
+import java.util.Optional;
 
 import javax.swing.JPanel;
@@ -125,8 +126,5 @@
             if (e.getSource() instanceof ChangesetCommentModel) {
                 String newValue = ((ChangesetCommentModel) e.getSource()).getComment();
-                String oldValue = getTagEditorValue(key);
-                if (oldValue == null) {
-                    oldValue = "";
-                }
+                String oldValue = Optional.ofNullable(getTagEditorValue(key)).orElse("");
                 if (!oldValue.equals(newValue)) {
                     setProperty(key, newValue);
Index: trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java	(revision 11553)
@@ -25,4 +25,5 @@
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Optional;
 import java.util.concurrent.TimeUnit;
 
@@ -343,8 +344,5 @@
      */
     public Changeset getChangeset() {
-        Changeset cs = pnlChangesetManagement.getSelectedChangeset();
-        if (cs == null) {
-            cs = new Changeset();
-        }
+        Changeset cs = Optional.ofNullable(pnlChangesetManagement.getSelectedChangeset()).orElseGet(Changeset::new);
         cs.setKeys(pnlTagSettings.getTags(false));
         return cs;
Index: trunk/src/org/openstreetmap/josm/gui/io/UploadLayerTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/UploadLayerTask.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/io/UploadLayerTask.java	(revision 11553)
@@ -6,4 +6,5 @@
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Optional;
 import java.util.Set;
 
@@ -62,9 +63,6 @@
         CheckParameterUtil.ensureParameterNotNull(layer, "layer");
         CheckParameterUtil.ensureParameterNotNull(strategy, "strategy");
-        if (monitor == null) {
-            monitor = NullProgressMonitor.INSTANCE;
-        }
         this.layer = layer;
-        this.monitor = monitor;
+        this.monitor = Optional.ofNullable(monitor).orElse(NullProgressMonitor.INSTANCE);
         this.changeset = changeset;
         this.strategy = strategy;
Index: trunk/src/org/openstreetmap/josm/gui/io/UploadNoteLayerTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/UploadNoteLayerTask.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/io/UploadNoteLayerTask.java	(revision 11553)
@@ -3,4 +3,6 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Optional;
 
 import org.openstreetmap.josm.actions.upload.UploadNotesTask;
@@ -29,9 +31,6 @@
     public UploadNoteLayerTask(NoteLayer layer, ProgressMonitor monitor) {
         CheckParameterUtil.ensureParameterNotNull(layer, "layer");
-        if (monitor == null) {
-            monitor = NullProgressMonitor.INSTANCE;
-        }
         this.layer = layer;
-        this.monitor = monitor;
+        this.monitor = Optional.ofNullable(monitor).orElse(NullProgressMonitor.INSTANCE);
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/io/UploadedObjectsSummaryPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/UploadedObjectsSummaryPanel.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/io/UploadedObjectsSummaryPanel.java	(revision 11553)
@@ -9,4 +9,5 @@
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 
 import javax.swing.AbstractListModel;
@@ -174,9 +175,5 @@
 
         public void setPrimitives(List<OsmPrimitive> primitives) {
-            if (primitives == null) {
-                this.primitives = new ArrayList<>();
-            } else {
-                this.primitives = primitives;
-            }
+            this.primitives = Optional.ofNullable(primitives).orElseGet(ArrayList::new);
             fireContentsChanged(this, 0, getSize());
         }
Index: trunk/src/org/openstreetmap/josm/gui/layer/Layer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/Layer.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/layer/Layer.java	(revision 11553)
@@ -11,4 +11,5 @@
 import java.io.File;
 import java.util.List;
+import java.util.Optional;
 
 import javax.swing.AbstractAction;
@@ -301,10 +302,6 @@
             removeColorPropertyListener();
         }
-        if (name == null) {
-            name = "";
-        }
-
         String oldValue = this.name;
-        this.name = name;
+        this.name = Optional.ofNullable(name).orElse("");
         if (!this.name.equals(oldValue)) {
             propertyChangeSupport.firePropertyChange(NAME_PROP, oldValue, this.name);
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java	(revision 11553)
@@ -37,4 +37,5 @@
 import java.util.Locale;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.TimeZone;
 import java.util.concurrent.TimeUnit;
@@ -581,10 +582,6 @@
         JPanel panelTf = new JPanel(new GridBagLayout());
 
-        String prefTimezone = Main.pref.get("geoimage.timezone", "0:00");
-        if (prefTimezone == null) {
-            prefTimezone = "0:00";
-        }
         try {
-            timezone = Timezone.parseTimezone(prefTimezone);
+            timezone = Timezone.parseTimezone(Optional.ofNullable(Main.pref.get("geoimage.timezone", "0:00")).orElse("0:00"));
         } catch (ParseException e) {
             timezone = Timezone.ZERO;
Index: trunk/src/org/openstreetmap/josm/gui/layer/imagery/ColorfulImageProcessor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/imagery/ColorfulImageProcessor.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/layer/imagery/ColorfulImageProcessor.java	(revision 11553)
@@ -11,4 +11,5 @@
 import java.awt.image.DataBuffer;
 import java.awt.image.DataBufferByte;
+import java.util.Optional;
 
 import org.openstreetmap.josm.Main;
@@ -82,8 +83,5 @@
             }
 
-            BufferedImage dest = dst;
-            if (dest == null) {
-                dest = createCompatibleDestImage(src, null);
-            }
+            BufferedImage dest = Optional.ofNullable(dst).orElseGet(() -> createCompatibleDestImage(src, null));
             DataBuffer srcBuffer = src.getRaster().getDataBuffer();
             DataBuffer destBuffer = dest.getRaster().getDataBuffer();
Index: trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java	(revision 11553)
@@ -23,4 +23,5 @@
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.TimeZone;
 
@@ -196,10 +197,6 @@
 
             URL url = uriToUrl(uri, relativePath);
-
             String urlStr = url == null ? "" : url.toString();
-            String symbolName = wpt.getString("symbol");
-            if (symbolName == null) {
-                symbolName = wpt.getString(GpxConstants.PT_SYM);
-            }
+            String symbolName = Optional.ofNullable(wpt.getString("symbol")).orElseGet(() -> wpt.getString(GpxConstants.PT_SYM));
             // text marker is returned in every case, see #10208
             final Marker marker = new Marker(wpt.getCoor(), wpt, symbolName, parentLayer, time, offset);
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java	(revision 11553)
@@ -3,4 +3,5 @@
 
 import java.util.Arrays;
+import java.util.Optional;
 
 import org.openstreetmap.josm.data.osm.Storage;
@@ -44,9 +45,5 @@
 
         int idx = getIndex(selected);
-        DividedScale<StyleElementList> ds = s.states[idx];
-        if (ds == null) {
-            ds = new DividedScale<>();
-        }
-        s.states[idx] = ds.put(o, r);
+        s.states[idx] = Optional.ofNullable(s.states[idx]).orElseGet(DividedScale::new).put(o, r);
         return s.intern();
     }
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LabelCompositionStrategy.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LabelCompositionStrategy.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LabelCompositionStrategy.java	(revision 11553)
@@ -163,17 +163,16 @@
 
         private static List<String> buildNameTags(List<String> nameTags) {
-            if (nameTags == null) {
-                nameTags = Collections.emptyList();
-            }
             List<String> result = new ArrayList<>();
-            for (String tag: nameTags) {
-                if (tag == null) {
-                    continue;
-                }
-                tag = tag.trim();
-                if (tag.isEmpty()) {
-                    continue;
-                }
-                result.add(tag);
+            if (nameTags != null) {
+                for (String tag: nameTags) {
+                    if (tag == null) {
+                        continue;
+                    }
+                    tag = tag.trim();
+                    if (tag.isEmpty()) {
+                        continue;
+                    }
+                    result.add(tag);
+                }
             }
             return result;
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java	(revision 11553)
@@ -6,4 +6,5 @@
 import java.util.Arrays;
 import java.util.Objects;
+import java.util.Optional;
 
 import org.openstreetmap.josm.Main;
@@ -357,9 +358,5 @@
                 if (casingWidth == null)
                     return null;
-                width = getWidth(c, WIDTH, getWidth(cDef, WIDTH, null));
-                if (width == null) {
-                    width = 0f;
-                }
-                width += 2 * casingWidth;
+                width = Optional.ofNullable(getWidth(c, WIDTH, getWidth(cDef, WIDTH, null))).orElse(0f) + 2 * casingWidth;
                 break;
             case LEFT_CASING:
@@ -378,8 +375,5 @@
 
             /* if we have a "width" tag, try use it */
-            String widthTag = env.osm.get("width");
-            if (widthTag == null) {
-                widthTag = env.osm.get("est_width");
-            }
+            String widthTag = Optional.ofNullable(env.osm.get("width")).orElseGet(() -> env.osm.get("est_width"));
             if (widthTag != null) {
                 try {
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java	(revision 11553)
@@ -167,10 +167,5 @@
             sizeOnDefault = null;
         }
-        Float size = getWidth(c, "symbol-size", sizeOnDefault);
-
-        if (size == null) {
-            size = 10f;
-        }
-
+        Float size = Optional.ofNullable(getWidth(c, "symbol-size", sizeOnDefault)).orElse(10f);
         if (size <= 0)
             return null;
Index: trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java	(revision 11553)
@@ -27,4 +27,5 @@
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -160,8 +161,5 @@
             if (ico != null)
                 return ico;
-            Object o = action.getValue(Action.LARGE_ICON_KEY);
-            if (o == null)
-                o = action.getValue(Action.SMALL_ICON);
-            return (Icon) o;
+            return (Icon) Optional.ofNullable(action.getValue(Action.LARGE_ICON_KEY)).orElseGet(() -> action.getValue(Action.SMALL_ICON));
         }
 
@@ -1193,14 +1191,8 @@
         }
 
-        String tt = action.getDisplayTooltip();
-        if (tt == null) {
-            tt = "";
-        }
+        String tt = Optional.ofNullable(action.getDisplayTooltip()).orElse("");
 
         if (sc == null || paramCode != 0) {
-            String name = (String) action.getAction().getValue("toolbar");
-            if (name == null) {
-                name = action.getDisplayName();
-            }
+            String name = Optional.ofNullable((String) action.getAction().getValue("toolbar")).orElseGet(action::getDisplayName);
             if (paramCode != 0) {
                 name = name+paramCode;
Index: trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PrefEntry.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PrefEntry.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PrefEntry.java	(revision 11553)
@@ -113,7 +113,5 @@
         if (this == obj)
             return true;
-        if (obj == null)
-            return false;
-        if (getClass() != obj.getClass())
+        if (obj == null || getClass() != obj.getClass())
             return false;
         PrefEntry other = (PrefEntry) obj;
Index: trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginUpdatePolicyPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginUpdatePolicyPanel.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginUpdatePolicyPanel.java	(revision 11553)
@@ -11,4 +11,5 @@
 import java.util.Locale;
 import java.util.Map;
+import java.util.Optional;
 
 import javax.swing.ButtonGroup;
@@ -173,26 +174,16 @@
      */
     public final void initFromPreferences() {
-        String pref = Main.pref.get("pluginmanager.version-based-update.policy", "ask");
-        Policy p = Policy.fromPreferenceValue(pref);
-        if (p == null) {
-            p = Policy.ASK;
-        }
-        rbVersionBasedUpatePolicy.get(p).setSelected(true);
-
-        pref = Main.pref.get("pluginmanager.time-based-update.policy", "ask");
-        p = Policy.fromPreferenceValue(pref);
-        if (p == null) {
-            p = Policy.ASK;
-        }
-        rbTimeBasedUpatePolicy.get(p).setSelected(true);
-
-        pref = Main.pref.get("pluginmanager.warntime", null);
+        rbVersionBasedUpatePolicy.get(Optional.ofNullable(Policy.fromPreferenceValue(
+                Main.pref.get("pluginmanager.version-based-update.policy", "ask"))).orElse(Policy.ASK)).setSelected(true);
+        rbTimeBasedUpatePolicy.get(Optional.ofNullable(Policy.fromPreferenceValue(
+                Main.pref.get("pluginmanager.time-based-update.policy", "ask"))).orElse(Policy.ASK)).setSelected(true);
+
+        String pref = Main.pref.get("pluginmanager.warntime", null);
         int days = 0;
         if (pref != null) {
             // remove legacy preference
             Main.pref.put("pluginmanager.warntime", null);
-            pref = pref.trim();
             try {
-                days = Integer.parseInt(pref);
+                days = Integer.parseInt(pref.trim());
             } catch (NumberFormatException e) {
                 // ignore - load from preference pluginmanager.time-based-update.interval
Index: trunk/src/org/openstreetmap/josm/gui/preferences/projection/AbstractProjectionChoice.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/projection/AbstractProjectionChoice.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/projection/AbstractProjectionChoice.java	(revision 11553)
@@ -1,4 +1,6 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.gui.preferences.projection;
+
+import java.util.Optional;
 
 import org.openstreetmap.josm.data.projection.CustomProjection;
@@ -60,8 +62,6 @@
     public Projection getProjection() {
         String code = getCurrentCode();
-        String pref = Projections.getInit(code);
-        if (pref == null)
-            throw new AssertionError("Error: Unknown projection code");
-        return new CustomProjection(getProjectionName(), code, pref, getCacheDir());
+        return new CustomProjection(getProjectionName(), code, Optional.ofNullable(Projections.getInit(code))
+                .orElseThrow(() -> new AssertionError("Error: Unknown projection code: " + code)), getCacheDir());
     }
 }
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java	(revision 11553)
@@ -18,4 +18,5 @@
 import java.util.Locale;
 import java.util.Map;
+import java.util.Optional;
 
 import javax.swing.BorderFactory;
@@ -322,9 +323,5 @@
      */
     public final void initFromPreferences() {
-        String policy = Main.pref.get(PROXY_POLICY, null);
-        ProxyPolicy pp = ProxyPolicy.fromName(policy);
-        if (pp == null) {
-            pp = ProxyPolicy.NO_PROXY;
-        }
+        ProxyPolicy pp = Optional.ofNullable(ProxyPolicy.fromName(Main.pref.get(PROXY_POLICY, null))).orElse(ProxyPolicy.NO_PROXY);
         rbProxyPolicy.get(pp).setSelected(true);
         String value = Main.pref.get("proxy.host", null);
@@ -419,8 +416,5 @@
             }
         }
-        if (policy == null) {
-            policy = ProxyPolicy.NO_PROXY;
-        }
-        Main.pref.put(PROXY_POLICY, policy.getName());
+        Main.pref.put(PROXY_POLICY, Optional.ofNullable(policy).orElse(ProxyPolicy.NO_PROXY).getName());
         Main.pref.put(PROXY_HTTP_HOST, tfProxyHttpHost.getText());
         Main.pref.put(PROXY_HTTP_PORT, tfProxyHttpPort.getText());
Index: trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java	(revision 11553)
@@ -508,9 +508,6 @@
     public void addCommands(List<Tag> changedTags) {
         Object obj = getSelectedItem();
-        String display = (obj == null) ? null : obj.toString();
+        String display = obj == null ? getDisplayIfNull() : obj.toString();
         String value = null;
-        if (display == null) {
-            display = getDisplayIfNull();
-        }
 
         if (display != null) {
Index: trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Link.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Link.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Link.java	(revision 11553)
@@ -26,8 +26,5 @@
     public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {
         initializeLocaleText(tr("More information about this feature"));
-        String url = locale_href;
-        if (url == null) {
-            url = href;
-        }
+        String url = java.util.Optional.ofNullable(locale_href).orElse(href);
         if (url != null) {
             p.add(new UrlLabel(url, locale_text, 2), GBC.eol().insets(0, 10, 0, 0).fill(GBC.HORIZONTAL));
Index: trunk/src/org/openstreetmap/josm/gui/util/CursorManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/util/CursorManager.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/util/CursorManager.java	(revision 11553)
@@ -6,4 +6,5 @@
 import java.util.Iterator;
 import java.util.LinkedHashMap;
+import java.util.Objects;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -50,7 +51,5 @@
      */
     public synchronized void setNewCursor(Cursor cursor, Object reference) {
-        if (reference == null) {
-            throw new NullPointerException("Cannot register a cursor that can never be removed.");
-        }
+        Objects.requireNonNull(reference, "Cannot register a cursor that can never be removed.");
         // re-insert to allow overriding.
         cursors.remove(reference);
Index: trunk/src/org/openstreetmap/josm/gui/widgets/HtmlPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/widgets/HtmlPanel.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/gui/widgets/HtmlPanel.java	(revision 11553)
@@ -5,4 +5,5 @@
 import java.awt.Font;
 import java.text.MessageFormat;
+import java.util.Optional;
 
 import javax.swing.JEditorPane;
@@ -85,8 +86,5 @@
      */
     public final void setText(String text) {
-        if (text == null) {
-            text = "";
-        }
-        jepMessage.setText(text);
+        jepMessage.setText(Optional.ofNullable(text).orElse(""));
     }
 }
Index: trunk/src/org/openstreetmap/josm/io/DiffResultProcessor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/DiffResultProcessor.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/io/DiffResultProcessor.java	(revision 11553)
@@ -12,4 +12,5 @@
 import java.util.HashSet;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 
@@ -61,8 +62,5 @@
      */
     public DiffResultProcessor(Collection<? extends OsmPrimitive> primitives) {
-        if (primitives == null) {
-            primitives = Collections.emptyList();
-        }
-        this.primitives = primitives;
+        this.primitives = Optional.ofNullable(primitives).orElseGet(Collections::emptyList);
         this.processed = new HashSet<>();
     }
Index: trunk/src/org/openstreetmap/josm/io/GpxExporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/GpxExporter.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/io/GpxExporter.java	(revision 11553)
@@ -13,4 +13,5 @@
 import java.text.MessageFormat;
 import java.time.Year;
+import java.util.Optional;
 
 import javax.swing.JButton;
@@ -223,16 +224,10 @@
         if (enable) {
             if (copyrightYear.getText().isEmpty()) {
-                String sCopyrightYear = data.getString(META_COPYRIGHT_YEAR);
-                if (sCopyrightYear == null) {
-                    sCopyrightYear = Year.now().toString();
-                }
-                copyrightYear.setText(sCopyrightYear);
+                copyrightYear.setText(Optional.ofNullable(data.getString(META_COPYRIGHT_YEAR)).orElseGet(
+                        () -> Year.now().toString()));
             }
             if (copyright.getText().isEmpty()) {
-                String sCopyright = data.getString(META_COPYRIGHT_LICENSE);
-                if (sCopyright == null) {
-                    sCopyright = Main.pref.get("lastCopyright", "https://creativecommons.org/licenses/by-sa/2.5");
-                }
-                copyright.setText(sCopyright);
+                copyright.setText(Optional.ofNullable(data.getString(META_COPYRIGHT_LICENSE)).orElseGet(
+                        () -> Main.pref.get("lastCopyright", "https://creativecommons.org/licenses/by-sa/2.5")));
                 copyright.setCaretPosition(0);
             }
@@ -282,14 +277,6 @@
             emailLabel.setEnabled(b);
             if (b) {
-                String sAuthorName = data.getString(META_AUTHOR_NAME);
-                if (sAuthorName == null) {
-                    sAuthorName = Main.pref.get("lastAuthorName");
-                }
-                authorName.setText(sAuthorName);
-                String sEmail = data.getString(META_AUTHOR_EMAIL);
-                if (sEmail == null) {
-                    sEmail = Main.pref.get("lastAuthorEmail");
-                }
-                email.setText(sEmail);
+                authorName.setText(Optional.ofNullable(data.getString(META_AUTHOR_NAME)).orElseGet(() -> Main.pref.get("lastAuthorName")));
+                email.setText(Optional.ofNullable(data.getString(META_AUTHOR_EMAIL)).orElseGet(() -> Main.pref.get("lastAuthorEmail")));
             } else {
                 authorName.setText("");
Index: trunk/src/org/openstreetmap/josm/io/NmeaReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/NmeaReader.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/io/NmeaReader.java	(revision 11553)
@@ -13,4 +13,5 @@
 import java.util.Collections;
 import java.util.Date;
+import java.util.Optional;
 
 import org.openstreetmap.josm.Main;
@@ -112,8 +113,6 @@
 
     private Date readTime(String p) {
-        Date d = rmcTimeFmt.parse(p, new ParsePosition(0));
-        if (d == null) {
-            d = rmcTimeFmtStd.parse(p, new ParsePosition(0));
-        }
+        Date d = Optional.ofNullable(rmcTimeFmt.parse(p, new ParsePosition(0)))
+                .orElseGet(() -> rmcTimeFmtStd.parse(p, new ParsePosition(0)));
         if (d == null)
             throw new JosmRuntimeException("Date is malformed");
Index: trunk/src/org/openstreetmap/josm/io/NoteReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/NoteReader.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/io/NoteReader.java	(revision 11553)
@@ -10,4 +10,5 @@
 import java.util.List;
 import java.util.Locale;
+import java.util.Optional;
 
 import javax.xml.parsers.ParserConfigurationException;
@@ -110,19 +111,9 @@
                 break;
             case "comment":
-                String uidStr = attrs.getValue("uid");
-                if (uidStr == null) {
-                    commentUid = 0;
-                } else {
-                    commentUid = Long.parseLong(uidStr);
-                }
+                commentUid = Long.parseLong(Optional.ofNullable(attrs.getValue("uid")).orElse("0"));
                 commentUsername = attrs.getValue("user");
                 noteAction = Action.valueOf(attrs.getValue("action").toUpperCase(Locale.ENGLISH));
                 commentCreateDate = DateUtils.fromString(attrs.getValue("timestamp"));
-                String isNew = attrs.getValue("is_new");
-                if (isNew == null) {
-                    commentIsNew = false;
-                } else {
-                    commentIsNew = Boolean.parseBoolean(isNew);
-                }
+                commentIsNew = Boolean.parseBoolean(Optional.ofNullable(attrs.getValue("is_new")).orElse("false"));
                 break;
             default: // Do nothing
Index: trunk/src/org/openstreetmap/josm/io/ProgressInputStream.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/ProgressInputStream.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/io/ProgressInputStream.java	(revision 11553)
@@ -7,4 +7,5 @@
 import java.io.InputStream;
 import java.net.URLConnection;
+import java.util.Optional;
 
 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
@@ -31,8 +32,6 @@
     public ProgressInputStream(InputStream in, long size, ProgressMonitor progressMonitor) {
         CheckParameterUtil.ensureParameterNotNull(in, "in");
-        if (progressMonitor == null) {
-            progressMonitor = NullProgressMonitor.INSTANCE;
-        }
-        this.updater = new StreamProgressUpdater(size, progressMonitor, tr("Downloading data..."));
+        this.updater = new StreamProgressUpdater(size,
+                Optional.ofNullable(progressMonitor).orElse(NullProgressMonitor.INSTANCE), tr("Downloading data..."));
         this.in = in;
     }
Index: trunk/src/org/openstreetmap/josm/io/StreamProgressUpdater.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/StreamProgressUpdater.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/io/StreamProgressUpdater.java	(revision 11553)
@@ -3,4 +3,5 @@
 
 import java.util.Locale;
+import java.util.Optional;
 
 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
@@ -17,9 +18,6 @@
 
     StreamProgressUpdater(long size, ProgressMonitor progressMonitor, String taskTitle) {
-        if (progressMonitor == null) {
-            progressMonitor = NullProgressMonitor.INSTANCE;
-        }
         this.size = size;
-        this.progressMonitor = progressMonitor;
+        this.progressMonitor = Optional.ofNullable(progressMonitor).orElse(NullProgressMonitor.INSTANCE);
         this.taskTitle = taskTitle;
         initProgressMonitor();
Index: trunk/src/org/openstreetmap/josm/io/UTFInputStreamReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/UTFInputStreamReader.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/io/UTFInputStreamReader.java	(revision 11553)
@@ -7,4 +7,5 @@
 import java.io.PushbackInputStream;
 import java.io.UnsupportedEncodingException;
+import java.util.Optional;
 
 /**
@@ -67,9 +68,5 @@
             pushbackStream.unread(bom, 0, 0);
         }
-
-        if (encoding == null) {
-            encoding = "UTF-8";
-        }
-        return new UTFInputStreamReader(pushbackStream, encoding);
+        return new UTFInputStreamReader(pushbackStream, Optional.ofNullable(encoding).orElse("UTF-8"));
     }
 }
Index: trunk/src/org/openstreetmap/josm/io/XmlStreamParsingException.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/XmlStreamParsingException.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/io/XmlStreamParsingException.java	(revision 11553)
@@ -3,4 +3,6 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Optional;
 
 import javax.xml.stream.Location;
@@ -37,8 +39,5 @@
     @Override
     public String getMessage() {
-        String msg = super.getMessage();
-        if (msg == null) {
-            msg = getClass().getName();
-        }
+        String msg = Optional.ofNullable(super.getMessage()).orElseGet(() -> getClass().getName());
         if (getLocation() == null)
             return msg;
Index: trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java	(revision 11553)
@@ -18,4 +18,5 @@
 import java.util.Locale;
 import java.util.Map;
+import java.util.Optional;
 import java.util.TreeMap;
 import java.util.jar.Attributes;
@@ -199,8 +200,5 @@
         Attributes attr = manifest.getMainAttributes();
         className = attr.getValue("Plugin-Class");
-        String s = attr.getValue(lang+"Plugin-Link");
-        if (s == null) {
-            s = attr.getValue("Plugin-Link");
-        }
+        String s = Optional.ofNullable(attr.getValue(lang+"Plugin-Link")).orElseGet(() -> attr.getValue("Plugin-Link"));
         if (s != null && !Utils.isValidUrl(s)) {
             Main.info(tr("Invalid URL ''{0}'' in plugin {1}", s, name));
Index: trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java	(revision 11553)
@@ -22,4 +22,5 @@
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 
@@ -54,8 +55,5 @@
 
     protected final void init(Collection<String> sites, boolean displayErrMsg) {
-        this.sites = sites;
-        if (sites == null) {
-            this.sites = Collections.emptySet();
-        }
+        this.sites = Optional.ofNullable(sites).orElseGet(Collections::emptySet);
         this.availablePlugins = new LinkedList<>();
         this.displayErrMsg = displayErrMsg;
Index: trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java	(revision 11553)
@@ -15,4 +15,5 @@
 import java.util.Collection;
 import java.util.Date;
+import java.util.Optional;
 import java.util.TreeSet;
 import java.util.regex.Matcher;
@@ -362,11 +363,4 @@
     public static String explainGenericOsmApiException(OsmApiException e) {
         Main.error(e);
-        String errMsg = e.getErrorHeader();
-        if (errMsg == null) {
-            errMsg = e.getErrorBody();
-        }
-        if (errMsg == null) {
-            errMsg = tr("no error message available");
-        }
         return tr("<html>"
                 + "Communication with the OSM server ''{0}''failed. The server replied<br>"
@@ -377,5 +371,6 @@
                 getUrlFromException(e),
                 e.getResponseCode(),
-                errMsg
+                Optional.ofNullable(Optional.ofNullable(e.getErrorHeader()).orElseGet(e::getErrorBody))
+                    .orElse(tr("no error message available"))
         );
     }
Index: trunk/src/org/openstreetmap/josm/tools/HttpClient.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 11553)
@@ -19,4 +19,5 @@
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Optional;
 import java.util.Scanner;
 import java.util.TreeMap;
@@ -148,7 +149,6 @@
                 if (redirectLocation == null) {
                     /* I18n: argument is HTTP response code */
-                    String msg = tr("Unexpected response from HTTP server. Got {0} response without ''Location'' header." +
-                            " Can''t redirect. Aborting.", connection.getResponseCode());
-                    throw new IOException(msg);
+                    throw new IOException(tr("Unexpected response from HTTP server. Got {0} response without ''Location'' header." +
+                            " Can''t redirect. Aborting.", connection.getResponseCode()));
                 } else if (maxRedirects > 0) {
                     url = new URL(url, redirectLocation);
@@ -284,8 +284,5 @@
             } catch (IOException ioe) {
                 Main.debug(ioe);
-                in = connection.getErrorStream();
-                if (in == null) {
-                    in = new ByteArrayInputStream(new byte[]{});
-                }
+                in = Optional.ofNullable(connection.getErrorStream()).orElseGet(() -> new ByteArrayInputStream(new byte[]{}));
             }
             in = new ProgressInputStream(in, getContentLength(), monitor);
Index: trunk/src/org/openstreetmap/josm/tools/Shortcut.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Shortcut.java	(revision 11552)
+++ trunk/src/org/openstreetmap/josm/tools/Shortcut.java	(revision 11553)
@@ -384,8 +384,5 @@
 
     private static int getGroupModifier(int group) {
-        Integer m = groups.get(group);
-        if (m == null)
-            m = -1;
-        return m;
+        return Optional.ofNullable(groups.get(group)).orElse(-1);
     }
 
