Changeset 14147 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2018-08-12T15:16:18+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r14145 r14147 21 21 import java.util.HashSet; 22 22 import java.util.Iterator; 23 import java.util.LinkedList;24 import java.util.List;25 23 import java.util.Map; 26 24 import java.util.Map.Entry; … … 48 46 import org.openstreetmap.josm.spi.preferences.ListSetting; 49 47 import org.openstreetmap.josm.spi.preferences.Setting; 50 import org.openstreetmap.josm.spi.preferences.StringSetting;51 48 import org.openstreetmap.josm.tools.CheckParameterUtil; 52 49 import org.openstreetmap.josm.tools.ListenerList; … … 286 283 287 284 /** 288 * Gets all normal (string) settings that have a key starting with the prefix289 * @param prefix The start of the key290 * @return The key names of the settings291 */292 public synchronized Map<String, String> getAllPrefix(final String prefix) {293 final Map<String, String> all = new TreeMap<>();294 for (final Entry<String, Setting<?>> e : settingsMap.entrySet()) {295 if (e.getKey().startsWith(prefix) && (e.getValue() instanceof StringSetting)) {296 all.put(e.getKey(), ((StringSetting) e.getValue()).getValue());297 }298 }299 return all;300 }301 302 /**303 * Gets all list settings that have a key starting with the prefix304 * @param prefix The start of the key305 * @return The key names of the list settings306 */307 public synchronized List<String> getAllPrefixCollectionKeys(final String prefix) {308 final List<String> all = new LinkedList<>();309 for (Map.Entry<String, Setting<?>> entry : settingsMap.entrySet()) {310 if (entry.getKey().startsWith(prefix) && entry.getValue() instanceof ListSetting) {311 all.add(entry.getKey());312 }313 }314 return all;315 }316 317 /**318 285 * Get all named colors, including customized and the default ones. 319 286 * @return a map of all named colors (maps preference key to {@link ColorInfo}) -
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.