Changeset 16436 in josm for trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
- Timestamp:
- 2020-05-17T12:08:17+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r16130 r16436 48 48 import org.openstreetmap.josm.tools.Logging; 49 49 import org.openstreetmap.josm.tools.MultiMap; 50 import org.openstreetmap.josm.tools.StreamUtils; 50 51 import org.openstreetmap.josm.tools.Utils; 51 52 … … 95 96 */ 96 97 public static ImageryType fromString(String s) { 97 for (ImageryType type : ImageryType.values()) { 98 if (type.getTypeString().equals(s)) { 99 return type; 100 } 101 } 102 return null; 98 return Arrays.stream(ImageryType.values()) 99 .filter(type -> type.getTypeString().equals(s)) 100 .findFirst().orElse(null); 103 101 } 104 102 } … … 170 168 */ 171 169 public static ImageryCategory fromString(String s) { 172 for (ImageryCategory category : ImageryCategory.values()) { 173 if (category.getCategoryString().equals(s)) { 174 return category; 175 } 176 } 177 return null; 170 return Arrays.stream(ImageryCategory.values()) 171 .filter(category -> category.getCategoryString().equals(s)) 172 .findFirst().orElse(null); 178 173 } 179 174 } … … 403 398 if (i.bounds != null) { 404 399 bounds = i.bounds.encodeAsString(","); 405 StringBuilder shapesString = new StringBuilder(); 406 for (Shape s : i.bounds.getShapes()) { 407 if (shapesString.length() > 0) { 408 shapesString.append(';'); 409 } 410 shapesString.append(s.encodeAsString(",")); 411 } 412 if (shapesString.length() > 0) { 413 shapes = shapesString.toString(); 400 String shapesString = Shape.encodeAsString(i.bounds.getShapes()); 401 if (!shapesString.isEmpty()) { 402 shapes = shapesString; 414 403 } 415 404 } … … 1093 1082 */ 1094 1083 public static Collection<String> getActiveIds() { 1095 ArrayList<String> ids = new ArrayList<>();1096 1084 IPreferences pref = Config.getPref(); 1097 if (pref != null) {1098 List<ImageryPreferenceEntry> entries = StructUtils.getListOfStructs(1099 pref, "imagery.entries", null, ImageryPreferenceEntry.class);1100 if (entries != null) {1101 for (ImageryPreferenceEntry prefEntry : entries) {1102 if (prefEntry.id != null && !prefEntry.id.isEmpty())1103 ids.add(prefEntry.id);1104 }1105 Collections.sort(ids);1106 }1107 }1108 return ids;1085 if (pref == null) { 1086 return Collections.emptyList(); 1087 } 1088 List<ImageryPreferenceEntry> entries = StructUtils.getListOfStructs(pref, "imagery.entries", null, ImageryPreferenceEntry.class); 1089 if (entries == null) { 1090 return Collections.emptyList(); 1091 } 1092 return entries.stream() 1093 .filter(prefEntry -> prefEntry.id != null && !prefEntry.id.isEmpty()) 1094 .map(prefEntry -> prefEntry.id) 1095 .sorted() 1096 .collect(Collectors.toList()); 1109 1097 } 1110 1098 … … 1230 1218 this.serverProjections = serverProjections.stream() 1231 1219 .map(String::intern) 1232 .collect( Collectors.collectingAndThen(Collectors.toList(), Utils::toUnmodifiableList));1220 .collect(StreamUtils.toUnmodifiableList()); 1233 1221 } 1234 1222
Note:
See TracChangeset
for help on using the changeset viewer.