Changeset 15863 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-02-16T15:46:02+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Utils.java
r15862 r15863 62 62 import java.util.regex.Pattern; 63 63 import java.util.stream.Collectors; 64 import java.util.stream.IntStream; 64 65 import java.util.stream.Stream; 65 66 import java.util.zip.ZipFile; … … 240 241 if (values == null) 241 242 return null; 242 StringBuilder s = null; 243 for (Object a : values) { 244 if (a == null) { 245 a = ""; 246 } 247 if (s != null) { 248 s.append(sep).append(a); 249 } else { 250 s = new StringBuilder(a.toString()); 251 } 252 } 253 return s != null ? s.toString() : ""; 243 return values.stream() 244 .map(v -> v != null ? v.toString() : "") 245 .collect(Collectors.joining(sep)); 254 246 } 255 247 … … 1023 1015 public static List<String> getMatches(final Matcher m) { 1024 1016 if (m.matches()) { 1025 List<String> result = new ArrayList<>(m.groupCount() + 1); 1026 for (int i = 0; i <= m.groupCount(); i++) { 1027 result.add(m.group(i)); 1028 } 1029 return result; 1017 return IntStream.rangeClosed(0, m.groupCount()) 1018 .mapToObj(m::group) 1019 .collect(Collectors.toList()); 1030 1020 } else { 1031 1021 return null; … … 1445 1435 public static boolean hasExtension(String filename, String... extensions) { 1446 1436 String name = filename.toLowerCase(Locale.ENGLISH).replace("?format=raw", ""); 1447 for (String ext : extensions) { 1448 if (name.endsWith('.' + ext.toLowerCase(Locale.ENGLISH))) 1449 return true; 1450 } 1451 return false; 1437 return Arrays.stream(extensions) 1438 .anyMatch(ext -> name.endsWith('.' + ext.toLowerCase(Locale.ENGLISH))); 1452 1439 } 1453 1440
Note:
See TracChangeset
for help on using the changeset viewer.