Changeset 14147 in josm for trunk/src/org/openstreetmap/josm/spi/preferences
- Timestamp:
- 2018-08-12T15:16:18+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/spi/preferences/AbstractPreferences.java
r14122 r14147 2 2 package org.openstreetmap.josm.spi.preferences; 3 3 4 import java.util.LinkedList; 4 5 import java.util.List; 5 6 import java.util.Map; 7 import java.util.Map.Entry; 8 import java.util.TreeMap; 6 9 7 10 import org.openstreetmap.josm.tools.Logging; … … 148 151 */ 149 152 public abstract <T extends Setting<?>> T getSetting(String key, T def, Class<T> klass); 153 154 /** 155 * Gets all normal (string) settings that have a key starting with the prefix 156 * @param prefix The start of the key 157 * @return The key names of the settings 158 */ 159 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; 167 } 168 169 /** 170 * Gets all list settings that have a key starting with the prefix 171 * @param prefix The start of the key 172 * @return The key names of the list settings 173 */ 174 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; 182 } 150 183 }
Note:
See TracChangeset
for help on using the changeset viewer.