Ignore:
Timestamp:
2016-07-27T02:08:34+02:00 (3 years ago)
Author:
Don-vip
Message:

see #11390, see #12890 - use Java 8 Predicates

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java

    r10548 r10657  
    2828import org.openstreetmap.josm.tools.Shortcut;
    2929import org.openstreetmap.josm.tools.UserCancelException;
    30 import org.openstreetmap.josm.tools.Utils;
    3130
    3231public final class ReverseWayAction extends JosmAction {
     
    135134    @Override
    136135    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
    137         setEnabled(Utils.exists(selection, OsmPrimitive.wayPredicate));
     136        setEnabled(selection.stream().anyMatch(OsmPrimitive.wayPredicate));
    138137    }
    139138}
  • trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java

    r10601 r10657  
    235235        }
    236236
    237         static PropertiesMembershipDialog showIfNecessary(Iterable<Node> selectedNodes, boolean preselectNew) throws UserCancelException {
     237        static PropertiesMembershipDialog showIfNecessary(Collection<Node> selectedNodes, boolean preselectNew) throws UserCancelException {
    238238            final boolean tagged = isTagged(selectedNodes);
    239239            final boolean usedInRelations = isUsedInRelations(selectedNodes);
     
    249249        }
    250250
    251         private static boolean isTagged(final Iterable<Node> existingNodes) {
    252             return Utils.exists(existingNodes, selectedNode -> selectedNode.hasKeys());
    253         }
    254 
    255         private static boolean isUsedInRelations(final Iterable<Node> existingNodes) {
    256             return Utils.exists(existingNodes, selectedNode -> Utils.exists(selectedNode.getReferrers(), OsmPrimitive.relationPredicate));
     251        private static boolean isTagged(final Collection<Node> existingNodes) {
     252            return existingNodes.stream().anyMatch(selectedNode -> selectedNode.hasKeys());
     253        }
     254
     255        private static boolean isUsedInRelations(final Collection<Node> existingNodes) {
     256            return existingNodes.stream().anyMatch(
     257                    selectedNode -> selectedNode.getReferrers().stream().anyMatch(OsmPrimitive.relationPredicate));
    257258        }
    258259
  • trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java

    r10601 r10657  
    1313import org.openstreetmap.josm.io.OnlineResource;
    1414import org.openstreetmap.josm.tools.ImageProvider;
    15 import org.openstreetmap.josm.tools.Utils;
     15import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    1616
    1717/**
     
    4040    public void setPrimitives(Collection<? extends OsmPrimitive> primitives) {
    4141        // selected non-new relations
    42         this.relations = Utils.filter(getRelations(primitives), r -> !r.isNew());
     42        this.relations = SubclassFilteredCollection.filter(getRelations(primitives), r -> !r.isNew());
    4343        updateEnabledState();
    4444    }
  • trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java

    r10601 r10657  
    1515import org.openstreetmap.josm.io.OnlineResource;
    1616import org.openstreetmap.josm.tools.ImageProvider;
    17 import org.openstreetmap.josm.tools.Utils;
     17import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    1818
    1919/**
     
    4242        Set<OsmPrimitive> ret = new HashSet<>();
    4343        for (Relation r : rels) {
    44             ret.addAll(Utils.filter(r.getIncompleteMembers(), osm -> !osm.isNew()));
     44            ret.addAll(SubclassFilteredCollection.filter(r.getIncompleteMembers(), osm -> !osm.isNew()));
    4545        }
    4646        return ret;
     
    5959    public void setPrimitives(Collection<? extends OsmPrimitive> primitives) {
    6060        // selected relations with incomplete members
    61         this.relations = Utils.filter(getRelations(primitives), r -> r.hasIncompleteMembers());
     61        this.relations = SubclassFilteredCollection.filter(getRelations(primitives), r -> r.hasIncompleteMembers());
    6262        this.incompleteMembers = buildSetOfIncompleteMembers(relations);
    6363        updateEnabledState();
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r10656 r10657  
    1515import java.util.Locale;
    1616import java.util.Map;
     17import java.util.function.Predicate;
    1718import java.util.regex.Matcher;
    1819import java.util.regex.Pattern;
     
    3839import org.openstreetmap.josm.tools.AlphanumComparator;
    3940import org.openstreetmap.josm.tools.Geometry;
    40 import org.openstreetmap.josm.tools.Predicate;
    4141import org.openstreetmap.josm.tools.UncheckedParseException;
    4242import org.openstreetmap.josm.tools.Utils;
     
    298298
    299299        @Override
    300         public final boolean evaluate(OsmPrimitive object) {
     300        public final boolean test(OsmPrimitive object) {
    301301            return match(object);
    302302        }
Note: See TracChangeset for help on using the changeset viewer.