Ignore:
Timestamp:
2015-10-19T20:48:07+02:00 (9 years ago)
Author:
simon04
Message:

JOSM/utilsplugin2: Refactoring (use Utils.filter)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/TagBufferAction.java

    r31026 r31653  
    55import java.util.*;
    66import java.awt.event.KeyEvent;
     7import org.openstreetmap.josm.tools.Predicate;
    78import org.openstreetmap.josm.tools.Shortcut;
    89import java.awt.event.ActionEvent;
    910import org.openstreetmap.josm.actions.JosmAction;
    1011import org.openstreetmap.josm.data.osm.OsmPrimitive;
     12import org.openstreetmap.josm.tools.Utils;
    1113import static org.openstreetmap.josm.tools.I18n.tr;
    1214
     
    1820public class TagBufferAction extends JosmAction {
    1921    private static final String TITLE = tr("Copy tags from previous selection");
     22    private static final Predicate<OsmPrimitive> IS_TAGGED_PREDICATE = new Predicate<OsmPrimitive>() {
     23        @Override
     24        public boolean evaluate(OsmPrimitive object) {
     25            return object.isTagged();
     26        }
     27    };
    2028    private Map<String, String> tags = new HashMap<>();
    2129    private Map<String, String> currentTags = new HashMap<>();
     
    94102    private void rememberSelectionTags() {
    95103        // Fix #8350 - only care about tagged objects
    96         Collection<OsmPrimitive> selectedTaggedObjects = new ArrayList<>(getCurrentDataSet().getSelected());
    97         for (Iterator<OsmPrimitive> it = selectedTaggedObjects.iterator(); it.hasNext(); ) {
    98             if (!it.next().isTagged()) {
    99                 it.remove();
    100             }
    101         }
     104        final Collection<OsmPrimitive> selectedTaggedObjects = Utils.filter(getCurrentDataSet().getSelected(), IS_TAGGED_PREDICATE);
    102105        if( !selectedTaggedObjects.isEmpty() ) {
    103106            currentTags.clear();
Note: See TracChangeset for help on using the changeset viewer.