Changeset 12165 in josm
- Timestamp:
- 2017-05-15T16:15:28+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r12164 r12165 108 108 } 109 109 } 110 privateTracks.addAll(other.getTracks());111 privateRoutes.addAll(other.getRoutes());112 privateWaypoints.addAll(other.getWaypoints());110 other.getTracks().forEach(this::addTrack); 111 other.getRoutes().forEach(this::addRoute); 112 other.getWaypoints().forEach(this::addWaypoint); 113 113 dataSources.addAll(other.dataSources); 114 114 fireInvalidate(); … … 129 129 */ 130 130 public void addTrack(GpxTrack track) { 131 if (privateTracks. contains(track)) {131 if (privateTracks.stream().anyMatch(t -> t == track)) { 132 132 throw new IllegalArgumentException(MessageFormat.format("The track was already added to this data: {0}", track)); 133 133 } … … 143 143 */ 144 144 public void removeTrack(GpxTrack track) { 145 if (!privateTracks.remove (track)) {145 if (!privateTracks.removeIf(t -> t == track)) { 146 146 throw new IllegalArgumentException(MessageFormat.format("The track was not in this data: {0}", track)); 147 147 } … … 165 165 */ 166 166 public void addRoute(GpxRoute route) { 167 if (privateRoutes. contains(route)) {167 if (privateRoutes.stream().anyMatch(r -> r == route)) { 168 168 throw new IllegalArgumentException(MessageFormat.format("The route was already added to this data: {0}", route)); 169 169 } … … 178 178 */ 179 179 public void removeRoute(GpxRoute route) { 180 if (!privateRoutes.remove (route)) {180 if (!privateRoutes.removeIf(r -> r == route)) { 181 181 throw new IllegalArgumentException(MessageFormat.format("The route was not in this data: {0}", route)); 182 182 } … … 199 199 */ 200 200 public void addWaypoint(WayPoint waypoint) { 201 if (privateWaypoints. contains(waypoint)) {201 if (privateWaypoints.stream().anyMatch(w -> w == waypoint)) { 202 202 throw new IllegalArgumentException(MessageFormat.format("The route was already added to this data: {0}", waypoint)); 203 203 } … … 212 212 */ 213 213 public void removeWaypoint(WayPoint waypoint) { 214 if (!privateWaypoints.remove (waypoint)) {214 if (!privateWaypoints.removeIf(w -> w == waypoint)) { 215 215 throw new IllegalArgumentException(MessageFormat.format("The route was not in this data: {0}", waypoint)); 216 216 } … … 580 580 final int prime = 31; 581 581 int result = 1; 582 result = prime * result + dataSources.hashCode();583 result = prime * result + privateRoutes.hashCode();584 result = prime * result + privateTracks.hashCode();585 result = prime * result + privateWaypoints.hashCode();582 result = prime * result + ((dataSources == null) ? 0 : dataSources.hashCode()); 583 result = prime * result + ((privateRoutes == null) ? 0 : privateRoutes.hashCode()); 584 result = prime * result + ((privateTracks == null) ? 0 : privateTracks.hashCode()); 585 result = prime * result + ((privateWaypoints == null) ? 0 : privateWaypoints.hashCode()); 586 586 return result; 587 587 }
Note:
See TracChangeset
for help on using the changeset viewer.