Changeset 10657 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-07-27T02:08:34+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java
r10548 r10657 28 28 import org.openstreetmap.josm.tools.Shortcut; 29 29 import org.openstreetmap.josm.tools.UserCancelException; 30 import org.openstreetmap.josm.tools.Utils;31 30 32 31 public final class ReverseWayAction extends JosmAction { … … 135 134 @Override 136 135 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 137 setEnabled( Utils.exists(selection,OsmPrimitive.wayPredicate));136 setEnabled(selection.stream().anyMatch(OsmPrimitive.wayPredicate)); 138 137 } 139 138 } -
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r10601 r10657 235 235 } 236 236 237 static PropertiesMembershipDialog showIfNecessary( Iterable<Node> selectedNodes, boolean preselectNew) throws UserCancelException {237 static PropertiesMembershipDialog showIfNecessary(Collection<Node> selectedNodes, boolean preselectNew) throws UserCancelException { 238 238 final boolean tagged = isTagged(selectedNodes); 239 239 final boolean usedInRelations = isUsedInRelations(selectedNodes); … … 249 249 } 250 250 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)); 257 258 } 258 259 -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadMembersAction.java
r10601 r10657 13 13 import org.openstreetmap.josm.io.OnlineResource; 14 14 import org.openstreetmap.josm.tools.ImageProvider; 15 import org.openstreetmap.josm.tools. Utils;15 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 16 16 17 17 /** … … 40 40 public void setPrimitives(Collection<? extends OsmPrimitive> primitives) { 41 41 // selected non-new relations 42 this.relations = Utils.filter(getRelations(primitives), r -> !r.isNew());42 this.relations = SubclassFilteredCollection.filter(getRelations(primitives), r -> !r.isNew()); 43 43 updateEnabledState(); 44 44 } -
trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java
r10601 r10657 15 15 import org.openstreetmap.josm.io.OnlineResource; 16 16 import org.openstreetmap.josm.tools.ImageProvider; 17 import org.openstreetmap.josm.tools. Utils;17 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 18 18 19 19 /** … … 42 42 Set<OsmPrimitive> ret = new HashSet<>(); 43 43 for (Relation r : rels) { 44 ret.addAll( Utils.filter(r.getIncompleteMembers(), osm -> !osm.isNew()));44 ret.addAll(SubclassFilteredCollection.filter(r.getIncompleteMembers(), osm -> !osm.isNew())); 45 45 } 46 46 return ret; … … 59 59 public void setPrimitives(Collection<? extends OsmPrimitive> primitives) { 60 60 // 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()); 62 62 this.incompleteMembers = buildSetOfIncompleteMembers(relations); 63 63 updateEnabledState(); -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r10656 r10657 15 15 import java.util.Locale; 16 16 import java.util.Map; 17 import java.util.function.Predicate; 17 18 import java.util.regex.Matcher; 18 19 import java.util.regex.Pattern; … … 38 39 import org.openstreetmap.josm.tools.AlphanumComparator; 39 40 import org.openstreetmap.josm.tools.Geometry; 40 import org.openstreetmap.josm.tools.Predicate;41 41 import org.openstreetmap.josm.tools.UncheckedParseException; 42 42 import org.openstreetmap.josm.tools.Utils; … … 298 298 299 299 @Override 300 public final boolean evaluate(OsmPrimitive object) {300 public final boolean test(OsmPrimitive object) { 301 301 return match(object); 302 302 } -
trunk/src/org/openstreetmap/josm/corrector/ReverseWayNoTagCorrector.java
r9539 r10657 55 55 for (Map.Entry<String, String> entry : way.getKeys().entrySet()) { 56 56 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); 58 58 if (isDirectional) { 59 59 final boolean cannotBeCorrected = ReverseWayTagCorrector.getTagCorrections(tag).isEmpty(); -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r10626 r10657 38 38 import java.util.TreeMap; 39 39 import java.util.concurrent.CopyOnWriteArrayList; 40 import java.util.function.Predicate; 40 41 import java.util.regex.Matcher; 41 42 import java.util.regex.Pattern; … … 69 70 import org.openstreetmap.josm.tools.I18n; 70 71 import org.openstreetmap.josm.tools.MultiMap; 71 import org.openstreetmap.josm.tools.Predicate;72 72 import org.openstreetmap.josm.tools.Utils; 73 73 import org.xml.sax.SAXException; -
trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java
r10378 r10657 12 12 import java.util.Set; 13 13 import java.util.concurrent.CopyOnWriteArrayList; 14 import java.util.function.Predicate; 14 15 15 16 import org.openstreetmap.josm.data.osm.Node; … … 18 19 import org.openstreetmap.josm.data.osm.Way; 19 20 import org.openstreetmap.josm.tools.CheckParameterUtil; 20 import org.openstreetmap.josm.tools.Predicate; 21 import org.openstreetmap.josm.tools.Utils; 21 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 22 22 23 23 /** … … 52 52 53 53 @Override 54 public boolean evaluate(Conflict<? extends OsmPrimitive> conflict) {54 public boolean test(Conflict<? extends OsmPrimitive> conflict) { 55 55 return conflict != null && c.isInstance(conflict.getMy()); 56 56 } … … 364 364 */ 365 365 public final Collection<Conflict<? extends OsmPrimitive>> getNodeConflicts() { 366 return Utils.filter(conflicts, NODE_FILTER_PREDICATE);366 return SubclassFilteredCollection.filter(conflicts, NODE_FILTER_PREDICATE); 367 367 } 368 368 … … 373 373 */ 374 374 public final Collection<Conflict<? extends OsmPrimitive>> getWayConflicts() { 375 return Utils.filter(conflicts, WAY_FILTER_PREDICATE);375 return SubclassFilteredCollection.filter(conflicts, WAY_FILTER_PREDICATE); 376 376 } 377 377 … … 382 382 */ 383 383 public final Collection<Conflict<? extends OsmPrimitive>> getRelationConflicts() { 384 return Utils.filter(conflicts, RELATION_FILTER_PREDICATE);384 return SubclassFilteredCollection.filter(conflicts, RELATION_FILTER_PREDICATE); 385 385 } 386 386 … … 396 396 ConflictCollection conflicts1 = (ConflictCollection) obj; 397 397 return Objects.equals(conflicts, conflicts1.conflicts) && 398 398 Objects.equals(listeners, conflicts1.listeners); 399 399 } 400 400 } -
trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java
r10608 r10657 16 16 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 17 17 import org.openstreetmap.josm.gui.util.GuiHelper; 18 import org.openstreetmap.josm.tools. Utils;18 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 19 19 20 20 /** … … 203 203 return getOpenChangesets(); 204 204 } else { 205 return new ArrayList<>( Utils.filter(getOpenChangesets(),205 return new ArrayList<>(SubclassFilteredCollection.filter(getOpenChangesets(), 206 206 object -> JosmUserIdentityManager.getInstance().isCurrentUser(object.getUser()))); 207 207 } -
trunk/src/org/openstreetmap/josm/data/osm/FilterWorker.java
r10308 r10657 6 6 7 7 import org.openstreetmap.josm.data.osm.FilterMatcher.FilterType; 8 import org.openstreetmap.josm.tools. Utils;8 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 9 9 10 10 /** … … 32 32 boolean changed; 33 33 // 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); 37 37 return changed; 38 38 } -
trunk/src/org/openstreetmap/josm/data/osm/NoteData.java
r10619 r10657 16 16 import org.openstreetmap.josm.data.notes.NoteComment; 17 17 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 18 import org.openstreetmap.josm.tools.Utils;19 18 20 19 /** … … 154 153 } else { 155 154 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()); 157 156 if (!isDirty) { 158 157 noteList.put(newNote); -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r10656 r10657 19 19 import java.util.Objects; 20 20 import java.util.Set; 21 import java.util.function.Predicate; 21 22 22 23 import org.openstreetmap.josm.Main; … … 27 28 import org.openstreetmap.josm.gui.mappaint.StyleCache; 28 29 import org.openstreetmap.josm.tools.CheckParameterUtil; 29 import org.openstreetmap.josm.tools.Predicate;30 30 import org.openstreetmap.josm.tools.Predicates; 31 31 import org.openstreetmap.josm.tools.Utils; -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r10656 r10657 16 16 import org.openstreetmap.josm.data.osm.visitor.Visitor; 17 17 import org.openstreetmap.josm.tools.CopyList; 18 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 18 19 import org.openstreetmap.josm.tools.Utils; 19 20 import org.openstreetmap.josm.tools.Utils.Function; … … 350 351 */ 351 352 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())); 353 354 } 354 355 -
trunk/src/org/openstreetmap/josm/data/validation/Test.java
r10413 r10657 9 9 import java.util.List; 10 10 import java.util.Objects; 11 import java.util.function.Predicate; 11 12 12 13 import javax.swing.JCheckBox; … … 25 26 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 26 27 import org.openstreetmap.josm.tools.GBC; 27 import org.openstreetmap.josm.tools.Predicate;28 28 import org.openstreetmap.josm.tools.Utils; 29 29 -
trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java
r10608 r10657 29 29 import org.openstreetmap.josm.tools.Geometry; 30 30 import org.openstreetmap.josm.tools.Pair; 31 import org.openstreetmap.josm.tools. Utils;31 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 32 32 33 33 /** … … 91 91 // warning level only if several relations have different names, see #10945 92 92 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()) { 94 94 level = Severity.WARNING; 95 95 } else { … … 243 243 // No street segment found near this house, report error on if the relation does not contain incomplete street ways (fix #8314) 244 244 if (hasIncompleteWays) return; 245 List<OsmPrimitive> errorList = new ArrayList< OsmPrimitive>(street);245 List<OsmPrimitive> errorList = new ArrayList<>(street); 246 246 errorList.add(0, house); 247 247 errors.add(new AddressError(this, HOUSE_NUMBER_TOO_FAR, errorList, -
trunk/src/org/openstreetmap/josm/data/validation/tests/ConditionalKeys.java
r10632 r10657 20 20 import org.openstreetmap.josm.tools.LanguageInfo; 21 21 import org.openstreetmap.josm.tools.Predicates; 22 import org.openstreetmap.josm.tools. Utils;22 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 23 23 24 24 /** … … 156 156 public List<TestError> validatePrimitive(OsmPrimitive p) { 157 157 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(:.*)?$")))) { 159 160 if (!isKeyValid(key)) { 160 161 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 158 158 final String highway = way.get("highway"); 159 159 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))) { 161 161 return true; 162 162 } … … 174 174 } 175 175 176 return Utils. exists(Utils.filteredCollection(referrers, Way.class),176 return Utils.filteredCollection(referrers, Way.class).stream().anyMatch( 177 177 otherWay -> !way.equals(otherWay) && otherWay.hasTag("highway", highway, highway.replaceAll("_link$", ""))); 178 178 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r10608 r10657 26 26 import java.util.Objects; 27 27 import java.util.Set; 28 import java.util.function.Predicate; 28 29 import java.util.regex.Matcher; 29 30 import java.util.regex.Pattern; … … 66 67 import org.openstreetmap.josm.tools.CheckParameterUtil; 67 68 import org.openstreetmap.josm.tools.MultiMap; 68 import org.openstreetmap.josm.tools.Predicate;69 69 import org.openstreetmap.josm.tools.Utils; 70 70 … … 390 390 391 391 @Override 392 public boolean evaluate(OsmPrimitive primitive) {392 public boolean test(OsmPrimitive primitive) { 393 393 // Tests whether the primitive contains a deprecated tag which is represented by this MapCSSTagChecker. 394 394 return whichSelectorMatchesPrimitive(primitive) != null; … … 788 788 Main.debug("- Errors: "+pErrors); 789 789 } 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)); 791 791 if (isError != i.getValue()) { 792 792 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 29 29 import org.openstreetmap.josm.tools.Pair; 30 30 import org.openstreetmap.josm.tools.Predicates; 31 import org.openstreetmap.josm.tools.Utils;32 31 33 32 /** … … 157 156 boolean ignore = false; 158 157 for (String ignoredKey : IGNORED_KEYS.get()) { 159 if ( Utils.exists(error.getPrimitives(),Predicates.hasKey(ignoredKey))) {158 if (error.getPrimitives().stream().anyMatch(Predicates.hasKey(ignoredKey))) { 160 159 ignore = true; 161 160 break; -
trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java
r10363 r10657 70 70 for (Node n : w.getNodes()) { 71 71 if (!isPowerTower(n)) { 72 if (!isPowerAllowed(n) && IN_DOWNLOADED_AREA. evaluate(n)) {72 if (!isPowerAllowed(n) && IN_DOWNLOADED_AREA.test(n)) { 73 73 if (!w.isFirstLastNode(n) || !isPowerStation(n)) { 74 74 potentialErrors.add(new PowerLineError(this, n, w)); -
trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedNode.java
r10046 r10657 43 43 if (n.isUsable() && !n.isTagged() && n.getReferrers().isEmpty()) { 44 44 45 if (!n.hasKeys() && IN_DOWNLOADED_AREA. evaluate(n)) {45 if (!n.hasKeys() && IN_DOWNLOADED_AREA.test(n)) { 46 46 String msg = marktr("No tags"); 47 47 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 16 16 import org.openstreetmap.josm.gui.mappaint.ElemStyles; 17 17 import org.openstreetmap.josm.tools.Predicates; 18 import org.openstreetmap.josm.tools.Utils;19 18 20 19 /** … … 68 67 if (wayNode.isOutsideDownloadArea()) { 69 68 return; 70 } else if ( Utils.exists(wayNode.getReferrers(),Predicates.hasTag("route", "ferry"))) {69 } else if (wayNode.getReferrers().stream().anyMatch(Predicates.hasTag("route", "ferry"))) { 71 70 return; 72 71 } else if (isArea(p)) { -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r10625 r10657 294 294 if (middleMouseDown || isAtOldPosition) { 295 295 Collection<OsmPrimitive> osms = mv.getAllNearest(ms.mousePos, 296 o -> isUsablePredicate. evaluate(o) && isSelectablePredicate.evaluate(o));296 o -> isUsablePredicate.test(o) && isSelectablePredicate.test(o)); 297 297 298 298 final JPanel c = new JPanel(new GridBagLayout()); -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r10634 r10657 26 26 import java.util.TreeMap; 27 27 import java.util.concurrent.CopyOnWriteArrayList; 28 import java.util.function.Predicate; 28 29 import java.util.zip.CRC32; 29 30 … … 59 60 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 60 61 import org.openstreetmap.josm.gui.util.CursorManager; 61 import org.openstreetmap.josm.tools.Predicate;62 62 import org.openstreetmap.josm.tools.Utils; 63 63 … … 818 818 819 819 for (Node n : ds.searchNodes(getBBox(p, PROP_SNAP_DISTANCE.get()))) { 820 if (predicate. evaluate(n)820 if (predicate.test(n) 821 821 && (dist = getPoint2D(n).distanceSq(p)) < snapDistanceSq) { 822 822 List<Node> nlist; … … 1027 1027 1028 1028 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)) { 1030 1030 continue; 1031 1031 } … … 1471 1471 for (OsmPrimitive o : nearestList) { 1472 1472 for (OsmPrimitive r : o.getReferrers()) { 1473 if (r instanceof Relation && predicate. evaluate(r)) {1473 if (r instanceof Relation && predicate.test(r)) { 1474 1474 parentRelations.add(r); 1475 1475 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java
r10611 r10657 25 25 import org.openstreetmap.josm.data.osm.RelationToChildReference; 26 26 import org.openstreetmap.josm.gui.util.GuiHelper; 27 import org.openstreetmap.josm.tools.Utils;28 27 29 28 /** … … 200 199 public void prepareDefaultRelationDecisions() { 201 200 202 if ( Utils.forAll(primitives,OsmPrimitive.nodePredicate)) {201 if (primitives.stream().allMatch(OsmPrimitive.nodePredicate)) { 203 202 final Collection<OsmPrimitive> primitivesInDecisions = new HashSet<>(); 204 203 for (final RelationMemberConflictDecision i : decisions) { … … 234 233 iterators.add(i.iterator()); 235 234 } 236 while ( Utils.forAll(iterators,it -> it.hasNext())) {235 while (iterators.stream().allMatch(it -> it.hasNext())) { 237 236 final List<RelationMemberConflictDecision> decisions = new ArrayList<>(); 238 237 final Collection<String> roles = new HashSet<>(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r10619 r10657 80 80 import org.openstreetmap.josm.tools.InputMapUtils; 81 81 import org.openstreetmap.josm.tools.Shortcut; 82 import org.openstreetmap.josm.tools. Utils;82 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 83 83 84 84 /** … … 488 488 private void updateFilteredRelations() { 489 489 if (filter != null) { 490 filteredRelations = new ArrayList<>( Utils.filter(relations, filter::match));490 filteredRelations = new ArrayList<>(SubclassFilteredCollection.filter(relations, filter::match)); 491 491 } else if (filteredRelations != null) { 492 492 filteredRelations = null; -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r10619 r10657 878 878 private Set<OsmPrimitive> members = new HashSet<>(); 879 879 private List<Integer> position = new ArrayList<>(); 880 private Iterable<OsmPrimitive> selection;880 private Collection<OsmPrimitive> selection; 881 881 private String positionString; 882 882 private String roleString; 883 883 884 MemberInfo( Iterable<OsmPrimitive> selection) {884 MemberInfo(Collection<OsmPrimitive> selection) { 885 885 this.selection = selection; 886 886 } … … 896 896 positionString = Utils.getPositionListString(position); 897 897 // 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)))) { 899 899 positionString += ",\u2717"; 900 900 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java
r10611 r10657 17 17 import java.util.Map.Entry; 18 18 import java.util.Set; 19 import java.util.function.Predicate; 19 20 20 21 import javax.swing.JTree; … … 36 37 import org.openstreetmap.josm.tools.Destroyable; 37 38 import org.openstreetmap.josm.tools.MultiMap; 38 import org.openstreetmap.josm.tools.Predicate;39 39 import org.openstreetmap.josm.tools.Predicates; 40 import org.openstreetmap.josm.tools.Utils;41 40 42 41 /** … … 364 363 final TestError error = (TestError) ((DefaultMutableTreeNode) child).getUserObject(); 365 364 if (error.getPrimitives() != null) { 366 if ( Utils.exists(error.getPrimitives(),isRelevant)) {365 if (error.getPrimitives().stream().anyMatch(isRelevant)) { 367 366 paths.add(p.pathByAddingChild(child)); 368 367 } -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java
r10611 r10657 14 14 import java.util.Map.Entry; 15 15 import java.util.Objects; 16 import java.util.function.Predicate; 16 17 17 18 import javax.swing.JOptionPane; … … 26 27 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 27 28 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 28 import org.openstreetmap.josm.tools.Predicate; 29 import org.openstreetmap.josm.tools.Utils; 29 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 30 30 import org.openstreetmap.josm.tools.WindowGeometry; 31 31 import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler; … … 177 177 */ 178 178 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); 180 180 if (notNewPrimitives.isEmpty()) { 181 181 JOptionPane.showMessageDialog( … … 187 187 } 188 188 189 Collection<? extends PrimitiveId> toLoad = Utils.filter(primitives, unloadedHistoryPredicate);189 Collection<? extends PrimitiveId> toLoad = SubclassFilteredCollection.filter(primitives, unloadedHistoryPredicate); 190 190 if (!toLoad.isEmpty()) { 191 191 HistoryLoadTask task = new HistoryLoadTask(); … … 217 217 218 218 @Override 219 public boolean evaluate(PrimitiveId p) {219 public boolean test(PrimitiveId p) { 220 220 History h = hds.getHistory(p); 221 221 if (h == null) -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java
r10607 r10657 11 11 import java.util.Objects; 12 12 import java.util.Set; 13 import java.util.function.Predicate; 13 14 import java.util.regex.Pattern; 14 15 … … 26 27 import org.openstreetmap.josm.gui.mappaint.Environment; 27 28 import org.openstreetmap.josm.tools.CheckParameterUtil; 28 import org.openstreetmap.josm.tools.Predicate;29 29 import org.openstreetmap.josm.tools.Predicates; 30 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 30 31 import org.openstreetmap.josm.tools.Utils; 31 32 … … 463 464 return e.osm.isKeyFalse(label) ^ negateResult; 464 465 case REGEX: 465 return Utils.exists(e.osm.keySet(),containsPattern) ^ negateResult;466 return e.osm.keySet().stream().anyMatch(containsPattern) ^ negateResult; 466 467 default: 467 468 return e.osm.hasKey(label) ^ negateResult; … … 486 487 String key = label; 487 488 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); 489 490 if (!matchingKeys.isEmpty()) { 490 491 key = matchingKeys.iterator().next(); … … 666 667 */ 667 668 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); 669 670 } 670 671 -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r10627 r10657 38 38 import org.openstreetmap.josm.tools.Predicates; 39 39 import org.openstreetmap.josm.tools.RightAndLefthandTraffic; 40 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 40 41 import org.openstreetmap.josm.tools.Utils; 41 42 import org.openstreetmap.josm.tools.Utils.Function; … … 1134 1135 public Float aggregateList(List<?> lst) { 1135 1136 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())); 1137 1138 return nonNullList.isEmpty() ? (Float) Float.NaN : computeMax ? Collections.max(nonNullList) : Collections.min(nonNullList); 1138 1139 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r10627 r10657 25 25 import org.openstreetmap.josm.tools.Pair; 26 26 import org.openstreetmap.josm.tools.Predicates; 27 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 27 28 import org.openstreetmap.josm.tools.Utils; 28 29 … … 320 321 throw new NoSuchElementException(); 321 322 } 322 final Collection<Relation> multipolygons = Utils.filteredCollection( Utils.filter(323 final Collection<Relation> multipolygons = Utils.filteredCollection(SubclassFilteredCollection.filter( 323 324 e.osm.getReferrers(), Predicates.hasTag("type", "multipolygon")), Relation.class); 324 325 final Relation multipolygon = multipolygons.iterator().next(); -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ListEditor.java
r10611 r10657 19 19 import org.openstreetmap.josm.gui.widgets.JosmTextField; 20 20 import org.openstreetmap.josm.tools.GBC; 21 import org.openstreetmap.josm.tools. Utils;21 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 22 22 23 23 /** … … 43 43 @Override 44 44 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())); 46 46 } 47 47 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r10634 r10657 21 21 import java.util.Map; 22 22 import java.util.Set; 23 import java.util.function.Predicate; 23 24 24 25 import javax.swing.AbstractAction; … … 60 61 import org.openstreetmap.josm.tools.ImageProvider; 61 62 import org.openstreetmap.josm.tools.ImageProvider.ImageResourceCallback; 62 import org.openstreetmap.josm.tools.Predicate;63 63 import org.openstreetmap.josm.tools.Utils; 64 64 import org.openstreetmap.josm.tools.template_engine.ParseError; … … 297 297 } 298 298 299 boolean presetInitiallyMatches = !selected.isEmpty() && Utils.forAll(selected,this);299 boolean presetInitiallyMatches = !selected.isEmpty() && selected.stream().allMatch(this); 300 300 JPanel items = new JPanel(new GridBagLayout()); 301 301 for (TaggingPresetItem i : data) { … … 556 556 */ 557 557 @Override 558 public boolean evaluate(OsmPrimitive p) {558 public boolean test(OsmPrimitive p) { 559 559 return matches(EnumSet.of(TaggingPresetType.forPrimitive(p)), p.getKeys(), false); 560 560 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java
r10590 r10657 282 282 && preset.roles != null && !preset.roles.roles.isEmpty()) { 283 283 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)); 285 285 // keep the preset to allow the creation of new relations 286 286 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java
r10590 r10657 115 115 * @param primitive the primitive 116 116 * @return a new collection of all presets matching the given preset. 117 * @see TaggingPreset# evaluate(OsmPrimitive)117 * @see TaggingPreset#test(OsmPrimitive) 118 118 * @since 9265 119 119 */ 120 120 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)); 122 122 } 123 123 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
r10615 r10657 29 29 import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog; 30 30 import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault; 31 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 31 32 import org.openstreetmap.josm.tools.Utils; 32 33 … … 193 194 Main.worker.submit(() -> { 194 195 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); 196 197 ds.setSelected(filteredPrimitives); 197 198 forTagAdd.addAll(filteredPrimitives); -
trunk/src/org/openstreetmap/josm/tools/FilteredCollection.java
r7395 r10657 17 17 * @param predicate The predicate to use as filter 18 18 */ 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) { 20 20 super(collection, predicate); 21 21 } -
trunk/src/org/openstreetmap/josm/tools/SubclassFilteredCollection.java
r10584 r10657 120 120 * @return The filtered collection. It is a {@code Collection<T>}. 121 121 */ 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) { 123 123 return new SubclassFilteredCollection<>(collection, predicate); 124 124 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r10638 r10657 102 102 * Tests whether {@code predicate} applies to at least one element from {@code collection}. 103 103 * <p> 104 * Note: you can use {@link Stream#anyMatch(java.util.function.Predicate)} instead.105 104 * @param <T> type of items 106 105 * @param collection the collection 107 106 * @param predicate the predicate 108 107 * @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 110 111 public static <T> boolean exists(Iterable<? extends T> collection, Predicate<? super T> predicate) { 111 112 for (T item : collection) { … … 120 121 * Tests whether {@code predicate} applies to all elements from {@code collection}. 121 122 * <p> 122 * Note: you can use {@link Stream#allMatch(java.util.function.Predicate)} instead.123 123 * @param <T> type of items 124 124 * @param collection the collection 125 125 * @param predicate the predicate 126 126 * @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 128 130 public static <T> boolean forAll(Iterable<? extends T> collection, Predicate<? super T> predicate) { 129 131 return !exists(collection, Predicates.not(predicate));
Note:
See TracChangeset
for help on using the changeset viewer.