Index: trunk/src/org/openstreetmap/josm/gui/util/LruCache.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/util/LruCache.java	(revision 16187)
+++ trunk/src/org/openstreetmap/josm/gui/util/LruCache.java	(revision 16188)
@@ -4,7 +4,10 @@
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.Objects;
 
 /**
- * LRU cache
+ * LRU cache (least recently used)
+ * @param <K> the type of keys maintained by this map
+ * @param <V> the type of mapped values
  * @see <a href="http://java-planet.blogspot.com/2005/08/how-to-set-up-simple-lru-cache-using.html">
  *     Java Planet: How to set up a simple LRU cache using LinkedHashMap</a>
@@ -14,4 +17,8 @@
     private final int capacity;
 
+    /**
+     * Constructs an empty {@code LruCache} instance with the given capacity
+     * @param capacity the capacity
+     */
     public LruCache(int capacity) {
         super(capacity + 1, 1.1f, true);
@@ -23,3 +30,17 @@
         return size() > capacity;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        if (!super.equals(o)) return false;
+        LruCache<?, ?> lruCache = (LruCache<?, ?>) o;
+        return capacity == lruCache.capacity;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(super.hashCode(), capacity);
+    }
 }
Index: trunk/src/org/openstreetmap/josm/tools/GenericParser.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/GenericParser.java	(revision 16187)
+++ trunk/src/org/openstreetmap/josm/tools/GenericParser.java	(revision 16188)
@@ -10,4 +10,5 @@
  * Utility class to parse various types from other values.
  *
+ * @param <U> the type of the objects to parse
  * @since 16184
  */
@@ -16,4 +17,7 @@
     protected final Map<Class<?>, Function<U, ?>> parsers;
 
+    /**
+     * Creates an empty {@code GenericParser}
+     */
     public GenericParser() {
         this(new LinkedHashMap<>());
@@ -29,4 +33,9 @@
     }
 
+    /**
+     * Creates a new {@code GenericParser} with the same parsers as the specified map
+     *
+     * @param parsers the parsers
+     */
     protected GenericParser(Map<Class<?>, Function<U, ?>> parsers) {
         this.parsers = parsers;
@@ -80,5 +89,5 @@
      * or {@code Optional.empty()} (if parsing fails, or the type is not {@linkplain #supports supported})
      */
-    public <T> Optional<?> tryParse(Class<?> type, U value) {
+    public <T> Optional<T> tryParse(Class<T> type, U value) {
         try {
             return Optional.ofNullable(parse(type, value));
Index: trunk/src/org/openstreetmap/josm/tools/StringParser.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/StringParser.java	(revision 16187)
+++ trunk/src/org/openstreetmap/josm/tools/StringParser.java	(revision 16188)
@@ -36,4 +36,7 @@
             .parsers));
 
+    /**
+     * Creates an empty {@code StringParser}
+     */
     public StringParser() {
         super();
@@ -49,5 +52,5 @@
     }
 
-    protected StringParser(Map<Class<?>, Function<String, ?>> parsers) {
+    private StringParser(Map<Class<?>, Function<String, ?>> parsers) {
         super(parsers);
     }
Index: trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java	(revision 16187)
+++ trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java	(revision 16188)
@@ -126,8 +126,6 @@
         }
 
-        private void setValue(Entry entry, String fieldName, String value) throws SAXException {
-            if (value != null) {
-                value = value.intern();
-            }
+        private void setValue(Entry entry, String fieldName, String value0) throws SAXException {
+            final String value = value0 != null ? value0.intern() : null;
             CheckParameterUtil.ensureParameterNotNull(entry, "entry");
             if ("class".equals(fieldName) || "default".equals(fieldName) || "throw".equals(fieldName) ||
@@ -142,6 +140,8 @@
                     f = entry.getField("locale_" + fieldName.substring(lang.length()));
                 }
-                Optional<?> parsed;
-                if (f != null && Modifier.isPublic(f.getModifiers()) && (parsed = primitiveParsers.tryParse(f.getType(), value)).isPresent()) {
+                Optional<?> parsed = Optional.ofNullable(f)
+                        .filter(field -> Modifier.isPublic(field.getModifiers()))
+                        .flatMap(field -> primitiveParsers.tryParse(field.getType(), value));
+                if (parsed.isPresent()) {
                     f.set(c, parsed.get());
                 } else {
