Changeset 16438 in josm for trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
- Timestamp:
- 2020-05-17T14:18:22+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r16187 r16438 32 32 import java.util.Map; 33 33 import java.util.Map.Entry; 34 import java.util.Objects; 34 35 import java.util.Optional; 35 36 import java.util.Set; … … 38 39 import java.util.concurrent.atomic.AtomicInteger; 39 40 import java.util.regex.Pattern; 41 import java.util.stream.Collectors; 42 import java.util.stream.Stream; 40 43 41 44 import javax.swing.AbstractAction; … … 52 55 import org.openstreetmap.josm.data.APIDataSet; 53 56 import org.openstreetmap.josm.data.Bounds; 54 import org.openstreetmap.josm.data.DataSource;55 57 import org.openstreetmap.josm.data.ProjectionBounds; 56 58 import org.openstreetmap.josm.data.UndoRedoHandler; … … 826 828 827 829 private static boolean containsOnlyGpxTags(Tagged t) { 828 for (String key : t.getKeys().keySet()) { 829 if (!GpxConstants.WPT_KEYS.contains(key) && !key.startsWith(GpxConstants.GPX_PREFIX)) { 830 return false; 831 } 832 } 833 return true; 830 return t.getKeys().keySet().stream() 831 .allMatch(key -> GpxConstants.WPT_KEYS.contains(key) || key.startsWith(GpxConstants.GPX_PREFIX)); 834 832 } 835 833 … … 890 888 addStringIfPresent(wpt, n, GpxConstants.GPX_SRC, "source", "source:position"); 891 889 892 Collection<GpxLink> links = new ArrayList<>(); 893 for (String key : new String[]{"link", "url", "website", "contact:website"}) { 894 String value = gpxVal(n, key); 895 if (value != null) { 896 links.add(new GpxLink(value)); 897 } 898 } 890 Collection<GpxLink> links = Stream.of("link", "url", "website", "contact:website") 891 .map(key -> gpxVal(n, key)) 892 .filter(Objects::nonNull) 893 .map(GpxLink::new) 894 .collect(Collectors.toList()); 899 895 wpt.put(GpxConstants.META_LINKS, links); 900 896 … … 968 964 969 965 private static void addStringIfPresent(WayPoint wpt, OsmPrimitive p, String gpxKey, String... osmKeys) { 970 List<String> possibleKeys = new ArrayList<>(Arrays.asList(osmKeys)); 971 possibleKeys.add(0, gpxKey); 972 for (String key : possibleKeys) { 973 String value = gpxVal(p, key); 974 // Sanity checks 975 if (value != null && (!GpxConstants.PT_FIX.equals(gpxKey) || GpxConstants.FIX_VALUES.contains(value))) { 976 wpt.put(gpxKey, value); 977 break; 978 } 979 } 966 Stream.concat(Stream.of(gpxKey), Arrays.stream(osmKeys)) 967 .map(key -> gpxVal(p, key)) 968 // Sanity checks 969 .filter(value -> value != null && (!GpxConstants.PT_FIX.equals(gpxKey) || GpxConstants.FIX_VALUES.contains(value))) 970 .findFirst() 971 .ifPresent(value -> wpt.put(gpxKey, value)); 980 972 } 981 973 … … 1029 1021 return true; 1030 1022 1031 boolean layerBoundsPoint = false; 1032 for (DataSource src : this.data.getDataSources()) { 1033 if (src.bounds.contains(coor)) { 1034 layerBoundsPoint = true; 1035 break; 1036 } 1037 } 1038 return layerBoundsPoint; 1023 return this.data.getDataSources().stream() 1024 .anyMatch(src -> src.bounds.contains(coor)); 1039 1025 } 1040 1026 … … 1229 1215 */ 1230 1216 private boolean isDataSetEmpty() { 1231 if (data != null) { 1232 for (OsmPrimitive osm : data.allNonDeletedPrimitives()) { 1233 if (!osm.isDeleted() || !osm.isNewOrUndeleted()) 1234 return false; 1235 } 1236 } 1237 return true; 1217 return data == null || data.allNonDeletedPrimitives().stream() 1218 .allMatch(osm -> osm.isDeleted() && osm.isNewOrUndeleted()); 1238 1219 } 1239 1220
Note:
See TracChangeset
for help on using the changeset viewer.