Ticket #13581: 13581.patch

File 13581.patch, 2.0 KB (added by simon04, 9 years ago)
  • src/org/openstreetmap/josm/data/Preferences.java

    diff --git a/src/org/openstreetmap/josm/data/Preferences.java b/src/org/openstreetmap/josm/data/Preferences.java
    index ec382d8..b700a7f 100644
    a b  
    1717import java.lang.annotation.RetentionPolicy;
    1818import java.lang.reflect.Field;
    1919import java.nio.charset.StandardCharsets;
     20import java.util.AbstractMap;
    2021import java.util.ArrayList;
    2122import java.util.Collection;
    2223import java.util.Collections;
     
    3738import java.util.function.Predicate;
    3839import java.util.regex.Matcher;
    3940import java.util.regex.Pattern;
     41import java.util.stream.Collectors;
    4042import java.util.stream.Stream;
    4143
    4244import javax.json.Json;
    private void removeObsolete(int loadedVersion) {  
    15251527        removeUrlFromEntries(loadedVersion, 10063,
    15261528                "validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries",
    15271529                "resource://data/validator/power.mapcss");
    1528 
     1530        // drop in February 2017
     1531        settingsMap.keySet().stream()
     1532                .filter(key -> key.startsWith("color."))
     1533                .flatMap(key -> {
     1534                    final String newKey = ColorProperty.getColorKey(key.substring("color.".length()));
     1535                    return key.equals(newKey) ? Stream.empty() : Stream.of(new AbstractMap.SimpleImmutableEntry<>(key, newKey));
     1536                })
     1537                .collect(Collectors.toList()) // to avoid ConcurrentModificationException
     1538                .forEach(entry -> {
     1539                    final String oldKey = entry.getKey();
     1540                    final String newKey = entry.getValue();
     1541                    Main.info("Migrating {0} => {1}", oldKey, newKey);
     1542                    put(newKey, get(oldKey));
     1543                    put(oldKey, null);
     1544                });
    15291545        for (String key : OBSOLETE_PREF_KEYS) {
    15301546            if (settingsMap.containsKey(key)) {
    15311547                settingsMap.remove(key);