Changeset 15418 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2019-10-05T15:51:53+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java
r15362 r15418 19 19 import java.util.Set; 20 20 import java.util.function.Consumer; 21 import java.util.stream.Collectors;22 21 23 22 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; … … 468 467 } 469 468 470 static List< OsmPrimitive> findVias(Relation r, String type) {469 static List<? extends OsmPrimitive> findVias(Relation r, String type) { 471 470 if (type != null) { 472 471 switch (type) { 473 472 case "connectivity": 474 473 case "restriction": 475 return findRelationMembers(r,"via");474 return r.findRelationMembers("via"); 476 475 case "destination_sign": 477 476 // Prefer intersection over sign, see #12347 478 List< OsmPrimitive> intersections = findRelationMembers(r,"intersection");479 return intersections.isEmpty() ? findRelationMembers(r,"sign") : intersections;477 List<? extends OsmPrimitive> intersections = r.findRelationMembers("intersection"); 478 return intersections.isEmpty() ? r.findRelationMembers("sign") : intersections; 480 479 default: 481 480 break; … … 483 482 } 484 483 return Collections.emptyList(); 485 }486 487 static List<OsmPrimitive> findRelationMembers(Relation r, String role) {488 return r.getMembers().stream().filter(rmv -> role.equals(rmv.getRole()))489 .map(RelationMember::getMember).collect(Collectors.toList());490 484 } 491 485 -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r15404 r15418 23 23 import java.util.function.Function; 24 24 import java.util.function.Predicate; 25 import java.util.stream.Collectors; 25 26 import java.util.stream.Stream; 26 27 … … 214 215 for (Relation r : relations) { 215 216 Relation newRelation = (Relation) primMap.get(r); 216 List<RelationMember> newMembers = new ArrayList<>(); 217 for (RelationMember rm : r.getMembers()) { 218 newMembers.add(new RelationMember(rm.getRole(), primMap.get(rm.getMember()))); 219 } 220 newRelation.setMembers(newMembers); 217 newRelation.setMembers(r.getMembers().stream() 218 .map(rm -> new RelationMember(rm.getRole(), primMap.get(rm.getMember()))) 219 .collect(Collectors.toList())); 221 220 } 222 221 for (DataSource source : copyFrom.dataSources) { -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r15127 r15418 274 274 throw new IllegalStateException(tr("Missing merge target of type {0} with id {1}", 275 275 sourceMember.getType(), sourceMember.getUniqueId())); 276 RelationMember newMember = new RelationMember(sourceMember.getRole(), targetMember); 277 newMembers.add(newMember); 276 newMembers.add(new RelationMember(sourceMember.getRole(), targetMember)); 278 277 if (targetMember.isDeleted() && !conflicts.hasConflictForMy(targetMember)) { 279 278 addConflict(new Conflict<>(targetMember, sourceMember.getMember(), true)); -
trunk/src/org/openstreetmap/josm/data/osm/IRelation.java
r13957 r15418 6 6 import java.util.List; 7 7 import java.util.Set; 8 import java.util.stream.Collectors; 8 9 9 10 import org.openstreetmap.josm.tools.Utils; … … 124 125 return ret; 125 126 } 127 128 /** 129 * Returns a list of relation members having the specified role. 130 * @param role role 131 * @return a list of relation members having the specified role 132 * @since 15418 133 */ 134 default List<? extends IPrimitive> findRelationMembers(String role) { 135 return getMembers().stream().filter(rmv -> role.equals(rmv.getRole())) 136 .map(IRelationMember::getMember).collect(Collectors.toList()); 137 } 126 138 } -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r15361 r15418 543 543 return Stream.of(members).map(RelationMember::getRole).filter(role -> !role.isEmpty()).collect(Collectors.toSet()); 544 544 } 545 546 @Override 547 public List<? extends OsmPrimitive> findRelationMembers(String role) { 548 return IRelation.super.findRelationMembers(role).stream() 549 .filter(m -> m instanceof OsmPrimitive) 550 .map(m -> (OsmPrimitive) m).collect(Collectors.toList()); 551 } 545 552 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitor.java
r13907 r15418 6 6 import java.util.List; 7 7 import java.util.Map; 8 import java.util.stream.Collectors; 8 9 9 10 import org.openstreetmap.josm.data.osm.DataSet; … … 100 101 } 101 102 102 List<RelationMemberData> newMembers = new ArrayList<>(); 103 for (RelationMember member: r.getMembers()) { 104 newMembers.add(new RelationMemberData(member.getRole(), mappedPrimitives.get(member.getMember()))); 105 106 } 107 clone.setMembers(newMembers); 103 clone.setMembers(r.getMembers().stream() 104 .map(m -> new RelationMemberData(m.getRole(), mappedPrimitives.get(m.getMember()))) 105 .collect(Collectors.toList())); 108 106 } 109 107 -
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r14990 r15418 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 7 import java.util.ArrayList; 7 8 import java.util.Collection; 8 9 import java.util.EnumSet; … … 10 11 import java.util.LinkedHashMap; 11 12 import java.util.LinkedList; 13 import java.util.List; 12 14 import java.util.Map; 13 15 import java.util.stream.Collectors; … … 317 319 // verify unwanted members 318 320 for (String key : map.keySet()) { 319 boolean found = false; 320 for (Role r: allroles.keySet()) { 321 if (r.isRole(key)) { 322 found = true; 323 break; 324 } 325 } 326 327 if (!found) { 321 if (allroles.keySet().stream().noneMatch(role -> role.isRole(key))) { 328 322 String templates = allroles.keySet().stream().map(r -> r.key).collect(Collectors.joining("/")); 323 List<OsmPrimitive> primitives = new ArrayList<>(n.findRelationMembers(key)); 324 primitives.add(0, n); 329 325 330 326 if (!key.isEmpty()) { 331 327 errors.add(TestError.builder(this, Severity.WARNING, ROLE_UNKNOWN) 332 328 .message(ROLE_VERIF_PROBLEM_MSG, marktr("Role ''{0}'' is not in templates ''{1}''"), key, templates) 333 .primitives( n)329 .primitives(primitives) 334 330 .build()); 335 331 } else { 336 332 errors.add(TestError.builder(this, Severity.WARNING, ROLE_EMPTY) 337 333 .message(ROLE_VERIF_PROBLEM_MSG, marktr("Empty role found when expecting one of ''{0}''"), templates) 338 .primitives( n)334 .primitives(primitives) 339 335 .build()); 340 336 } -
trunk/src/org/openstreetmap/josm/gui/datatransfer/RelationMemberTransferable.java
r12663 r15418 11 11 import java.util.Collections; 12 12 import java.util.HashSet; 13 import java.util.stream.Collectors; 13 14 14 15 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; … … 51 52 */ 52 53 public static Data getData(Collection<RelationMember> members) { 53 final Collection<RelationMemberData> r = new ArrayList<>(members.size()); 54 for (RelationMember member : members) { 55 r.add(new RelationMemberData(member.getRole(), member.getType(), member.getUniqueId())); 56 } 57 return new Data(r); 54 return new Data(members.stream() 55 .map(m -> new RelationMemberData(m.getRole(), m.getType(), m.getUniqueId())) 56 .collect(Collectors.toList())); 58 57 } 59 58 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorter.java
r15361 r15418 66 66 @Override 67 67 public boolean acceptsMember(List<RelationMember> relationMembers, RelationMember m) { 68 return "address".equals(m.getRole()) || "house".equals(m.getRole());68 return m.hasRole("address", "house"); 69 69 } 70 70
Note:
See TracChangeset
for help on using the changeset viewer.