Ticket #23468: 23468.patch
File 23468.patch, 3.9 KB (added by , 19 months ago) |
---|
-
src/org/openstreetmap/josm/data/validation/OsmValidator.java
15 15 import java.util.Arrays; 16 16 import java.util.Collection; 17 17 import java.util.Collections; 18 import java.util.Comparator; 18 19 import java.util.EnumMap; 19 20 import java.util.Enumeration; 20 21 import java.util.HashMap; … … 683 684 684 685 /** 685 686 * Groups the given collection of errors by severity, then message, then description. 687 * Uses <code>AlphanumComparator</code> for grouping the strings. 686 688 * @param errors list of errors to group 687 689 * @param filterToUse optional filter 688 690 * @return collection of errors grouped by severity, then message, then description … … 690 692 */ 691 693 public static Map<Severity, Map<String, Map<String, List<TestError>>>> getErrorsBySeverityMessageDescription( 692 694 Collection<TestError> errors, Predicate<? super TestError> filterToUse) { 693 return errors.stream().filter(filterToUse).collect( 695 return getErrorsBySeverityMessageDescription(errors, filterToUse, AlphanumComparator.getInstance()); 696 } 697 698 /** 699 * Groups the given collection of errors by severity, then message, then description. 700 * Uses the given comparator for grouping the strings. 701 * @param errors list of errors to group 702 * @param filterToUse optional filter 703 * @param comparator the String comparator to use for grouping the messages and descriptions 704 * @return collection of errors grouped by severity, then message, then description 705 * @since xxx 706 */ 707 public static Map<Severity, Map<String, Map<String, List<TestError>>>> getErrorsBySeverityMessageDescription( 708 Collection<TestError> errors, Predicate<? super TestError> filterToUse, final Comparator<String> comparator) { 709 Stopwatch stopwatch = Stopwatch.createStarted(); 710 Map<Severity, Map<String, Map<String, List<TestError>>>> x = errors.stream().filter(filterToUse).collect( 694 711 Collectors.groupingBy(TestError::getSeverity, () -> new EnumMap<>(Severity.class), 695 Collectors.groupingBy(TestError::getMessage, () -> new TreeMap<>( AlphanumComparator.getInstance()),712 Collectors.groupingBy(TestError::getMessage, () -> new TreeMap<>(comparator), 696 713 Collectors.groupingBy(e -> e.getDescription() == null ? "" : e.getDescription(), 697 () -> new TreeMap<>( AlphanumComparator.getInstance()),714 () -> new TreeMap<>(comparator), 698 715 Collectors.toList() 699 716 )))); 717 Logging.debug("getErrorsBySeverityMessageDescription took " + stopwatch.toString()); 718 return x; 700 719 } 701 720 702 721 /** -
src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java
209 209 filterToUse = filterToUse.and(e -> e.getPrimitives().stream().anyMatch(filter::contains)); 210 210 } 211 211 Map<Severity, Map<String, Map<String, List<TestError>>>> errorsBySeverityMessageDescription 212 = OsmValidator.getErrorsBySeverityMessageDescription(errors, filterToUse );212 = OsmValidator.getErrorsBySeverityMessageDescription(errors, filterToUse, String::compareTo); 213 213 214 214 final List<TreePath> expandedPaths = new ArrayList<>(); 215 215 for (Entry<Severity, Map<String, Map<String, List<TestError>>>> entry: errorsBySeverityMessageDescription.entrySet()) {