Changeset 15998 in josm


Ignore:
Timestamp:
2020-03-02T22:19:23+01:00 (4 years ago)
Author:
simon04
Message:

see #18802 - MapCSSTagChecker: use Stream API

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r15997 r15998  
    379379
    380380        Selector whichSelectorMatchesEnvironment(Environment env) {
    381             for (Selector i : rule.selectors) {
    382                 env.clearSelectorMatchingInformation();
    383                 if (i.matches(env)) {
    384                     return i;
    385                 }
    386             }
    387             return null;
     381            return rule.selectors.stream()
     382                    .filter(i -> i.matches(env.clearSelectorMatchingInformation()))
     383                    .findFirst()
     384                    .orElse(null);
    388385        }
    389386
     
    693690     */
    694691    private static void addIfNotSimilar(TestError toAdd, List<TestError> errors) {
    695         boolean isDup = false;
    696         if (toAdd.getPrimitives().size() >= 2) {
    697             for (TestError e : errors) {
    698                 if (e.getCode() == toAdd.getCode() && e.getMessage().equals(toAdd.getMessage())
     692        final boolean isDup = toAdd.getPrimitives().size() >= 2 && errors.stream()
     693                .anyMatch(e -> e.getCode() == toAdd.getCode()
     694                        && e.getMessage().equals(toAdd.getMessage())
    699695                        && e.getPrimitives().size() == toAdd.getPrimitives().size()
    700696                        && e.getPrimitives().containsAll(toAdd.getPrimitives())
    701                         && highlightedIsEqual(e.getHighlighted(), toAdd.getHighlighted())) {
    702                     isDup = true;
    703                     break;
    704                 }
    705             }
    706         }
     697                        && highlightedIsEqual(e.getHighlighted(), toAdd.getHighlighted()));
    707698        if (!isDup)
    708699            errors.add(toAdd);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/Environment.java

    r15959 r15998  
    300300    /**
    301301     * Clears all matching context information
    302      */
    303     public void clearSelectorMatchingInformation() {
     302     * @return this
     303     */
     304    public Environment clearSelectorMatchingInformation() {
    304305        parent = null;
    305306        child = null;
     
    309310        intersections = null;
    310311        crossingWaysMap = null;
     312        return this;
    311313    }
    312314
Note: See TracChangeset for help on using the changeset viewer.