Changeset 10774 in josm
- Timestamp:
- 2016-08-10T13:47:34+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r10662 r10774 271 271 } 272 272 273 /**274 * Tests whether one of the primitives matches.275 * @param primitives primitives276 * @return {@code true} if one of the primitives matches, {@code false} otherwise277 */278 protected boolean existsMatch(Collection<? extends OsmPrimitive> primitives) {279 for (OsmPrimitive p : primitives) {280 if (match(p))281 return true;282 }283 return false;284 }285 286 /**287 * Tests whether all primitives match.288 * @param primitives primitives289 * @return {@code true} if all primitives match, {@code false} otherwise290 */291 protected boolean forallMatch(Collection<? extends OsmPrimitive> primitives) {292 for (OsmPrimitive p : primitives) {293 if (!match(p))294 return false;295 }296 return true;297 }298 299 273 @Override 300 274 public final boolean test(OsmPrimitive object) { … … 1473 1447 return false; 1474 1448 else if (osm instanceof Node) { 1449 LatLon coordinate = ((Node) osm).getCoor(); 1475 1450 Collection<Bounds> allBounds = getBounds(osm); 1476 if (allBounds != null) { 1477 LatLon coor = ((Node) osm).getCoor(); 1478 for (Bounds bounds: allBounds) { 1479 if (bounds.contains(coor)) { 1480 return true; 1481 } 1482 } 1483 } 1484 return false; 1451 return allBounds != null && allBounds.stream().anyMatch(bounds -> bounds.contains(coordinate)); 1485 1452 } else if (osm instanceof Way) { 1486 1453 Collection<Node> nodes = ((Way) osm).getNodes(); 1487 return all ? forallMatch(nodes) : existsMatch(nodes);1454 return all ? nodes.stream().allMatch(this) : nodes.stream().anyMatch(this); 1488 1455 } else if (osm instanceof Relation) { 1489 Collection<OsmPrimitive> primitives = ((Relation) osm).getMemberPrimitives ();1490 return all ? forallMatch(primitives) : existsMatch(primitives);1456 Collection<OsmPrimitive> primitives = ((Relation) osm).getMemberPrimitivesList(); 1457 return all ? primitives.stream().allMatch(this) : primitives.stream().anyMatch(this); 1491 1458 } else 1492 1459 return false;
Note:
See TracChangeset
for help on using the changeset viewer.