Ignore:
Timestamp:
2020-05-17T12:08:17+02:00 (6 years ago)
Author:
simon04
Message:

see #19251 - Java 8: use Stream

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/spi/preferences/AbstractPreferences.java

    r14147 r16436  
    77import java.util.Map.Entry;
    88import java.util.TreeMap;
     9import java.util.stream.Collectors;
    910
    1011import org.openstreetmap.josm.tools.Logging;
     
    158159     */
    159160    public Map<String, String> getAllPrefix(String prefix) {
    160         final Map<String, String> all = new TreeMap<>();
    161         for (final Entry<String, Setting<?>> e : getAllSettings().entrySet()) {
    162             if (e.getKey().startsWith(prefix) && (e.getValue() instanceof StringSetting)) {
    163                 all.put(e.getKey(), ((StringSetting) e.getValue()).getValue());
    164             }
    165         }
    166         return all;
     161        return getAllSettings().entrySet().stream()
     162                .filter(e -> e.getKey().startsWith(prefix) && (e.getValue() instanceof StringSetting))
     163                .collect(Collectors.toMap(Entry::getKey, e -> ((StringSetting) e.getValue()).getValue(), (a, b) -> b, TreeMap::new));
    167164    }
    168165
     
    173170     */
    174171    public List<String> getAllPrefixCollectionKeys(String prefix) {
    175         final List<String> all = new LinkedList<>();
    176         for (Entry<String, Setting<?>> entry : getAllSettings().entrySet()) {
    177             if (entry.getKey().startsWith(prefix) && entry.getValue() instanceof ListSetting) {
    178                 all.add(entry.getKey());
    179             }
    180         }
    181         return all;
     172        return getAllSettings().entrySet().stream()
     173                .filter(entry -> entry.getKey().startsWith(prefix) && entry.getValue() instanceof ListSetting)
     174                .map(Entry::getKey)
     175                .collect(Collectors.toCollection(LinkedList::new));
    182176    }
    183177}
Note: See TracChangeset for help on using the changeset viewer.