Changeset 11175 in josm for trunk/src/org
- Timestamp:
- 2016-10-27T00:32:44+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/APIDataSet.java
r10647 r11175 12 12 import java.util.Set; 13 13 import java.util.Stack; 14 import java.util.stream.Collectors; 15 import java.util.stream.Stream; 14 16 15 17 import org.openstreetmap.josm.actions.upload.CyclicUploadDependencyException; … … 57 59 } 58 60 61 /** 62 * Initializes the API data set with the modified primitives, ignores unmodified primitives. 63 * 64 * @param primitives the primitives 65 */ 59 66 public final void init(Collection<OsmPrimitive> primitives) { 60 67 toAdd.clear(); … … 89 96 /** 90 97 * Replies true if one of the primitives to be updated or to be deleted 91 * participates in the conflict <code>conflict</code>92 *93 * @param conflict the conflict94 * @return true if one of the primitives to be updated or to be deleted95 * participates in the conflict <code>conflict</code>96 */97 public boolean participatesInConflict(Conflict<?> conflict) {98 if (conflict == null) return false;99 for (OsmPrimitive p: toUpdate) {100 if (conflict.isParticipating(p)) return true;101 }102 for (OsmPrimitive p: toDelete) {103 if (conflict.isParticipating(p)) return true;104 }105 return false;106 }107 108 /**109 * Replies true if one of the primitives to be updated or to be deleted110 98 * participates in at least one conflict in <code>conflicts</code> 111 99 * … … 116 104 public boolean participatesInConflict(ConflictCollection conflicts) { 117 105 if (conflicts == null || conflicts.isEmpty()) return false; 118 Set<PrimitiveId> idsParticipatingInConflicts = new HashSet<>(); 119 for (OsmPrimitive p: conflicts.getMyConflictParties()) { 120 idsParticipatingInConflicts.add(p.getPrimitiveId()); 121 } 122 for (OsmPrimitive p: conflicts.getTheirConflictParties()) { 123 idsParticipatingInConflicts.add(p.getPrimitiveId()); 124 } 125 for (OsmPrimitive p: toUpdate) { 126 if (idsParticipatingInConflicts.contains(p.getPrimitiveId())) return true; 127 } 128 for (OsmPrimitive p: toDelete) { 129 if (idsParticipatingInConflicts.contains(p.getPrimitiveId())) return true; 130 } 131 return false; 106 Set<PrimitiveId> idsParticipatingInConflicts = conflicts.get().stream() 107 .flatMap(c -> Stream.of(c.getMy(), c.getTheir())) 108 .map(OsmPrimitive::getPrimitiveId) 109 .collect(Collectors.toSet()); 110 return Stream.of(toUpdate, toDelete) 111 .flatMap(Collection::stream) 112 .map(OsmPrimitive::getPrimitiveId) 113 .anyMatch(idsParticipatingInConflicts::contains); 132 114 } 133 115
Note:
See TracChangeset
for help on using the changeset viewer.