Changeset 17622 in josm
- Timestamp:
- 2021-03-21T15:45:27+01:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/validation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/TestError.java
r17350 r17622 540 540 } 541 541 542 /** 543 * Tests if two errors are similar, i.e., 544 * same code and description and same combination of primitives and same combination of highlighted objects, but maybe with different orders. 545 * @param other the other error to be compared 546 * @return true if two errors are similar 547 */ 548 public boolean isSimilar(TestError other) { 549 return getCode() == other.getCode() 550 && getMessage().equals(other.getMessage()) 551 && getPrimitives().size() == other.getPrimitives().size() 552 && getPrimitives().containsAll(other.getPrimitives()) 553 && highlightedIsEqual(getHighlighted(), other.getHighlighted()); 554 } 555 556 private static boolean highlightedIsEqual(Collection<?> highlighted, Collection<?> highlighted2) { 557 if (highlighted.size() == highlighted2.size()) { 558 if (!highlighted.isEmpty()) { 559 Object h1 = highlighted.iterator().next(); 560 Object h2 = highlighted2.iterator().next(); 561 if (h1 instanceof Area && h2 instanceof Area) { 562 return ((Area) h1).equals((Area) h2); 563 } 564 return highlighted.containsAll(highlighted2); 565 } 566 return true; 567 } 568 return false; 569 } 570 542 571 @Override 543 572 public String toString() { -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r17621 r17622 202 202 */ 203 203 private static void addIfNotSimilar(TestError toAdd, List<TestError> errors) { 204 final boolean isDup = toAdd.getPrimitives().size() >= 2 && errors.stream() 205 .anyMatch(e -> e.getCode() == toAdd.getCode() 206 && e.getMessage().equals(toAdd.getMessage()) 207 && e.getPrimitives().size() == toAdd.getPrimitives().size() 208 && e.getPrimitives().containsAll(toAdd.getPrimitives()) 209 && highlightedIsEqual(e.getHighlighted(), toAdd.getHighlighted())); 204 final boolean isDup = toAdd.getPrimitives().size() >= 2 && errors.stream().anyMatch(toAdd::isSimilar); 210 205 if (!isDup) 211 206 errors.add(toAdd); 212 }213 214 private static boolean highlightedIsEqual(Collection<?> highlighted, Collection<?> highlighted2) {215 if (highlighted.size() == highlighted2.size()) {216 if (!highlighted.isEmpty()) {217 Object h1 = highlighted.iterator().next();218 Object h2 = highlighted2.iterator().next();219 if (h1 instanceof Area && h2 instanceof Area) {220 return ((Area) h1).equals((Area) h2);221 }222 return highlighted.containsAll(highlighted2);223 }224 return true;225 }226 return false;227 207 } 228 208
Note:
See TracChangeset
for help on using the changeset viewer.