Changeset 10608 in josm for trunk/src/org/openstreetmap/josm
- Timestamp:
- 2016-07-23T15:46:39+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/APIDataSet.java
r9067 r10608 5 5 import java.util.Collection; 6 6 import java.util.Collections; 7 import java.util.Comparator;8 7 import java.util.HashMap; 9 8 import java.util.HashSet; … … 335 334 Collections.sort( 336 335 ret, 337 new Comparator<Relation>() { 338 @Override 339 public int compare(Relation o1, Relation o2) { 340 return Integer.compare(uploadOrder.indexOf(o1), uploadOrder.indexOf(o2)); 341 } 342 } 336 (o1, o2) -> Integer.compare(uploadOrder.indexOf(o1), uploadOrder.indexOf(o2)) 343 337 ); 344 338 return ret; -
trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
r10469 r10608 243 243 244 244 protected void displayNotification() { 245 GuiHelper.runInEDT(new Runnable() { 246 @Override 247 public void run() { 245 GuiHelper.runInEDT( 248 246 new Notification(tr("Your work has been saved automatically.")) 249 247 .setDuration(Notification.TIME_SHORT) 250 .show(); 251 } 252 }); 248 ::show); 253 249 } 254 250 … … 346 342 File jvmDir = new File(System.getProperty("java.io.tmpdir") + File.separator + "hsperfdata_" + System.getProperty("user.name")); 347 343 if (jvmDir.exists() && jvmDir.canRead()) { 348 File[] files = jvmDir.listFiles(new FileFilter() { 349 @Override 350 public boolean accept(File file) { 351 return file.getName().equals(jvmId) && file.isFile(); 352 } 353 }); 344 File[] files = jvmDir.listFiles((FileFilter) file -> file.getName().equals(jvmId) && file.isFile()); 354 345 return files != null && files.length == 1; 355 346 } … … 365 356 final OpenFileTask openFileTsk = new OpenFileTask(files, null, tr("Restoring files")); 366 357 final Future<?> openFilesFuture = Main.worker.submit(openFileTsk); 367 return Main.worker.submit(new Runnable() { 368 @Override 369 public void run() { 370 try { 371 // Wait for opened tasks to be generated. 372 openFilesFuture.get(); 373 for (File f: openFileTsk.getSuccessfullyOpenedFiles()) { 374 moveToDeletedLayersFolder(f); 375 } 376 } catch (InterruptedException | ExecutionException e) { 377 Main.error(e); 378 } 358 return Main.worker.submit(() -> { 359 try { 360 // Wait for opened tasks to be generated. 361 openFilesFuture.get(); 362 for (File f: openFileTsk.getSuccessfullyOpenedFiles()) { 363 moveToDeletedLayersFolder(f); 364 } 365 } catch (InterruptedException | ExecutionException e) { 366 Main.error(e); 379 367 } 380 368 }); -
trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java
r10593 r10608 372 372 373 373 final ReadLocalPluginInformationTask task = new ReadLocalPluginInformationTask(); 374 Runnable r = new Runnable() { 375 @Override 376 public void run() { 377 if (task.isCanceled()) return; 378 synchronized (CustomConfigurator.class) { 379 try { // proceed only after all other tasks were finished 380 while (busy) CustomConfigurator.class.wait(); 381 } catch (InterruptedException ex) { 382 Main.warn("InterruptedException while reading local plugin information"); 383 } 384 385 SwingUtilities.invokeLater(new Runnable() { 386 @Override 387 public void run() { 388 List<PluginInformation> availablePlugins = task.getAvailablePlugins(); 389 List<PluginInformation> toInstallPlugins = new ArrayList<>(); 390 List<PluginInformation> toRemovePlugins = new ArrayList<>(); 391 List<PluginInformation> toDeletePlugins = new ArrayList<>(); 392 for (PluginInformation pi: availablePlugins) { 393 String name = pi.name.toLowerCase(Locale.ENGLISH); 394 if (installList.contains(name)) toInstallPlugins.add(pi); 395 if (removeList.contains(name)) toRemovePlugins.add(pi); 396 if (deleteList.contains(name)) toDeletePlugins.add(pi); 397 } 398 if (!installList.isEmpty()) { 399 PluginDownloadTask pluginDownloadTask = 400 new PluginDownloadTask(Main.parent, toInstallPlugins, tr("Installing plugins")); 401 Main.worker.submit(pluginDownloadTask); 402 } 403 Collection<String> pls = new ArrayList<>(Main.pref.getCollection("plugins")); 404 for (PluginInformation pi: toInstallPlugins) { 405 if (!pls.contains(pi.name)) { 406 pls.add(pi.name); 407 } 408 } 409 for (PluginInformation pi: toRemovePlugins) { 410 pls.remove(pi.name); 411 } 412 for (PluginInformation pi: toDeletePlugins) { 413 pls.remove(pi.name); 414 new File(Main.pref.getPluginsDirectory(), pi.name+".jar").deleteOnExit(); 415 } 416 Main.pref.putCollection("plugins", pls); 374 Runnable r = () -> { 375 if (task.isCanceled()) return; 376 synchronized (CustomConfigurator.class) { 377 try { // proceed only after all other tasks were finished 378 while (busy) CustomConfigurator.class.wait(); 379 } catch (InterruptedException ex) { 380 Main.warn(ex, "InterruptedException while reading local plugin information"); 381 } 382 383 SwingUtilities.invokeLater(() -> { 384 List<PluginInformation> availablePlugins = task.getAvailablePlugins(); 385 List<PluginInformation> toInstallPlugins = new ArrayList<>(); 386 List<PluginInformation> toRemovePlugins = new ArrayList<>(); 387 List<PluginInformation> toDeletePlugins = new ArrayList<>(); 388 for (PluginInformation pi1: availablePlugins) { 389 String name = pi1.name.toLowerCase(Locale.ENGLISH); 390 if (installList.contains(name)) toInstallPlugins.add(pi1); 391 if (removeList.contains(name)) toRemovePlugins.add(pi1); 392 if (deleteList.contains(name)) toDeletePlugins.add(pi1); 393 } 394 if (!installList.isEmpty()) { 395 PluginDownloadTask pluginDownloadTask = 396 new PluginDownloadTask(Main.parent, toInstallPlugins, tr("Installing plugins")); 397 Main.worker.submit(pluginDownloadTask); 398 } 399 Collection<String> pls = new ArrayList<>(Main.pref.getCollection("plugins")); 400 for (PluginInformation pi2: toInstallPlugins) { 401 if (!pls.contains(pi2.name)) { 402 pls.add(pi2.name); 417 403 } 418 }); 419 } 404 } 405 for (PluginInformation pi3: toRemovePlugins) { 406 pls.remove(pi3.name); 407 } 408 for (PluginInformation pi4: toDeletePlugins) { 409 pls.remove(pi4.name); 410 new File(Main.pref.getPluginsDirectory(), pi4.name+".jar").deleteOnExit(); 411 } 412 Main.pref.putCollection("plugins", pls); 413 }); 420 414 } 421 415 }; -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r10600 r10608 138 138 protected final SortedMap<String, Setting<?>> defaultsMap = new TreeMap<>(); 139 139 140 private final Predicate<Entry<String, Setting<?>>> NO_DEFAULT_SETTINGS_ENTRY = new Predicate<Entry<String, Setting<?>>>() { 141 @Override 142 public boolean evaluate(Entry<String, Setting<?>> e) { 143 return !e.getValue().equals(defaultsMap.get(e.getKey())); 144 } 145 }; 140 private final Predicate<Entry<String, Setting<?>>> NO_DEFAULT_SETTINGS_ENTRY = 141 e -> !e.getValue().equals(defaultsMap.get(e.getKey())); 146 142 147 143 /** -
trunk/src/org/openstreetmap/josm/data/cache/HostLimitQueue.java
r10420 r10608 125 125 if (limit != null) { 126 126 limit.acquire(); 127 jcsJob.setFinishedTask(new Runnable() { 128 @Override 129 public void run() { 130 releaseSemaphore(jcsJob); 131 } 132 }); 127 jcsJob.setFinishedTask(() -> releaseSemaphore(jcsJob)); 133 128 } 134 129 } … … 141 136 ret = limit.tryAcquire(); 142 137 if (ret) { 143 job.setFinishedTask(new Runnable() { 144 @Override 145 public void run() { 146 releaseSemaphore(job); 147 } 148 }); 138 job.setFinishedTask(() -> releaseSemaphore(job)); 149 139 } 150 140 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r10467 r10608 362 362 */ 363 363 public Iterable<Collection<WayPoint>> getLinesIterable(final boolean[] trackVisibility) { 364 return new Iterable<Collection<WayPoint>>() { 365 @Override 366 public Iterator<Collection<WayPoint>> iterator() { 367 return new LinesIterator(GpxData.this, trackVisibility); 368 } 369 }; 364 return () -> new LinesIterator(GpxData.this, trackVisibility); 370 365 } 371 366 -
trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java
r10469 r10608 61 61 @Override 62 62 protected Callable<List<Attribution>> getAttributionLoaderCallable() { 63 return new Callable<List<Attribution>>() { 64 65 @Override 66 public List<Attribution> call() throws Exception { 67 BingAttributionData attributionLoader = new BingAttributionData(); 68 int waitTimeSec = 1; 69 while (true) { 70 try { 71 String xml = attributionLoader.updateIfRequiredString(); 72 List<Attribution> ret = parseAttributionText(new InputSource(new StringReader(xml))); 73 if (attributionDownloadedTask != null) { 74 GuiHelper.runInEDT(attributionDownloadedTask); 75 attributionDownloadedTask = null; 76 } 77 return ret; 78 } catch (IOException ex) { 79 Main.warn(ex, "Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds."); 80 Thread.sleep(waitTimeSec * 1000L); 81 waitTimeSec *= 2; 63 return () -> { 64 BingAttributionData attributionLoader = new BingAttributionData(); 65 int waitTimeSec = 1; 66 while (true) { 67 try { 68 String xml = attributionLoader.updateIfRequiredString(); 69 List<Attribution> ret = parseAttributionText(new InputSource(new StringReader(xml))); 70 if (attributionDownloadedTask != null) { 71 GuiHelper.runInEDT(attributionDownloadedTask); 72 attributionDownloadedTask = null; 82 73 } 74 return ret; 75 } catch (IOException ex) { 76 Main.warn(ex, "Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds."); 77 Thread.sleep(waitTimeSec * 1000L); 78 waitTimeSec *= 2; 83 79 } 84 80 } -
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r10378 r10608 14 14 import java.util.Collection; 15 15 import java.util.Collections; 16 import java.util.Comparator;17 16 import java.util.HashSet; 18 17 import java.util.List; … … 85 84 86 85 private static class TileMatrixSetBuilder { 87 SortedSet<TileMatrix> tileMatrix = new TreeSet<>(new Comparator<TileMatrix>() { 88 @Override 89 public int compare(TileMatrix o1, TileMatrix o2) { 90 // reverse the order, so it will be from greatest (lowest zoom level) to lowest value (highest zoom level) 91 return -1 * Double.compare(o1.scaleDenominator, o2.scaleDenominator); 92 } 93 }); // sorted by zoom level 86 // sorted by zoom level 87 SortedSet<TileMatrix> tileMatrix = new TreeSet<>((o1, o2) -> -1 * Double.compare(o1.scaleDenominator, o2.scaleDenominator)); 94 88 private String crs; 95 89 private String identifier; -
trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java
r9519 r10608 16 16 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 17 17 import org.openstreetmap.josm.gui.util.GuiHelper; 18 import org.openstreetmap.josm.tools.Predicate;19 18 import org.openstreetmap.josm.tools.Utils; 20 19 … … 70 69 71 70 protected void fireChangesetCacheEvent(final ChangesetCacheEvent e) { 72 GuiHelper.runInEDT(new Runnable() { 73 @Override public void run() { 74 for (ChangesetCacheListener l: listeners) { 75 l.changesetCacheUpdated(e); 76 } 71 GuiHelper.runInEDT(() -> { 72 for (ChangesetCacheListener l: listeners) { 73 l.changesetCacheUpdated(e); 77 74 } 78 75 }); … … 206 203 return getOpenChangesets(); 207 204 } else { 208 return new ArrayList<>(Utils.filter(getOpenChangesets(), new Predicate<Changeset>() { 209 @Override 210 public boolean evaluate(Changeset object) { 211 return JosmUserIdentityManager.getInstance().isCurrentUser(object.getUser()); 212 } 213 })); 205 return new ArrayList<>(Utils.filter(getOpenChangesets(), 206 object -> JosmUserIdentityManager.getInstance().isCurrentUser(object.getUser()))); 214 207 } 215 208 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r10590 r10608 47 47 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 48 48 import org.openstreetmap.josm.tools.FilteredCollection; 49 import org.openstreetmap.josm.tools.Predicate;50 49 import org.openstreetmap.josm.tools.Predicates; 51 50 import org.openstreetmap.josm.tools.SubclassFilteredCollection; … … 614 613 */ 615 614 public Collection<OsmPrimitive> getSelectedNodesAndWays() { 616 return new FilteredCollection<>(getSelected(), new Predicate<OsmPrimitive>() { 617 @Override 618 public boolean evaluate(OsmPrimitive primitive) { 619 return primitive instanceof Node || primitive instanceof Way; 620 } 621 }); 615 return new FilteredCollection<>(getSelected(), primitive -> primitive instanceof Node || primitive instanceof Way); 622 616 } 623 617 -
trunk/src/org/openstreetmap/josm/data/osm/NoteData.java
r10134 r10608 16 16 import org.openstreetmap.josm.data.notes.NoteComment; 17 17 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 18 import org.openstreetmap.josm.tools.Predicate;19 18 import org.openstreetmap.josm.tools.Utils; 20 19 … … 37 36 * Within each subgroup it sorts by ID 38 37 */ 39 public static final Comparator<Note> DEFAULT_COMPARATOR = new Comparator<Note>() { 40 @Override 41 public int compare(Note n1, Note n2) { 42 if (n1.getId() < 0 && n2.getId() > 0) { 43 return 1; 44 } 45 if (n1.getId() > 0 && n2.getId() < 0) { 46 return -1; 47 } 48 if (n1.getState() == State.CLOSED && n2.getState() == State.OPEN) { 49 return 1; 50 } 51 if (n1.getState() == State.OPEN && n2.getState() == State.CLOSED) { 52 return -1; 53 } 54 return Long.compare(Math.abs(n1.getId()), Math.abs(n2.getId())); 55 } 38 public static final Comparator<Note> DEFAULT_COMPARATOR = (n1, n2) -> { 39 if (n1.getId() < 0 && n2.getId() > 0) { 40 return 1; 41 } 42 if (n1.getId() > 0 && n2.getId() < 0) { 43 return -1; 44 } 45 if (n1.getState() == State.CLOSED && n2.getState() == State.OPEN) { 46 return 1; 47 } 48 if (n1.getState() == State.OPEN && n2.getState() == State.CLOSED) { 49 return -1; 50 } 51 return Long.compare(Math.abs(n1.getId()), Math.abs(n2.getId())); 56 52 }; 57 53 58 54 /** Sorts notes strictly by creation date */ 59 public static final Comparator<Note> DATE_COMPARATOR = new Comparator<Note>() { 60 @Override 61 public int compare(Note n1, Note n2) { 55 public static final Comparator<Note> DATE_COMPARATOR = (n1, n2) -> n1.getCreatedAt().compareTo(n2.getCreatedAt()); 56 57 /** Sorts notes by user, then creation date */ 58 public static final Comparator<Note> USER_COMPARATOR = (n1, n2) -> { 59 String n1User = n1.getFirstComment().getUser().getName(); 60 String n2User = n2.getFirstComment().getUser().getName(); 61 if (n1User.equals(n2User)) { 62 62 return n1.getCreatedAt().compareTo(n2.getCreatedAt()); 63 63 } 64 return n1.getFirstComment().getUser().getName().compareTo(n2.getFirstComment().getUser().getName()); 64 65 }; 65 66 66 /** Sorts notes by user, then creation date */67 public static final Comparator<Note> USER_COMPARATOR = new Comparator<Note>() {68 @Override69 public int compare(Note n1, Note n2) {70 String n1User = n1.getFirstComment().getUser().getName();71 String n2User = n2.getFirstComment().getUser().getName();72 if (n1User.equals(n2User)) {73 return n1.getCreatedAt().compareTo(n2.getCreatedAt());74 }75 return n1.getFirstComment().getUser().getName().compareTo(n2.getFirstComment().getUser().getName());76 }77 };78 79 67 /** Sorts notes by the last modified date */ 80 public static final Comparator<Note> LAST_ACTION_COMPARATOR = new Comparator<Note>() { 81 @Override 82 public int compare(Note n1, Note n2) { 83 Date n1Date = n1.getComments().get(n1.getComments().size()-1).getCommentTimestamp(); 84 Date n2Date = n2.getComments().get(n2.getComments().size()-1).getCommentTimestamp(); 85 return n1Date.compareTo(n2Date); 86 } 68 public static final Comparator<Note> LAST_ACTION_COMPARATOR = (n1, n2) -> { 69 Date n1Date = n1.getComments().get(n1.getComments().size()-1).getCommentTimestamp(); 70 Date n2Date = n2.getComments().get(n2.getComments().size()-1).getCommentTimestamp(); 71 return n1Date.compareTo(n2Date); 87 72 }; 88 73 … … 169 154 } else { 170 155 final Note existingNote = noteList.get(newNote); 171 final boolean isDirty = Utils.exists(existingNote.getComments(), new Predicate<NoteComment>() { 172 @Override 173 public boolean evaluate(NoteComment object) { 174 return object.isNew(); 175 } 176 }); 156 final boolean isDirty = Utils.exists(existingNote.getComments(), object -> object.isNew()); 177 157 if (!isDirty) { 178 158 noteList.put(newNote); -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r10583 r10608 110 110 111 111 /** 112 * A tagged way that matches this pattern has a direction. 113 * @see #FLAG_HAS_DIRECTIONS 114 */ 115 private static volatile Match directionKeys; 116 117 /** 118 * A tagged way that matches this pattern has a direction that is reversed. 119 * <p> 120 * This pattern should be a subset of {@link #directionKeys} 121 * @see #FLAG_DIRECTION_REVERSED 122 */ 123 private static volatile Match reversedDirectionKeys; 124 125 static { 126 String reversedDirectionDefault = "oneway=\"-1\""; 127 128 String directionDefault = "oneway? | (aerialway=* -aerialway=station) | "+ 129 "waterway=stream | waterway=river | waterway=ditch | waterway=drain | "+ 130 "\"piste:type\"=downhill | \"piste:type\"=sled | man_made=\"piste:halfpipe\" | "+ 131 "junction=roundabout | (highway=motorway & -oneway=no & -oneway=reversible) | "+ 132 "(highway=motorway_link & -oneway=no & -oneway=reversible)"; 133 134 reversedDirectionKeys = compileDirectionKeys("tags.reversed_direction", reversedDirectionDefault); 135 directionKeys = compileDirectionKeys("tags.direction", directionDefault); 136 } 137 138 /** 112 139 * Replies the sub-collection of {@link OsmPrimitive}s of type <code>type</code> present in 113 140 * another collection of {@link OsmPrimitive}s. The result collection is a list. … … 174 201 * @see OsmPrimitive#isUsable() 175 202 */ 176 public static final Predicate<OsmPrimitive> isUsablePredicate = new Predicate<OsmPrimitive>() { 177 @Override 178 public boolean evaluate(OsmPrimitive primitive) { 179 return primitive.isUsable(); 180 } 181 }; 203 public static final Predicate<OsmPrimitive> isUsablePredicate = primitive -> primitive.isUsable(); 182 204 183 205 /** 184 206 * A predicate filtering primitives that are selectable. 185 207 */ 186 public static final Predicate<OsmPrimitive> isSelectablePredicate = new Predicate<OsmPrimitive>() { 187 @Override 188 public boolean evaluate(OsmPrimitive primitive) { 189 return primitive.isSelectable(); 190 } 191 }; 208 public static final Predicate<OsmPrimitive> isSelectablePredicate = primitive -> primitive.isSelectable(); 192 209 193 210 /** 194 211 * A predicate filtering primitives that are not deleted. 195 212 */ 196 public static final Predicate<OsmPrimitive> nonDeletedPredicate = new Predicate<OsmPrimitive>() { 197 @Override public boolean evaluate(OsmPrimitive primitive) { 198 return !primitive.isDeleted(); 199 } 200 }; 213 public static final Predicate<OsmPrimitive> nonDeletedPredicate = primitive -> !primitive.isDeleted(); 201 214 202 215 /** 203 216 * A predicate filtering primitives that are not deleted and not incomplete. 204 217 */ 205 public static final Predicate<OsmPrimitive> nonDeletedCompletePredicate = new Predicate<OsmPrimitive>() { 206 @Override public boolean evaluate(OsmPrimitive primitive) { 207 return !primitive.isDeleted() && !primitive.isIncomplete(); 208 } 209 }; 218 public static final Predicate<OsmPrimitive> nonDeletedCompletePredicate = 219 primitive -> !primitive.isDeleted() && !primitive.isIncomplete(); 210 220 211 221 /** 212 222 * A predicate filtering primitives that are not deleted and not incomplete and that are not a relation. 213 223 */ 214 public static final Predicate<OsmPrimitive> nonDeletedPhysicalPredicate = new Predicate<OsmPrimitive>() { 215 @Override public boolean evaluate(OsmPrimitive primitive) { 216 return !primitive.isDeleted() && !primitive.isIncomplete() && !(primitive instanceof Relation); 217 } 218 }; 224 public static final Predicate<OsmPrimitive> nonDeletedPhysicalPredicate = 225 primitive -> !primitive.isDeleted() && !primitive.isIncomplete() && !(primitive instanceof Relation); 219 226 220 227 /** 221 228 * A predicate filtering primitives that are modified 222 229 */ 223 public static final Predicate<OsmPrimitive> modifiedPredicate = new Predicate<OsmPrimitive>() { 224 @Override public boolean evaluate(OsmPrimitive primitive) { 225 return primitive.isModified(); 226 } 227 }; 230 public static final Predicate<OsmPrimitive> modifiedPredicate = primitive -> primitive.isModified(); 228 231 229 232 /** … … 245 248 * A predicate filtering multipolygon relations. 246 249 */ 247 public static final Predicate<OsmPrimitive> multipolygonPredicate = new Predicate<OsmPrimitive>() { 248 @Override public boolean evaluate(OsmPrimitive primitive) { 249 return primitive.getClass() == Relation.class && ((Relation) primitive).isMultipolygon(); 250 } 251 }; 250 public static final Predicate<OsmPrimitive> multipolygonPredicate = 251 primitive -> primitive.getClass() == Relation.class && ((Relation) primitive).isMultipolygon(); 252 252 253 253 /** … … 256 256 * @see #FLAG_HAS_DIRECTIONS 257 257 */ 258 public static final Predicate<Tag> directionalKeyPredicate = new Predicate<Tag>() { 259 @Override 260 public boolean evaluate(Tag tag) { 261 return directionKeys.match(tag); 262 } 263 }; 258 public static final Predicate<Tag> directionalKeyPredicate = tag -> directionKeys.match(tag); 264 259 265 260 /** … … 843 838 } 844 839 845 /**846 * A tagged way that matches this pattern has a direction.847 * @see #FLAG_HAS_DIRECTIONS848 */849 private static volatile Match directionKeys;850 851 /**852 * A tagged way that matches this pattern has a direction that is reversed.853 * <p>854 * This pattern should be a subset of {@link #directionKeys}855 * @see #FLAG_DIRECTION_REVERSED856 */857 private static volatile Match reversedDirectionKeys;858 859 static {860 String reversedDirectionDefault = "oneway=\"-1\"";861 862 String directionDefault = "oneway? | (aerialway=* -aerialway=station) | "+863 "waterway=stream | waterway=river | waterway=ditch | waterway=drain | "+864 "\"piste:type\"=downhill | \"piste:type\"=sled | man_made=\"piste:halfpipe\" | "+865 "junction=roundabout | (highway=motorway & -oneway=no & -oneway=reversible) | "+866 "(highway=motorway_link & -oneway=no & -oneway=reversible)";867 868 reversedDirectionKeys = compileDirectionKeys("tags.reversed_direction", reversedDirectionDefault);869 directionKeys = compileDirectionKeys("tags.direction", directionDefault);870 }871 872 840 private static Match compileDirectionKeys(String prefName, String defaultValue) throws AssertionError { 873 841 try { -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r10242 r10608 15 15 import org.openstreetmap.josm.data.osm.visitor.Visitor; 16 16 import org.openstreetmap.josm.tools.CopyList; 17 import org.openstreetmap.josm.tools.Predicate;18 17 import org.openstreetmap.josm.tools.Utils; 18 import org.openstreetmap.josm.tools.Utils.Function; 19 19 20 20 /** … … 349 349 */ 350 350 public Collection<RelationMember> getMembersFor(final Collection<? extends OsmPrimitive> primitives) { 351 return Utils.filter(getMembers(), new Predicate<RelationMember>() { 352 @Override 353 public boolean evaluate(RelationMember member) { 354 return primitives.contains(member.getMember()); 355 } 356 }); 351 return Utils.filter(getMembers(), member -> primitives.contains(member.getMember())); 357 352 } 358 353 … … 405 400 406 401 public List<OsmPrimitive> getMemberPrimitivesList() { 407 return Utils.transform(getMembers(), new Utils.Function<RelationMember, OsmPrimitive>() { 408 @Override 409 public OsmPrimitive apply(RelationMember x) { 410 return x.getMember(); 411 } 412 }); 402 return Utils.transform(getMembers(), (Function<RelationMember, OsmPrimitive>) x -> x.getMember()); 413 403 } 414 404 -
trunk/src/org/openstreetmap/josm/data/osm/event/SelectionEventManager.java
r10043 r10608 88 88 } 89 89 90 private final Runnable edtRunnable = new Runnable() { 91 @Override 92 public void run() { 93 if (selection != null) { 94 fireEvents(inEDTListeners, selection); 95 } 90 private final Runnable edtRunnable = () -> { 91 if (selection != null) { 92 fireEvents(inEDTListeners, selection); 96 93 } 97 94 }; -
trunk/src/org/openstreetmap/josm/data/osm/history/History.java
r10600 r10608 5 5 import java.util.ArrayList; 6 6 import java.util.Collections; 7 import java.util.Comparator;8 7 import java.util.Date; 9 8 import java.util.List; … … 70 69 public History sortAscending() { 71 70 List<HistoryOsmPrimitive> copy = new ArrayList<>(versions); 72 Collections.sort( 73 copy, 74 new Comparator<HistoryOsmPrimitive>() { 75 @Override 76 public int compare(HistoryOsmPrimitive o1, HistoryOsmPrimitive o2) { 77 return o1.compareTo(o2); 78 } 79 } 80 ); 71 Collections.sort(copy, (o1, o2) -> o1.compareTo(o2)); 81 72 return new History(id, type, copy); 82 73 } … … 88 79 public History sortDescending() { 89 80 List<HistoryOsmPrimitive> copy = new ArrayList<>(versions); 90 Collections.sort( 91 copy, 92 new Comparator<HistoryOsmPrimitive>() { 93 @Override 94 public int compare(HistoryOsmPrimitive o1, HistoryOsmPrimitive o2) { 95 return o2.compareTo(o1); 96 } 97 } 98 ); 81 Collections.sort(copy, (o1, o2) -> o2.compareTo(o1)); 99 82 return new History(id, type, copy); 100 83 } … … 106 89 */ 107 90 public History from(final Date fromDate) { 108 return filter( 109 this, 110 new FilterPredicate() { 111 @Override 112 public boolean matches(HistoryOsmPrimitive primitive) { 113 return primitive.getTimestamp().compareTo(fromDate) >= 0; 114 } 115 } 116 ); 91 return filter(this, primitive -> primitive.getTimestamp().compareTo(fromDate) >= 0); 117 92 } 118 93 … … 123 98 */ 124 99 public History until(final Date untilDate) { 125 return filter( 126 this, 127 new FilterPredicate() { 128 @Override 129 public boolean matches(HistoryOsmPrimitive primitive) { 130 return primitive.getTimestamp().compareTo(untilDate) <= 0; 131 } 132 } 133 ); 100 return filter(this, primitive -> primitive.getTimestamp().compareTo(untilDate) <= 0); 134 101 } 135 102 … … 150 117 */ 151 118 public History from(final long fromVersion) { 152 return filter( 153 this, 154 new FilterPredicate() { 155 @Override 156 public boolean matches(HistoryOsmPrimitive primitive) { 157 return primitive.getVersion() >= fromVersion; 158 } 159 } 160 ); 119 return filter(this, primitive -> primitive.getVersion() >= fromVersion); 161 120 } 162 121 … … 167 126 */ 168 127 public History until(final long untilVersion) { 169 return filter( 170 this, 171 new FilterPredicate() { 172 @Override 173 public boolean matches(HistoryOsmPrimitive primitive) { 174 return primitive.getVersion() <= untilVersion; 175 } 176 } 177 ); 128 return filter(this, primitive -> primitive.getVersion() <= untilVersion); 178 129 } 179 130 … … 194 145 */ 195 146 public History forUserId(final long uid) { 196 return filter( 197 this, 198 new FilterPredicate() { 199 @Override 200 public boolean matches(HistoryOsmPrimitive primitive) { 201 return primitive.getUser() != null && primitive.getUser().getId() == uid; 202 } 203 } 204 ); 147 return filter(this, primitive -> primitive.getUser() != null && primitive.getUser().getId() == uid); 205 148 } 206 149 … … 283 226 * @throws IndexOutOfBoundsException if index out or range 284 227 */ 285 public HistoryOsmPrimitive get(int idx) throws IndexOutOfBoundsException{228 public HistoryOsmPrimitive get(int idx) { 286 229 if (idx < 0 || idx >= versions.size()) 287 230 throw new IndexOutOfBoundsException(MessageFormat.format( … … 338 281 public String toString() { 339 282 StringBuilder result = new StringBuilder("History [" 340 + (type != null ? "type=" + type + ", ": "") + "id=" + id);283 + (type != null ? ("type=" + type + ", ") : "") + "id=" + id); 341 284 if (versions != null) { 342 285 result.append(", versions=\n"); -
trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java
r10378 r10608 29 29 import org.openstreetmap.josm.tools.Geometry; 30 30 import org.openstreetmap.josm.tools.Pair; 31 import org.openstreetmap.josm.tools.Predicate;32 31 import org.openstreetmap.josm.tools.Utils; 33 32 … … 92 91 // warning level only if several relations have different names, see #10945 93 92 final String name = list.get(0).get("name"); 94 if (name == null || Utils.filter(list, new Predicate<Relation>() { 95 @Override 96 public boolean evaluate(Relation r) { 97 return name.equals(r.get("name")); 98 } 99 }).size() < list.size()) { 93 if (name == null || Utils.filter(list, r -> name.equals(r.get("name"))).size() < list.size()) { 100 94 level = Severity.WARNING; 101 95 } else { 102 96 level = Severity.OTHER; 103 97 } 104 List<OsmPrimitive> errorList = new ArrayList< OsmPrimitive>(list);98 List<OsmPrimitive> errorList = new ArrayList<>(list); 105 99 errorList.add(0, p); 106 100 errors.add(new AddressError(this, MULTIPLE_STREET_RELATIONS, level, errorList, -
trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java
r10409 r10608 24 24 import org.openstreetmap.josm.data.validation.Test; 25 25 import org.openstreetmap.josm.data.validation.TestError; 26 import org.openstreetmap.josm.tools.Predicate;27 26 import org.openstreetmap.josm.tools.Utils; 28 27 … … 175 174 } 176 175 177 return Utils.exists(Utils.filteredCollection(referrers, Way.class), new Predicate<Way>() { 178 @Override 179 public boolean evaluate(final Way otherWay) { 180 return !way.equals(otherWay) && otherWay.hasTag("highway", highway, highway.replaceAll("_link$", "")); 181 } 182 }); 176 return Utils.exists(Utils.filteredCollection(referrers, Way.class), 177 otherWay -> !way.equals(otherWay) && otherWay.hasTag("highway", highway, highway.replaceAll("_link$", ""))); 183 178 } 184 179 -
trunk/src/org/openstreetmap/josm/data/validation/tests/Lanes.java
r8846 r10608 18 18 import org.openstreetmap.josm.tools.Predicates; 19 19 import org.openstreetmap.josm.tools.Utils; 20 import org.openstreetmap.josm.tools.Utils.Function; 20 21 21 22 /** … … 51 52 return; 52 53 } 53 final Set<Integer> lanesCount = new HashSet<>(Utils.transform(keysForPattern, new Utils.Function<String, Integer>() { 54 @Override 55 public Integer apply(String key) { 56 return getLanesCount(p.get(key)); 57 } 58 })); 54 final Set<Integer> lanesCount = new HashSet<>(Utils.transform(keysForPattern, 55 (Function<String, Integer>) key -> getLanesCount(p.get(key)))); 59 56 if (lanesCount.size() > 1) { 60 57 // if not all numbers are the same -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r10599 r10608 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import static org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.FixCommand.evaluateObject; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 787 788 Main.debug("- Errors: "+pErrors); 788 789 } 789 final boolean isError = Utils.exists(pErrors, new Predicate<TestError>() { 790 @Override 791 public boolean evaluate(TestError e) { 792 //noinspection EqualsBetweenInconvertibleTypes 793 return e.getTester().equals(check.rule); 794 } 795 }); 790 final boolean isError = Utils.exists(pErrors, e -> e.getTester().equals(check.rule)); 796 791 if (isError != i.getValue()) { 797 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
r10378 r10608 8 8 import java.util.Collection; 9 9 import java.util.Collections; 10 import java.util.Comparator;11 10 import java.util.HashMap; 12 11 import java.util.HashSet; … … 175 174 protected static Set<WaySegment> checkDuplicateWaySegment(Way w) { 176 175 // test for ticket #4959 177 Set<WaySegment> segments = new TreeSet<>(new Comparator<WaySegment>() { 178 @Override 179 public int compare(WaySegment o1, WaySegment o2) { 180 final List<Node> n1 = Arrays.asList(o1.getFirstNode(), o1.getSecondNode()); 181 final List<Node> n2 = Arrays.asList(o2.getFirstNode(), o2.getSecondNode()); 182 Collections.sort(n1); 183 Collections.sort(n2); 184 final int first = n1.get(0).compareTo(n2.get(0)); 185 final int second = n1.get(1).compareTo(n2.get(1)); 186 return first != 0 ? first : second; 187 } 176 Set<WaySegment> segments = new TreeSet<>((o1, o2) -> { 177 final List<Node> n1 = Arrays.asList(o1.getFirstNode(), o1.getSecondNode()); 178 final List<Node> n2 = Arrays.asList(o2.getFirstNode(), o2.getSecondNode()); 179 Collections.sort(n1); 180 Collections.sort(n2); 181 final int first = n1.get(0).compareTo(n2.get(0)); 182 final int second = n1.get(1).compareTo(n2.get(1)); 183 return first != 0 ? first : second; 188 184 }); 189 185 final Set<WaySegment> duplicateWaySegments = new HashSet<>(); -
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r10378 r10608 29 29 import org.openstreetmap.josm.gui.tagging.presets.items.Roles.Role; 30 30 import org.openstreetmap.josm.tools.Utils; 31 import org.openstreetmap.josm.tools.Utils.Function; 31 32 32 33 /** … … 255 256 256 257 // convert in localization friendly way to string of accepted types 257 String typesStr = Utils.join("/", Utils.transform(types, new Utils.Function<TaggingPresetType, Object>() { 258 @Override 259 public Object apply(TaggingPresetType x) { 260 return tr(x.getName()); 261 } 262 })); 258 String typesStr = Utils.join("/", Utils.transform(types, (Function<TaggingPresetType, Object>) x -> tr(x.getName()))); 263 259 264 260 errors.add(new TestError(this, Severity.WARNING, ROLE_VERIF_PROBLEM_MSG, … … 297 293 for (String key : map.keySet()) { 298 294 if (!allroles.containsKey(key)) { 299 String templates = Utils.join("/", Utils.transform(allroles.keySet(), new Utils.Function<String, Object>() { 300 @Override 301 public Object apply(String x) { 302 return tr(x); 303 } 304 })); 295 String templates = Utils.join("/", Utils.transform(allroles.keySet(), (Function<String, Object>) x -> tr(x))); 305 296 306 297 if (!key.isEmpty()) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r10469 r10608 6 6 7 7 import java.awt.GridBagConstraints; 8 import java.awt.event.ActionEvent;9 8 import java.awt.event.ActionListener; 10 9 import java.io.BufferedReader; … … 598 597 testPanel.add(sourcesList, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(23, 0, 0, 0)); 599 598 600 ActionListener disableCheckActionListener = new ActionListener() { 601 @Override 602 public void actionPerformed(ActionEvent e) { 603 handlePrefEnable(); 604 } 605 }; 599 ActionListener disableCheckActionListener = e -> handlePrefEnable(); 606 600 prefCheckKeys.addActionListener(disableCheckActionListener); 607 601 prefCheckKeysBeforeUpload.addActionListener(disableCheckActionListener);
Note:
See TracChangeset
for help on using the changeset viewer.