Changeset 15717 in josm
- Timestamp:
- 2020-01-18T14:14:01+01:00 (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/Projections.java
r13602 r15717 17 17 import java.util.regex.Matcher; 18 18 import java.util.regex.Pattern; 19 import java.util.stream.Collectors; 19 20 20 21 import org.openstreetmap.josm.data.projection.datum.Datum; … … 44 45 import org.openstreetmap.josm.tools.JosmRuntimeException; 45 46 import org.openstreetmap.josm.tools.Logging; 46 import org.openstreetmap.josm.tools.Utils;47 47 48 48 /** … … 407 407 408 408 private static String listKeys(Map<String, ?> map) { 409 List<String> keys = new ArrayList<>(map.keySet());410 Collections.sort(keys);411 return Utils.join(", ", keys);409 return map.keySet().stream() 410 .sorted() 411 .collect(Collectors.joining(", ")); 412 412 } 413 413 -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r15371 r15717 76 76 import org.openstreetmap.josm.tools.Logging; 77 77 import org.openstreetmap.josm.tools.Shortcut; 78 import org.openstreetmap.josm.tools.Utils;79 78 import org.openstreetmap.josm.tools.bugreport.BugReport; 80 79 … … 816 815 */ 817 816 public String getLayerInformationForSourceTag() { 818 final Set<String> layerInfo =layerManager.getVisibleLayersInZOrder().stream()817 return layerManager.getVisibleLayersInZOrder().stream() 819 818 .filter(layer -> layer.getChangesetSourceTag() != null && !layer.getChangesetSourceTag().trim().isEmpty()) 820 .map(layer -> layer.getChangesetSourceTag().trim()).distinct().collect(Collectors.toSet()); 821 return Utils.join("; ", layerInfo); 819 .map(layer -> layer.getChangesetSourceTag().trim()) 820 .distinct() 821 .collect(Collectors.joining("; ")); 822 822 } 823 823 -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/AbstractCopyAction.java
r13956 r15717 3 3 4 4 import java.awt.event.ActionEvent; 5 import java.util.Arrays; 5 6 import java.util.Collection; 6 7 import java.util.Objects; 7 import java.util.Set;8 import java.util.TreeSet;9 8 import java.util.function.IntFunction; 10 9 import java.util.function.Supplier; 10 import java.util.stream.Collectors; 11 11 12 12 import javax.swing.AbstractAction; … … 15 15 import org.openstreetmap.josm.data.osm.Tagged; 16 16 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 17 import org.openstreetmap.josm.tools.Utils;18 17 19 18 /** … … 44 43 public void actionPerformed(ActionEvent ae) { 45 44 int[] rows = tagTable.getSelectedRows(); 46 Set<String> values = new TreeSet<>();47 45 Collection<? extends Tagged> sel = objectSupplier.get(); 48 46 if (rows.length == 0 || sel == null || sel.isEmpty()) return; 49 47 50 for (int row: rows) { 51 String key = keySupplier.apply(row); 52 for (Tagged p : sel) { 53 Collection<String> s = getString(p, key); 54 if (s != null) { 55 values.addAll(s); 56 } 57 } 58 } 48 final String values = Arrays.stream(rows) 49 .mapToObj(keySupplier) 50 .flatMap(key -> sel.stream().map(p -> getString(p, key))) 51 .filter(Objects::nonNull) 52 .flatMap(Collection::stream) 53 .sorted() 54 .collect(Collectors.joining("\n")); 59 55 if (!values.isEmpty()) { 60 ClipboardUtils.copyString( Utils.join("\n", values));56 ClipboardUtils.copyString(values); 61 57 } 62 58 } -
trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesWithReferrersTask.java
r14153 r15717 13 13 import java.util.List; 14 14 import java.util.Set; 15 import java.util.stream.Collectors; 15 16 16 17 import javax.swing.JLabel; … … 33 34 import org.openstreetmap.josm.io.OsmTransferException; 34 35 import org.openstreetmap.josm.tools.GBC; 35 import org.openstreetmap.josm.tools.Utils;36 36 import org.xml.sax.SAXException; 37 37 … … 219 219 txt.setColumns(40); 220 220 txt.setRows(1); 221 txt.setText( Utils.join(", ", errs));221 txt.setText(errs.stream().map(String::valueOf).collect(Collectors.joining(", "))); 222 222 JScrollPane scroll = new JScrollPane(txt); 223 223 p.add(scroll, GBC.eop().weight(1.0, 0.0).fill(GBC.HORIZONTAL)); -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r14201 r15717 7 7 import java.util.Arrays; 8 8 import java.util.Collection; 9 import java.util.HashSet;10 9 import java.util.LinkedList; 11 10 import java.util.List; 12 import java.util.Set;13 11 14 12 import javax.swing.ImageIcon; … … 347 345 return (MapCSSStyleSource) entry; 348 346 } 349 Set<String> mimes = new HashSet<>(Arrays.asList(MapCSSStyleSource.MAPCSS_STYLE_MIME_TYPES.split(", "))); 350 try (CachedFile cf = new CachedFile(entry.url).setHttpAccept(Utils.join(", ", mimes))) { 347 try (CachedFile cf = new CachedFile(entry.url).setHttpAccept(MapCSSStyleSource.MAPCSS_STYLE_MIME_TYPES)) { 351 348 String zipEntryPath = cf.findZipEntryPath("mapcss", "style"); 352 349 if (zipEntryPath != null) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java
r15716 r15717 307 307 * @param args arguments 308 308 * @return assembled string 309 * @see Utils#join309 * @see Collectors#joining 310 310 */ 311 311 @NullableArguments 312 312 public static String concat(Object... args) { // NO_UCD (unused code) 313 return Utils.join("",Arrays.asList(args));313 return Arrays.stream(args).map(String::valueOf).collect(Collectors.joining()); 314 314 } 315 315 -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSRule.java
r12379 r15717 4 4 import java.util.List; 5 5 import java.util.Objects; 6 import java.util.stream.Collectors; 6 7 7 8 import org.openstreetmap.josm.gui.mappaint.Environment; 8 9 import org.openstreetmap.josm.gui.mappaint.StyleSource; 9 import org.openstreetmap.josm.tools.Utils;10 10 11 11 /** … … 109 109 @Override 110 110 public String toString() { 111 return selector + " {\n " + Utils.join("\n ", declaration.instructions) + "\n}"; 111 return selector + declaration.instructions.stream() 112 .map(String::valueOf) 113 .collect(Collectors.joining("\n ", " {\n ", "\n}")); 112 114 } 113 115 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
r15588 r15717 29 29 import java.util.concurrent.locks.ReadWriteLock; 30 30 import java.util.concurrent.locks.ReentrantReadWriteLock; 31 import java.util.stream.Collectors; 31 32 import java.util.zip.ZipEntry; 32 33 import java.util.zip.ZipFile; … … 811 812 @Override 812 813 public String toString() { 813 return Utils.join("\n", rules);814 return rules.stream().map(MapCSSRule::toString).collect(Collectors.joining("\n")); 814 815 } 815 816 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r15289 r15717 14 14 import java.util.function.IntSupplier; 15 15 import java.util.regex.PatternSyntaxException; 16 import java.util.stream.Collectors; 16 17 17 18 import org.openstreetmap.josm.data.osm.INode; … … 783 784 @Override 784 785 public String toString() { 785 return base + (Range.ZERO_TO_INFINITY.equals(range) ? "" : range) + (conds != null ? Utils.join("", conds) : "") 786 return base 787 + (Range.ZERO_TO_INFINITY.equals(range) ? "" : range) 788 + (conds != null ? conds.stream().map(String::valueOf).collect(Collectors.joining("")) : "") 786 789 + (subpart != null && subpart != Subpart.DEFAULT_SUBPART ? ("::" + subpart) : ""); 787 790 } -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMSLayerPanel.java
r15228 r15717 30 30 import org.openstreetmap.josm.tools.GBC; 31 31 import org.openstreetmap.josm.tools.Logging; 32 import org.openstreetmap.josm.tools.Utils;33 32 34 33 /** … … 161 160 ) 162 161 ); 163 name.setText(wms.buildRootUrlWithoutCapabilities() + ": " + Utils.join(", ", tree.getSelectedLayers())); 162 name.setText(wms.buildRootUrlWithoutCapabilities() + ": " + 163 tree.getSelectedLayers().stream().map(LayerDetails::toString).collect(Collectors.joining(", "))); 164 164 } 165 165 showBounds.setEnabled(tree.getSelectedLayers().size() == 1); -
trunk/src/org/openstreetmap/josm/io/MultiFetchOverpassObjectReader.java
r12816 r15717 3 3 4 4 import java.util.Set; 5 import java.util. function.Function;5 import java.util.stream.Collectors; 6 6 7 7 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 17 17 @Override 18 18 protected String buildRequestString(final OsmPrimitiveType type, Set<Long> idPackage) { 19 final Function<Long, Object> toOverpassExpression = x -> type.getAPIName() + '(' + x + ");>;"; 20 final String query = '(' + Utils.join("", Utils.transform(idPackage, toOverpassExpression)) + ");out meta;"; 19 final String query = idPackage.stream() 20 .map(x -> type.getAPIName() + '(' + x + ");>;") 21 .collect(Collectors.joining("", "(", ");out meta;")); 21 22 return "interpreter?data=" + Utils.encodeUrl(query); 22 23 } -
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r15520 r15717 23 23 import java.util.concurrent.Executors; 24 24 import java.util.concurrent.Future; 25 import java.util.stream.Collectors; 25 26 26 27 import org.openstreetmap.josm.data.osm.DataSet; … … 270 271 */ 271 272 protected String buildRequestString(final OsmPrimitiveType type, Set<Long> idPackage) { 272 return type.getAPIName() + "s?" + type.getAPIName() + "s=" + Utils.join(",",idPackage);273 return type.getAPIName() + "s?" + type.getAPIName() + "s=" + idPackage.stream().map(String::valueOf).collect(Collectors.joining(",")); 273 274 } 274 275 -
trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java
r14741 r15717 9 9 import java.nio.charset.StandardCharsets; 10 10 import java.nio.file.Files; 11 import java.util.ArrayList;12 11 import java.util.Collection; 13 12 import java.util.HashMap; 14 13 import java.util.List; 15 14 import java.util.Map; 15 import java.util.Objects; 16 16 import java.util.Set; 17 import java.util.stream.Collectors; 17 18 import java.util.zip.ZipEntry; 18 19 import java.util.zip.ZipOutputStream; … … 237 238 } 238 239 Set<Layer> deps = dependencies.get(layer); 239 if (deps != null && !deps.isEmpty()) { 240 List<Integer> depsInt = new ArrayList<>(); 241 for (Layer depLayer : deps) { 242 int depIndex = layers.indexOf(depLayer); 243 if (depIndex == -1) { 244 Logging.warn("Unable to find " + depLayer); 245 } else { 246 depsInt.add(depIndex+1); 247 } 240 final String depends = deps == null ? "" : deps.stream().map(depLayer -> { 241 int depIndex = layers.indexOf(depLayer); 242 if (depIndex == -1) { 243 Logging.warn("Unable to find " + depLayer); 244 return null; 245 } else { 246 return Integer.toString(depIndex+1); 248 247 } 249 if (!depsInt.isEmpty()) {250 el.setAttribute("depends", Utils.join(",", depsInt));251 }248 }).filter(Objects::nonNull).collect(Collectors.joining(",")); 249 if (!depends.isEmpty()) { 250 el.setAttribute("depends", depends); 252 251 } 253 252 layersEl.appendChild(el); -
trunk/src/org/openstreetmap/josm/tools/MultiMap.java
r12865 r15717 2 2 package org.openstreetmap.josm.tools; 3 3 4 import java.util.ArrayList;5 4 import java.util.Collection; 6 5 import java.util.Collections; 7 6 import java.util.HashMap; 8 7 import java.util.LinkedHashSet; 9 import java.util.List;10 8 import java.util.Map; 11 9 import java.util.Map.Entry; 12 10 import java.util.Objects; 13 11 import java.util.Set; 12 import java.util.stream.Collectors; 14 13 15 14 /** … … 246 245 @Override 247 246 public String toString() { 248 List<String> entries = new ArrayList<>(map.size()); 249 for (Entry<A, Set<B>> entry : map.entrySet()) { 250 entries.add(entry.getKey() + "->{" + Utils.join(",", entry.getValue()) + '}'); 251 } 252 return '(' + Utils.join(",", entries) + ')'; 247 return map.entrySet().stream() 248 .map(entry -> entry.getKey() + "->" + entry.getValue()) 249 .collect(Collectors.joining(",", "(", ")")); 253 250 } 254 251 } -
trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
r14190 r15717 18 18 import java.text.MessageFormat; 19 19 import java.util.ArrayList; 20 import java.util.Arrays; 20 21 import java.util.Locale; 21 22 import java.util.Random; 23 import java.util.TreeSet; 22 24 import java.util.logging.Logger; 23 25 … … 35 37 import org.openstreetmap.josm.data.osm.Node; 36 38 import org.openstreetmap.josm.data.osm.OsmPrimitive; 39 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 37 40 import org.openstreetmap.josm.data.osm.Relation; 38 41 import org.openstreetmap.josm.data.osm.RelationMember; … … 42 45 43 46 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 47 import org.openstreetmap.josm.testutils.JOSMTestRules; 44 48 45 49 /** … … 49 53 public class MultiFetchServerObjectReaderTest { 50 54 private static Logger logger = Logger.getLogger(MultiFetchServerObjectReader.class.getName()); 55 56 /** 57 * Setup test. 58 */ 59 @Rule 60 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 61 public JOSMTestRules test = new JOSMTestRules().preferences(); 51 62 52 63 /** … … 332 343 assertEquals(9999999, reader.getMissingPrimitives().iterator().next().getUniqueId()); 333 344 } 345 346 /** 347 * Test {@link MultiFetchServerObjectReader#buildRequestString} 348 */ 349 @Test 350 public void testBuildRequestString() { 351 String requestString = new MultiFetchServerObjectReader() 352 .buildRequestString(OsmPrimitiveType.WAY, new TreeSet<>(Arrays.asList(130L, 123L, 126L))); 353 assertEquals("ways?ways=123,126,130", requestString); 354 } 334 355 } -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTest.java
r14317 r15717 10 10 import java.util.Arrays; 11 11 import java.util.List; 12 import java.util.stream.Collectors; 13 import java.util.stream.Stream; 12 14 13 15 import javax.swing.JScrollPane; … … 24 26 import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker; 25 27 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 26 import org.openstreetmap.josm.tools.Utils;27 28 28 import com.google.common.collect.ImmutableMap; 29 29 … … 70 70 final String old = System.getProperty("josm.plugins"); 71 71 try { 72 System.setProperty("josm.plugins", 73 Utils.join(",", PluginHandler.DEPRECATED_PLUGINS) + "," + 74 Utils.join(",", Arrays.asList(PluginHandler.UNMAINTAINED_PLUGINS))); 72 final String plugins = Stream.concat( 73 PluginHandler.DEPRECATED_PLUGINS.stream(), 74 PluginHandler.UNMAINTAINED_PLUGINS.stream() 75 ).map(String::valueOf).collect(Collectors.joining(",")); 76 System.setProperty("josm.plugins", plugins); 75 77 List<PluginInformation> list = PluginHandler.buildListOfPluginsToLoad(null, null); 76 78 assertNotNull(list);
Note:
See TracChangeset
for help on using the changeset viewer.