Changeset 16387 in josm for trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
- Timestamp:
- 2020-04-30T20:53:59+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r16212 r16387 17 17 import java.util.function.Consumer; 18 18 import java.util.stream.Collectors; 19 import java.util.stream.IntStream; 19 20 import java.util.stream.Stream; 20 21 … … 510 511 if (referrers instanceof OsmPrimitive) 511 512 return referrers instanceof Relation && ((OsmPrimitive) referrers).isSelected(); 512 for (OsmPrimitive ref : (OsmPrimitive[]) referrers) { 513 if (ref instanceof Relation && ref.isSelected()) 514 return true; 515 } 516 return false; 513 return Arrays.stream((OsmPrimitive[]) referrers) 514 .anyMatch(ref -> ref instanceof Relation && ref.isSelected()); 517 515 } 518 516 … … 524 522 return isOuterMemberOfMultipolygon((OsmPrimitive) referrers); 525 523 } 526 for (OsmPrimitive ref : (OsmPrimitive[]) referrers) { 527 if (isOuterMemberOfMultipolygon(ref)) 528 return true; 529 } 530 return false; 524 return Arrays.stream((OsmPrimitive[]) referrers) 525 .anyMatch(this::isOuterMemberOfMultipolygon); 531 526 } 532 527 533 528 private boolean isOuterMemberOfMultipolygon(OsmPrimitive ref) { 534 if (ref instanceof Relation && ref.isSelected() && ((Relation) ref).isMultipolygon()) { 535 for (RelationMember rm : ((Relation) ref).getMembersFor(Collections.singleton(this))) { 536 if ("outer".equals(rm.getRole())) { 537 return true; 538 } 539 } 540 } 541 return false; 529 return ref instanceof Relation 530 && ref.isSelected() 531 && ((Relation) ref).isMultipolygon() 532 && ((Relation) ref).getMembersFor(Collections.singleton(this)).stream() 533 .anyMatch(rm -> "outer".equals(rm.getRole())); 542 534 } 543 535 … … 576 568 577 569 private void updateTagged() { 578 for (String key: keySet()) { 579 // 'area' is not really uninteresting (putting it in that list may have unpredictable side effects) 580 // but it's clearly not enough to consider an object as tagged (see #9261) 581 if (!isUninterestingKey(key) && !"area".equals(key)) { 582 updateFlagsNoLock(FLAG_TAGGED, true); 583 return; 584 } 585 } 586 updateFlagsNoLock(FLAG_TAGGED, false); 570 // 'area' is not really uninteresting (putting it in that list may have unpredictable side effects) 571 // but it's clearly not enough to consider an object as tagged (see #9261) 572 updateFlagsNoLock(FLAG_TAGGED, keySet().stream() 573 .anyMatch(key -> !isUninterestingKey(key) && !"area".equals(key))); 587 574 } 588 575 589 576 private void updateAnnotated() { 590 for (String key: keySet()) { 591 if (getWorkInProgressKeys().contains(key)) { 592 updateFlagsNoLock(FLAG_ANNOTATED, true); 593 return; 594 } 595 } 596 updateFlagsNoLock(FLAG_ANNOTATED, false); 577 updateFlagsNoLock(FLAG_ANNOTATED, keySet().stream() 578 .anyMatch(getWorkInProgressKeys()::contains)); 597 579 } 598 580 … … 746 728 } else if (referrers instanceof OsmPrimitive[]) { 747 729 OsmPrimitive[] orig = (OsmPrimitive[]) referrers; 748 int idx = -1; 749 for (int i = 0; i < orig.length; i++) { 750 if (orig[i] == referrer) { 751 idx = i; 752 break; 753 } 754 } 730 int idx = IntStream.range(0, orig.length) 731 .filter(i -> orig[i] == referrer) 732 .findFirst().orElse(-1); 755 733 if (idx == -1) 756 734 return; … … 904 882 905 883 /** 906 * Merges the technical and semantic alattributes from <code>other</code> onto this.884 * Merges the technical and semantic attributes from <code>other</code> onto this. 907 885 * 908 886 * Both this and other must be new, or both must be assigned an OSM ID. If both this and <code>other</code>
Note:
See TracChangeset
for help on using the changeset viewer.