Changeset 10657 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2016-07-27T02:08:34+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
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)) {
Note:
See TracChangeset
for help on using the changeset viewer.