Changeset 10657 in josm for trunk/src/org/openstreetmap


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

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

Location:
trunk/src/org/openstreetmap/josm
Files:
40 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        }
  • trunk/src/org/openstreetmap/josm/corrector/ReverseWayNoTagCorrector.java

    r9539 r10657  
    5555        for (Map.Entry<String, String> entry : way.getKeys().entrySet()) {
    5656            final Tag tag = new Tag(entry.getKey(), entry.getValue());
    57             final boolean isDirectional = directionalTags.contains(tag) || OsmPrimitive.directionalKeyPredicate.evaluate(tag);
     57            final boolean isDirectional = directionalTags.contains(tag) || OsmPrimitive.directionalKeyPredicate.test(tag);
    5858            if (isDirectional) {
    5959                final boolean cannotBeCorrected = ReverseWayTagCorrector.getTagCorrections(tag).isEmpty();
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r10626 r10657  
    3838import java.util.TreeMap;
    3939import java.util.concurrent.CopyOnWriteArrayList;
     40import java.util.function.Predicate;
    4041import java.util.regex.Matcher;
    4142import java.util.regex.Pattern;
     
    6970import org.openstreetmap.josm.tools.I18n;
    7071import org.openstreetmap.josm.tools.MultiMap;
    71 import org.openstreetmap.josm.tools.Predicate;
    7272import org.openstreetmap.josm.tools.Utils;
    7373import org.xml.sax.SAXException;
  • trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java

    r10378 r10657  
    1212import java.util.Set;
    1313import java.util.concurrent.CopyOnWriteArrayList;
     14import java.util.function.Predicate;
    1415
    1516import org.openstreetmap.josm.data.osm.Node;
     
    1819import org.openstreetmap.josm.data.osm.Way;
    1920import org.openstreetmap.josm.tools.CheckParameterUtil;
    20 import org.openstreetmap.josm.tools.Predicate;
    21 import org.openstreetmap.josm.tools.Utils;
     21import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    2222
    2323/**
     
    5252
    5353        @Override
    54         public boolean evaluate(Conflict<? extends OsmPrimitive> conflict) {
     54        public boolean test(Conflict<? extends OsmPrimitive> conflict) {
    5555            return conflict != null && c.isInstance(conflict.getMy());
    5656        }
     
    364364     */
    365365    public final Collection<Conflict<? extends OsmPrimitive>> getNodeConflicts() {
    366         return Utils.filter(conflicts, NODE_FILTER_PREDICATE);
     366        return SubclassFilteredCollection.filter(conflicts, NODE_FILTER_PREDICATE);
    367367    }
    368368
     
    373373     */
    374374    public final Collection<Conflict<? extends OsmPrimitive>> getWayConflicts() {
    375         return Utils.filter(conflicts, WAY_FILTER_PREDICATE);
     375        return SubclassFilteredCollection.filter(conflicts, WAY_FILTER_PREDICATE);
    376376    }
    377377
     
    382382     */
    383383    public final Collection<Conflict<? extends OsmPrimitive>> getRelationConflicts() {
    384         return Utils.filter(conflicts, RELATION_FILTER_PREDICATE);
     384        return SubclassFilteredCollection.filter(conflicts, RELATION_FILTER_PREDICATE);
    385385    }
    386386
     
    396396        ConflictCollection conflicts1 = (ConflictCollection) obj;
    397397        return Objects.equals(conflicts, conflicts1.conflicts) &&
    398                 Objects.equals(listeners, conflicts1.listeners);
     398               Objects.equals(listeners, conflicts1.listeners);
    399399    }
    400400}
  • trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java

    r10608 r10657  
    1616import org.openstreetmap.josm.gui.JosmUserIdentityManager;
    1717import org.openstreetmap.josm.gui.util.GuiHelper;
    18 import org.openstreetmap.josm.tools.Utils;
     18import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    1919
    2020/**
     
    203203            return getOpenChangesets();
    204204        } else {
    205             return new ArrayList<>(Utils.filter(getOpenChangesets(),
     205            return new ArrayList<>(SubclassFilteredCollection.filter(getOpenChangesets(),
    206206                    object -> JosmUserIdentityManager.getInstance().isCurrentUser(object.getUser())));
    207207        }
  • trunk/src/org/openstreetmap/josm/data/osm/FilterWorker.java

    r10308 r10657  
    66
    77import org.openstreetmap.josm.data.osm.FilterMatcher.FilterType;
    8 import org.openstreetmap.josm.tools.Utils;
     8import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    99
    1010/**
     
    3232        boolean changed;
    3333        // first relations, then ways and nodes last; this is required to resolve dependencies
    34         changed = doExecuteFilters(Utils.filter(all, OsmPrimitive.relationPredicate), filterMatcher);
    35         changed |= doExecuteFilters(Utils.filter(all, OsmPrimitive.wayPredicate), filterMatcher);
    36         changed |= doExecuteFilters(Utils.filter(all, OsmPrimitive.nodePredicate), filterMatcher);
     34        changed = doExecuteFilters(SubclassFilteredCollection.filter(all, OsmPrimitive.relationPredicate), filterMatcher);
     35        changed |= doExecuteFilters(SubclassFilteredCollection.filter(all, OsmPrimitive.wayPredicate), filterMatcher);
     36        changed |= doExecuteFilters(SubclassFilteredCollection.filter(all, OsmPrimitive.nodePredicate), filterMatcher);
    3737        return changed;
    3838    }
  • trunk/src/org/openstreetmap/josm/data/osm/NoteData.java

    r10619 r10657  
    1616import org.openstreetmap.josm.data.notes.NoteComment;
    1717import org.openstreetmap.josm.gui.JosmUserIdentityManager;
    18 import org.openstreetmap.josm.tools.Utils;
    1918
    2019/**
     
    154153            } else {
    155154                final Note existingNote = noteList.get(newNote);
    156                 final boolean isDirty = Utils.exists(existingNote.getComments(), object -> object.isNew());
     155                final boolean isDirty = existingNote.getComments().stream().anyMatch(object -> object.isNew());
    157156                if (!isDirty) {
    158157                    noteList.put(newNote);
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r10656 r10657  
    1919import java.util.Objects;
    2020import java.util.Set;
     21import java.util.function.Predicate;
    2122
    2223import org.openstreetmap.josm.Main;
     
    2728import org.openstreetmap.josm.gui.mappaint.StyleCache;
    2829import org.openstreetmap.josm.tools.CheckParameterUtil;
    29 import org.openstreetmap.josm.tools.Predicate;
    3030import org.openstreetmap.josm.tools.Predicates;
    3131import org.openstreetmap.josm.tools.Utils;
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r10656 r10657  
    1616import org.openstreetmap.josm.data.osm.visitor.Visitor;
    1717import org.openstreetmap.josm.tools.CopyList;
     18import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    1819import org.openstreetmap.josm.tools.Utils;
    1920import org.openstreetmap.josm.tools.Utils.Function;
     
    350351     */
    351352    public Collection<RelationMember> getMembersFor(final Collection<? extends OsmPrimitive> primitives) {
    352         return Utils.filter(getMembers(), member -> primitives.contains(member.getMember()));
     353        return SubclassFilteredCollection.filter(getMembers(), member -> primitives.contains(member.getMember()));
    353354    }
    354355
  • trunk/src/org/openstreetmap/josm/data/validation/Test.java

    r10413 r10657  
    99import java.util.List;
    1010import java.util.Objects;
     11import java.util.function.Predicate;
    1112
    1213import javax.swing.JCheckBox;
     
    2526import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    2627import org.openstreetmap.josm.tools.GBC;
    27 import org.openstreetmap.josm.tools.Predicate;
    2828import org.openstreetmap.josm.tools.Utils;
    2929
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java

    r10608 r10657  
    2929import org.openstreetmap.josm.tools.Geometry;
    3030import org.openstreetmap.josm.tools.Pair;
    31 import org.openstreetmap.josm.tools.Utils;
     31import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    3232
    3333/**
     
    9191            // warning level only if several relations have different names, see #10945
    9292            final String name = list.get(0).get("name");
    93             if (name == null || Utils.filter(list, r -> name.equals(r.get("name"))).size() < list.size()) {
     93            if (name == null || SubclassFilteredCollection.filter(list, r -> name.equals(r.get("name"))).size() < list.size()) {
    9494                level = Severity.WARNING;
    9595            } else {
     
    243243        // No street segment found near this house, report error on if the relation does not contain incomplete street ways (fix #8314)
    244244        if (hasIncompleteWays) return;
    245         List<OsmPrimitive> errorList = new ArrayList<OsmPrimitive>(street);
     245        List<OsmPrimitive> errorList = new ArrayList<>(street);
    246246        errorList.add(0, house);
    247247        errors.add(new AddressError(this, HOUSE_NUMBER_TOO_FAR, errorList,
  • trunk/src/org/openstreetmap/josm/data/validation/tests/ConditionalKeys.java

    r10632 r10657  
    2020import org.openstreetmap.josm.tools.LanguageInfo;
    2121import org.openstreetmap.josm.tools.Predicates;
    22 import org.openstreetmap.josm.tools.Utils;
     22import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    2323
    2424/**
     
    156156    public List<TestError> validatePrimitive(OsmPrimitive p) {
    157157        final List<TestError> errors = new ArrayList<>();
    158         for (final String key : Utils.filter(p.keySet(), Predicates.stringMatchesPattern(Pattern.compile(".*:conditional(:.*)?$")))) {
     158        for (final String key : SubclassFilteredCollection.filter(p.keySet(),
     159                Predicates.stringMatchesPattern(Pattern.compile(".*:conditional(:.*)?$")))) {
    159160            if (!isKeyValid(key)) {
    160161                errors.add(new TestError(this, Severity.WARNING, tr("Wrong syntax in {0} key", key), 3201, p));
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java

    r10608 r10657  
    158158        final String highway = way.get("highway");
    159159        if (highway == null || !highway.endsWith("_link")
    160                 || !IN_DOWNLOADED_AREA.evaluate(way.getNode(0)) || !IN_DOWNLOADED_AREA.evaluate(way.getNode(way.getNodesCount()-1))) {
     160                || !IN_DOWNLOADED_AREA.test(way.getNode(0)) || !IN_DOWNLOADED_AREA.test(way.getNode(way.getNodesCount()-1))) {
    161161            return true;
    162162        }
     
    174174        }
    175175
    176         return Utils.exists(Utils.filteredCollection(referrers, Way.class),
     176        return Utils.filteredCollection(referrers, Way.class).stream().anyMatch(
    177177                otherWay -> !way.equals(otherWay) && otherWay.hasTag("highway", highway, highway.replaceAll("_link$", "")));
    178178    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r10608 r10657  
    2626import java.util.Objects;
    2727import java.util.Set;
     28import java.util.function.Predicate;
    2829import java.util.regex.Matcher;
    2930import java.util.regex.Pattern;
     
    6667import org.openstreetmap.josm.tools.CheckParameterUtil;
    6768import org.openstreetmap.josm.tools.MultiMap;
    68 import org.openstreetmap.josm.tools.Predicate;
    6969import org.openstreetmap.josm.tools.Utils;
    7070
     
    390390
    391391        @Override
    392         public boolean evaluate(OsmPrimitive primitive) {
     392        public boolean test(OsmPrimitive primitive) {
    393393            // Tests whether the primitive contains a deprecated tag which is represented by this MapCSSTagChecker.
    394394            return whichSelectorMatchesPrimitive(primitive) != null;
     
    788788                    Main.debug("- Errors: "+pErrors);
    789789                }
    790                 final boolean isError = Utils.exists(pErrors, e -> e.getTester().equals(check.rule));
     790                final boolean isError = pErrors.stream().anyMatch(e -> e.getTester().equals(check.rule));
    791791                if (isError != i.getValue()) {
    792792                    final String error = MessageFormat.format("Expecting test ''{0}'' (i.e., {1}) to {2} {3} (i.e., {4})",
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java

    r10608 r10657  
    2929import org.openstreetmap.josm.tools.Pair;
    3030import org.openstreetmap.josm.tools.Predicates;
    31 import org.openstreetmap.josm.tools.Utils;
    3231
    3332/**
     
    157156                boolean ignore = false;
    158157                for (String ignoredKey : IGNORED_KEYS.get()) {
    159                     if (Utils.exists(error.getPrimitives(), Predicates.hasKey(ignoredKey))) {
     158                    if (error.getPrimitives().stream().anyMatch(Predicates.hasKey(ignoredKey))) {
    160159                        ignore = true;
    161160                        break;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java

    r10363 r10657  
    7070                for (Node n : w.getNodes()) {
    7171                    if (!isPowerTower(n)) {
    72                         if (!isPowerAllowed(n) && IN_DOWNLOADED_AREA.evaluate(n)) {
     72                        if (!isPowerAllowed(n) && IN_DOWNLOADED_AREA.test(n)) {
    7373                            if (!w.isFirstLastNode(n) || !isPowerStation(n)) {
    7474                                potentialErrors.add(new PowerLineError(this, n, w));
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedNode.java

    r10046 r10657  
    4343        if (n.isUsable() && !n.isTagged() && n.getReferrers().isEmpty()) {
    4444
    45             if (!n.hasKeys() && IN_DOWNLOADED_AREA.evaluate(n)) {
     45            if (!n.hasKeys() && IN_DOWNLOADED_AREA.test(n)) {
    4646                String msg = marktr("No tags");
    4747                errors.add(new TestError(this, Severity.WARNING, ERROR_MESSAGE, tr(msg), msg, UNTAGGED_NODE_BLANK, n));
  • trunk/src/org/openstreetmap/josm/data/validation/tests/WayConnectedToArea.java

    r8870 r10657  
    1616import org.openstreetmap.josm.gui.mappaint.ElemStyles;
    1717import org.openstreetmap.josm.tools.Predicates;
    18 import org.openstreetmap.josm.tools.Utils;
    1918
    2019/**
     
    6867        if (wayNode.isOutsideDownloadArea()) {
    6968            return;
    70         } else if (Utils.exists(wayNode.getReferrers(), Predicates.hasTag("route", "ferry"))) {
     69        } else if (wayNode.getReferrers().stream().anyMatch(Predicates.hasTag("route", "ferry"))) {
    7170            return;
    7271        } else if (isArea(p)) {
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r10625 r10657  
    294294                    if (middleMouseDown || isAtOldPosition) {
    295295                        Collection<OsmPrimitive> osms = mv.getAllNearest(ms.mousePos,
    296                                 o -> isUsablePredicate.evaluate(o) && isSelectablePredicate.evaluate(o));
     296                                o -> isUsablePredicate.test(o) && isSelectablePredicate.test(o));
    297297
    298298                        final JPanel c = new JPanel(new GridBagLayout());
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r10634 r10657  
    2626import java.util.TreeMap;
    2727import java.util.concurrent.CopyOnWriteArrayList;
     28import java.util.function.Predicate;
    2829import java.util.zip.CRC32;
    2930
     
    5960import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    6061import org.openstreetmap.josm.gui.util.CursorManager;
    61 import org.openstreetmap.josm.tools.Predicate;
    6262import org.openstreetmap.josm.tools.Utils;
    6363
     
    818818
    819819            for (Node n : ds.searchNodes(getBBox(p, PROP_SNAP_DISTANCE.get()))) {
    820                 if (predicate.evaluate(n)
     820                if (predicate.test(n)
    821821                        && (dist = getPoint2D(n).distanceSq(p)) < snapDistanceSq) {
    822822                    List<Node> nlist;
     
    10271027
    10281028            for (Way w : ds.searchWays(getBBox(p, Main.pref.getInteger("mappaint.segment.snap-distance", 10)))) {
    1029                 if (!predicate.evaluate(w)) {
     1029                if (!predicate.test(w)) {
    10301030                    continue;
    10311031                }
     
    14711471        for (OsmPrimitive o : nearestList) {
    14721472            for (OsmPrimitive r : o.getReferrers()) {
    1473                 if (r instanceof Relation && predicate.evaluate(r)) {
     1473                if (r instanceof Relation && predicate.test(r)) {
    14741474                    parentRelations.add(r);
    14751475                }
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java

    r10611 r10657  
    2525import org.openstreetmap.josm.data.osm.RelationToChildReference;
    2626import org.openstreetmap.josm.gui.util.GuiHelper;
    27 import org.openstreetmap.josm.tools.Utils;
    2827
    2928/**
     
    200199    public void prepareDefaultRelationDecisions() {
    201200
    202         if (Utils.forAll(primitives, OsmPrimitive.nodePredicate)) {
     201        if (primitives.stream().allMatch(OsmPrimitive.nodePredicate)) {
    203202            final Collection<OsmPrimitive> primitivesInDecisions = new HashSet<>();
    204203            for (final RelationMemberConflictDecision i : decisions) {
     
    234233                    iterators.add(i.iterator());
    235234                }
    236                 while (Utils.forAll(iterators, it -> it.hasNext())) {
     235                while (iterators.stream().allMatch(it -> it.hasNext())) {
    237236                    final List<RelationMemberConflictDecision> decisions = new ArrayList<>();
    238237                    final Collection<String> roles = new HashSet<>();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r10619 r10657  
    8080import org.openstreetmap.josm.tools.InputMapUtils;
    8181import org.openstreetmap.josm.tools.Shortcut;
    82 import org.openstreetmap.josm.tools.Utils;
     82import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    8383
    8484/**
     
    488488        private void updateFilteredRelations() {
    489489            if (filter != null) {
    490                 filteredRelations = new ArrayList<>(Utils.filter(relations, filter::match));
     490                filteredRelations = new ArrayList<>(SubclassFilteredCollection.filter(relations, filter::match));
    491491            } else if (filteredRelations != null) {
    492492                filteredRelations = null;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r10619 r10657  
    878878        private Set<OsmPrimitive> members = new HashSet<>();
    879879        private List<Integer> position = new ArrayList<>();
    880         private Iterable<OsmPrimitive> selection;
     880        private Collection<OsmPrimitive> selection;
    881881        private String positionString;
    882882        private String roleString;
    883883
    884         MemberInfo(Iterable<OsmPrimitive> selection) {
     884        MemberInfo(Collection<OsmPrimitive> selection) {
    885885            this.selection = selection;
    886886        }
     
    896896                positionString = Utils.getPositionListString(position);
    897897                // if not all objects from the selection are member of this relation
    898                 if (Utils.exists(selection, Predicates.not(Predicates.inCollection(members)))) {
     898                if (selection.stream().anyMatch(Predicates.not(Predicates.inCollection(members)))) {
    899899                    positionString += ",\u2717";
    900900                }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java

    r10611 r10657  
    1717import java.util.Map.Entry;
    1818import java.util.Set;
     19import java.util.function.Predicate;
    1920
    2021import javax.swing.JTree;
     
    3637import org.openstreetmap.josm.tools.Destroyable;
    3738import org.openstreetmap.josm.tools.MultiMap;
    38 import org.openstreetmap.josm.tools.Predicate;
    3939import org.openstreetmap.josm.tools.Predicates;
    40 import org.openstreetmap.josm.tools.Utils;
    4140
    4241/**
     
    364363                final TestError error = (TestError) ((DefaultMutableTreeNode) child).getUserObject();
    365364                if (error.getPrimitives() != null) {
    366                     if (Utils.exists(error.getPrimitives(), isRelevant)) {
     365                    if (error.getPrimitives().stream().anyMatch(isRelevant)) {
    367366                        paths.add(p.pathByAddingChild(child));
    368367                    }
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java

    r10611 r10657  
    1414import java.util.Map.Entry;
    1515import java.util.Objects;
     16import java.util.function.Predicate;
    1617
    1718import javax.swing.JOptionPane;
     
    2627import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
    2728import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
    28 import org.openstreetmap.josm.tools.Predicate;
    29 import org.openstreetmap.josm.tools.Utils;
     29import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    3030import org.openstreetmap.josm.tools.WindowGeometry;
    3131import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler;
     
    177177     */
    178178    public void showHistory(final Collection<? extends PrimitiveId> primitives) {
    179         final Collection<? extends PrimitiveId> notNewPrimitives = Utils.filter(primitives, notNewPredicate);
     179        final Collection<? extends PrimitiveId> notNewPrimitives = SubclassFilteredCollection.filter(primitives, notNewPredicate);
    180180        if (notNewPrimitives.isEmpty()) {
    181181            JOptionPane.showMessageDialog(
     
    187187        }
    188188
    189         Collection<? extends PrimitiveId> toLoad = Utils.filter(primitives, unloadedHistoryPredicate);
     189        Collection<? extends PrimitiveId> toLoad = SubclassFilteredCollection.filter(primitives, unloadedHistoryPredicate);
    190190        if (!toLoad.isEmpty()) {
    191191            HistoryLoadTask task = new HistoryLoadTask();
     
    217217
    218218        @Override
    219         public boolean evaluate(PrimitiveId p) {
     219        public boolean test(PrimitiveId p) {
    220220            History h = hds.getHistory(p);
    221221            if (h == null)
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java

    r10607 r10657  
    1111import java.util.Objects;
    1212import java.util.Set;
     13import java.util.function.Predicate;
    1314import java.util.regex.Pattern;
    1415
     
    2627import org.openstreetmap.josm.gui.mappaint.Environment;
    2728import org.openstreetmap.josm.tools.CheckParameterUtil;
    28 import org.openstreetmap.josm.tools.Predicate;
    2929import org.openstreetmap.josm.tools.Predicates;
     30import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    3031import org.openstreetmap.josm.tools.Utils;
    3132
     
    463464                    return e.osm.isKeyFalse(label) ^ negateResult;
    464465                case REGEX:
    465                     return Utils.exists(e.osm.keySet(), containsPattern) ^ negateResult;
     466                    return e.osm.keySet().stream().anyMatch(containsPattern) ^ negateResult;
    466467                default:
    467468                    return e.osm.hasKey(label) ^ negateResult;
     
    486487            String key = label;
    487488            if (KeyMatchType.REGEX.equals(matchType)) {
    488                 final Collection<String> matchingKeys = Utils.filter(p.keySet(), containsPattern);
     489                final Collection<String> matchingKeys = SubclassFilteredCollection.filter(p.keySet(), containsPattern);
    489490                if (!matchingKeys.isEmpty()) {
    490491                    key = matchingKeys.iterator().next();
     
    666667         */
    667668        static boolean inDownloadedArea(Environment e) { // NO_UCD (unused code)
    668             return IN_DOWNLOADED_AREA.evaluate(e.osm);
     669            return IN_DOWNLOADED_AREA.test(e.osm);
    669670        }
    670671
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r10627 r10657  
    3838import org.openstreetmap.josm.tools.Predicates;
    3939import org.openstreetmap.josm.tools.RightAndLefthandTraffic;
     40import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    4041import org.openstreetmap.josm.tools.Utils;
    4142import org.openstreetmap.josm.tools.Utils.Function;
     
    11341135        public Float aggregateList(List<?> lst) {
    11351136            final List<Float> floats = Utils.transform(lst, (Function<Object, Float>) x -> Cascade.convertTo(x, float.class));
    1136             final Collection<Float> nonNullList = Utils.filter(floats, Predicates.not(Predicates.isNull()));
     1137            final Collection<Float> nonNullList = SubclassFilteredCollection.filter(floats, Predicates.not(Predicates.isNull()));
    11371138            return nonNullList.isEmpty() ? (Float) Float.NaN : computeMax ? Collections.max(nonNullList) : Collections.min(nonNullList);
    11381139        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    r10627 r10657  
    2525import org.openstreetmap.josm.tools.Pair;
    2626import org.openstreetmap.josm.tools.Predicates;
     27import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    2728import org.openstreetmap.josm.tools.Utils;
    2829
     
    320321                        throw new NoSuchElementException();
    321322                    }
    322                     final Collection<Relation> multipolygons = Utils.filteredCollection(Utils.filter(
     323                    final Collection<Relation> multipolygons = Utils.filteredCollection(SubclassFilteredCollection.filter(
    323324                            e.osm.getReferrers(), Predicates.hasTag("type", "multipolygon")), Relation.class);
    324325                    final Relation multipolygon = multipolygons.iterator().next();
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ListEditor.java

    r10611 r10657  
    1919import org.openstreetmap.josm.gui.widgets.JosmTextField;
    2020import org.openstreetmap.josm.tools.GBC;
    21 import org.openstreetmap.josm.tools.Utils;
     21import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    2222
    2323/**
     
    4343    @Override
    4444    public List<String> getData() {
    45         return new ArrayList<>(Utils.filter(model.getData(), object -> object != null && !object.isEmpty()));
     45        return new ArrayList<>(SubclassFilteredCollection.filter(model.getData(), object -> object != null && !object.isEmpty()));
    4646    }
    4747
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r10634 r10657  
    2121import java.util.Map;
    2222import java.util.Set;
     23import java.util.function.Predicate;
    2324
    2425import javax.swing.AbstractAction;
     
    6061import org.openstreetmap.josm.tools.ImageProvider;
    6162import org.openstreetmap.josm.tools.ImageProvider.ImageResourceCallback;
    62 import org.openstreetmap.josm.tools.Predicate;
    6363import org.openstreetmap.josm.tools.Utils;
    6464import org.openstreetmap.josm.tools.template_engine.ParseError;
     
    297297        }
    298298
    299         boolean presetInitiallyMatches = !selected.isEmpty() && Utils.forAll(selected, this);
     299        boolean presetInitiallyMatches = !selected.isEmpty() && selected.stream().allMatch(this);
    300300        JPanel items = new JPanel(new GridBagLayout());
    301301        for (TaggingPresetItem i : data) {
     
    556556     */
    557557    @Override
    558     public boolean evaluate(OsmPrimitive p) {
     558    public boolean test(OsmPrimitive p) {
    559559        return matches(EnumSet.of(TaggingPresetType.forPrimitive(p)), p.getKeys(), false);
    560560    }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java

    r10590 r10657  
    282282                            && preset.roles != null && !preset.roles.roles.isEmpty()) {
    283283                        suitable = preset.roles.roles.stream().anyMatch(
    284                                 object -> object.memberExpression != null && Utils.exists(selectedPrimitives, object.memberExpression));
     284                                object -> object.memberExpression != null && selectedPrimitives.stream().anyMatch(object.memberExpression));
    285285                        // keep the preset to allow the creation of new relations
    286286                    }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java

    r10590 r10657  
    115115     * @param primitive the primitive
    116116     * @return a new collection of all presets matching the given preset.
    117      * @see TaggingPreset#evaluate(OsmPrimitive)
     117     * @see TaggingPreset#test(OsmPrimitive)
    118118     * @since 9265
    119119     */
    120120    public static Collection<TaggingPreset> getMatchingPresets(final OsmPrimitive primitive) {
    121         return SubclassFilteredCollection.filter(getTaggingPresets(), preset -> preset.evaluate(primitive));
     121        return SubclassFilteredCollection.filter(getTaggingPresets(), preset -> preset.test(primitive));
    122122    }
    123123
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r10615 r10657  
    2929import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog;
    3030import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault;
     31import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    3132import org.openstreetmap.josm.tools.Utils;
    3233
     
    193194                Main.worker.submit(() -> {
    194195                    final DataSet ds = Main.getLayerManager().getEditDataSet();
    195                     final Collection<OsmPrimitive> filteredPrimitives = Utils.filter(ds.allPrimitives(), search);
     196                    final Collection<OsmPrimitive> filteredPrimitives = SubclassFilteredCollection.filter(ds.allPrimitives(), search);
    196197                    ds.setSelected(filteredPrimitives);
    197198                    forTagAdd.addAll(filteredPrimitives);
  • trunk/src/org/openstreetmap/josm/tools/FilteredCollection.java

    r7395 r10657  
    1717     * @param predicate The predicate to use as filter
    1818     */
    19     public FilteredCollection(Collection<? extends T> collection, Predicate<? super T> predicate) {
     19    public FilteredCollection(Collection<? extends T> collection, java.util.function.Predicate<? super T> predicate) {
    2020        super(collection, predicate);
    2121    }
  • trunk/src/org/openstreetmap/josm/tools/SubclassFilteredCollection.java

    r10584 r10657  
    120120     * @return The filtered collection. It is a {@code Collection<T>}.
    121121     */
    122     public static <T> SubclassFilteredCollection<T, T> filter(Collection<T> collection, java.util.function.Predicate<T> predicate) {
     122    public static <T> SubclassFilteredCollection<T, T> filter(Collection<? extends T> collection, java.util.function.Predicate<T> predicate) {
    123123        return new SubclassFilteredCollection<>(collection, predicate);
    124124    }
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r10638 r10657  
    102102     * Tests whether {@code predicate} applies to at least one element from {@code collection}.
    103103     * <p>
    104      * Note: you can use {@link Stream#anyMatch(java.util.function.Predicate)} instead.
    105104     * @param <T> type of items
    106105     * @param collection the collection
    107106     * @param predicate the predicate
    108107     * @return {@code true} if {@code predicate} applies to at least one element from {@code collection}
    109      */
     108     * @deprecated use {@link Stream#anyMatch(java.util.function.Predicate)} instead.
     109     */
     110    @Deprecated
    110111    public static <T> boolean exists(Iterable<? extends T> collection, Predicate<? super T> predicate) {
    111112        for (T item : collection) {
     
    120121     * Tests whether {@code predicate} applies to all elements from {@code collection}.
    121122     * <p>
    122      * Note: you can use {@link Stream#allMatch(java.util.function.Predicate)} instead.
    123123     * @param <T> type of items
    124124     * @param collection the collection
    125125     * @param predicate the predicate
    126126     * @return {@code true} if {@code predicate} applies to all elements from {@code collection}
    127      */
     127     * @deprecated use {@link Stream#allMatch(java.util.function.Predicate)} instead.
     128     */
     129    @Deprecated
    128130    public static <T> boolean forAll(Iterable<? extends T> collection, Predicate<? super T> predicate) {
    129131        return !exists(collection, Predicates.not(predicate));
Note: See TracChangeset for help on using the changeset viewer.