- Timestamp:
- 2020-04-18T10:41:22+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/validation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/Test.java
r16154 r16332 10 10 import java.util.Optional; 11 11 import java.util.function.Predicate; 12 import java.util.stream.Collectors; 12 13 13 14 import javax.swing.JCheckBox; … … 336 337 */ 337 338 protected final Command deletePrimitivesIfNeeded(Collection<? extends OsmPrimitive> primitives) { 338 Collection<OsmPrimitive> primitivesToDelete = new ArrayList<>(); 339 for (OsmPrimitive p : primitives) { 340 if (!p.isDeleted()) { 341 primitivesToDelete.add(p); 342 } 343 } 339 Collection<OsmPrimitive> primitivesToDelete = primitives.stream() 340 .filter(p -> !p.isDeleted()) 341 .collect(Collectors.toList()); 344 342 if (!primitivesToDelete.isEmpty()) { 345 343 return DeleteCommand.delete(primitivesToDelete); -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java
r14654 r16332 320 320 if (nodes.size() >= 2) { 321 321 // Use first existing node or first node if all nodes are new 322 Node target = null; 323 for (Node n: nodes) { 324 if (!n.isNew()) { 325 target = n; 326 break; 327 } 328 } 329 if (target == null) { 330 target = nodes.iterator().next(); 331 } 322 Node target = nodes.stream() 323 .filter(n -> !n.isNew()) 324 .findFirst() 325 .orElseGet(() -> nodes.iterator().next()); 332 326 333 327 if (Command.checkOutlyingOrIncompleteOperation(nodes, Collections.singleton(target)) == Command.IS_OK) -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r16230 r16332 217 217 if (isKeyIgnored(key)) 218 218 continue; 219 boolean allNumerical = true;220 219 Set<String> values = TaggingPresets.getPresetValues(key); 221 if (values.isEmpty()) 222 allNumerical = false; 223 for (String val : values) { 224 if (!isNum(val)) { 225 allNumerical = false; 226 break; 227 } 228 } 220 boolean allNumerical = values != null && !values.isEmpty() 221 && values.stream().allMatch(TagChecker::isNum); 229 222 if (allNumerical) { 230 223 ignoreForLevenshtein.add(key); … … 394 387 private static void initAdditionalPresetsValueData() { 395 388 additionalPresetsValueData = new HashSet<>(); 396 for (String a : AbstractPrimitive.getUninterestingKeys()) { 397 additionalPresetsValueData.add(a); 398 } 399 for (String a : Config.getPref().getList(ValidatorPrefHelper.PREFIX + ".knownkeys", 400 Arrays.asList("is_in", "int_ref", "fixme", "population"))) { 401 additionalPresetsValueData.add(a); 402 } 389 additionalPresetsValueData.addAll(AbstractPrimitive.getUninterestingKeys()); 390 additionalPresetsValueData.addAll(Config.getPref().getList( 391 ValidatorPrefHelper.PREFIX + ".knownkeys", 392 Arrays.asList("is_in", "int_ref", "fixme", "population"))); 403 393 } 404 394 … … 575 565 */ 576 566 private static boolean isKeyIgnored(String key) { 577 if (ignoreDataEquals.contains(key)) { 578 return true; 579 } 580 for (String a : ignoreDataStartsWith) { 581 if (key.startsWith(a)) { 582 return true; 583 } 584 } 585 for (String a : ignoreDataEndsWith) { 586 if (key.endsWith(a)) { 587 return true; 588 } 589 } 590 return false; 567 return ignoreDataEquals.contains(key) 568 || ignoreDataStartsWith.stream().anyMatch(key::startsWith) 569 || ignoreDataEndsWith.stream().anyMatch(key::endsWith); 591 570 } 592 571 … … 605 584 return true; 606 585 if (!isTagInPresets(key, value)) { 607 for (Tag a : ignoreDataTag) { 608 if (key.equals(a.getKey()) && value.equals(a.getValue())) { 609 return true; 610 } 611 } 586 return ignoreDataTag.stream() 587 .anyMatch(a -> key.equals(a.getKey()) && value.equals(a.getValue())); 612 588 } 613 589 return false; … … 799 775 fixedKey = isKeyInPresets(prettifiedKey) ? prettifiedKey : harmonizedKeys.get(prettifiedKey); 800 776 } 801 if (fixedKey == null) { 802 for (Tag a : ignoreDataTag) { 803 if (a.getKey().equals(prettifiedKey)) { 804 fixedKey = prettifiedKey; 805 break; 806 } 807 } 777 if (fixedKey == null && ignoreDataTag.stream().anyMatch(a -> a.getKey().equals(prettifiedKey))) { 778 fixedKey = prettifiedKey; 808 779 } 809 780 … … 834 805 if (harmonizedValue == null || harmonizedValue.isEmpty()) 835 806 return; 836 String fixedValue = null;807 String fixedValue; 837 808 List<Set<String>> sets = new ArrayList<>(); 838 809 Set<String> presetValues = getPresetValues(key); … … 842 813 if (usedValues != null) 843 814 sets.add(usedValues); 844 for (Set<String> possibleValues: sets) { 845 if (possibleValues.contains(harmonizedValue)) { 846 fixedValue = harmonizedValue; 847 break; 848 } 849 } 815 fixedValue = sets.stream().anyMatch(possibleValues -> possibleValues.contains(harmonizedValue)) 816 ? harmonizedValue : null; 850 817 if (fixedValue == null && !ignoreForLevenshtein.contains(key)) { 851 818 int maxPresetValueLen = 0;
Note:
See TracChangeset
for help on using the changeset viewer.