Changeset 11298 in josm for trunk


Ignore:
Timestamp:
2016-11-23T23:39:40+01:00 (8 years ago)
Author:
simon04
Message:

Replace TestError#getSelectablePrimitives by Java 8 stream usage

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

Legend:

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

    r11235 r11298  
    33
    44import java.text.MessageFormat;
    5 import java.util.ArrayList;
    65import java.util.Arrays;
    76import java.util.Collection;
     
    381380
    382381    /**
    383      * Gets the list of primitives affected by this error and are selectable
    384      * @return the list of selectable primitives affected by this error
    385      */
    386     public Collection<? extends OsmPrimitive> getSelectablePrimitives() {
    387         List<OsmPrimitive> selectablePrimitives = new ArrayList<>(primitives.size());
    388         for (OsmPrimitive o : primitives) {
    389             if (o.isSelectable()) {
    390                 selectablePrimitives.add(o);
    391             }
    392         }
    393         return selectablePrimitives;
    394     }
    395 
    396     /**
    397382     * Sets the list of primitives affected by this error
    398383     * @param primitives the list of primitives affected by this error*
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java

    r10880 r11298  
    337337                if (nodeInfo instanceof TestError) {
    338338                    TestError error = (TestError) nodeInfo;
    339                     sel.addAll(error.getSelectablePrimitives());
     339                    error.getPrimitives().stream()
     340                            .filter(OsmPrimitive::isSelectable)
     341                            .forEach(sel::add);
    340342                }
    341343            }
     
    388390                hasFixes = hasFixes || error.isFixable();
    389391                if (addSelected) {
    390                     sel.addAll(error.getSelectablePrimitives());
     392                    error.getPrimitives().stream()
     393                            .filter(OsmPrimitive::isSelectable)
     394                            .forEach(sel::add);
    391395                }
    392396            }
Note: See TracChangeset for help on using the changeset viewer.