Changeset 18208 in josm
- Timestamp:
- 2021-09-11T17:50:57+02:00 (3 years ago)
- Location:
- trunk
- Files:
-
- 107 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/SyncEditorLayerIndex.java
r17737 r18208 64 64 import org.openstreetmap.josm.tools.OptionParser.OptionCount; 65 65 import org.openstreetmap.josm.tools.ReflectionUtils; 66 import org.openstreetmap.josm.tools.Utils; 66 67 import org.xml.sax.SAXException; 67 68 … … 959 960 Map<String, Set<String>> jh = getNoTileHeader(j); 960 961 if (!Objects.equals(eh, jh)) { 961 if ( jh == null || jh.isEmpty()) {962 if (Utils.isEmpty(jh)) { 962 963 myprintln("- Missing JOSM no tile headers ("+eh+"): "+getDescription(j)); 963 964 } else if (eh != null && !eh.isEmpty()) { -
trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
r17594 r18208 47 47 import org.openstreetmap.josm.tools.ImageProvider; 48 48 import org.openstreetmap.josm.tools.Logging; 49 import org.openstreetmap.josm.tools.Utils; 49 50 import org.openstreetmap.josm.tools.bugreport.ReportedException; 50 51 … … 115 116 case WMS_ENDPOINT: 116 117 // convert to WMS type 117 if ( info.getDefaultLayers() == null || info.getDefaultLayers().isEmpty()) {118 if (Utils.isEmpty(info.getDefaultLayers())) { 118 119 return getWMSLayerInfo(info); 119 120 } else { … … 122 123 case WMTS: 123 124 // specify which layer to use 124 if ( info.getDefaultLayers() == null || info.getDefaultLayers().isEmpty()) {125 if (Utils.isEmpty(info.getDefaultLayers())) { 125 126 WMTSTileSource tileSource = new WMTSTileSource(info); 126 127 DefaultLayer layerId = tileSource.userSelectLayer(); … … 169 170 } 170 171 } catch (IllegalArgumentException | ReportedException ex) { 171 if ( ex.getMessage() == null || ex.getMessage().isEmpty() || GraphicsEnvironment.isHeadless()) {172 if (Utils.isEmpty(ex.getMessage()) || GraphicsEnvironment.isHeadless()) { 172 173 throw ex; 173 174 } else { -
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r17200 r18208 50 50 import org.openstreetmap.josm.tools.Shortcut; 51 51 import org.openstreetmap.josm.tools.UserCancelException; 52 import org.openstreetmap.josm.tools.Utils; 52 53 53 54 /** … … 113 114 // prepare and clean the list of ways to combine 114 115 // 115 if ( ways == null || ways.isEmpty())116 if (Utils.isEmpty(ways)) 116 117 return null; 117 118 ways.remove(null); // just in case - remove all null ways from the collection -
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r17585 r18208 387 387 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 388 388 DataSet ds = getLayerManager().getEditDataSet(); 389 if (ds == null || selection.isEmpty()) {389 if (ds == null || Utils.isEmpty(selection)) { 390 390 setEnabled(false); 391 391 } else if (update) { -
trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java
r14397 r18208 15 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 16 16 import org.openstreetmap.josm.tools.Shortcut; 17 import org.openstreetmap.josm.tools.Utils; 17 18 18 19 /** … … 44 45 */ 45 46 public static void downloadReferrers(OsmDataLayer targetLayer, Collection<OsmPrimitive> children) { 46 if ( children == null || children.isEmpty())47 if (Utils.isEmpty(children)) 47 48 return; 48 49 MainApplication.worker.submit(new DownloadReferrersTask(targetLayer, children)); -
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r18014 r18208 261 261 @Override 262 262 protected void realRun() throws SAXException, IOException, OsmTransferException { 263 if ( files == null || files.isEmpty()) return;263 if (Utils.isEmpty(files)) return; 264 264 265 265 /** -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r14397 r18208 28 28 import org.openstreetmap.josm.io.OsmTransferException; 29 29 import org.openstreetmap.josm.tools.Shortcut; 30 import org.openstreetmap.josm.tools.Utils; 30 31 31 32 /** … … 120 121 @Override 121 122 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 122 if ( selection == null || selection.isEmpty()) {123 if (Utils.isEmpty(selection)) { 123 124 setEnabled(false); 124 125 } else { -
trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java
r15513 r18208 34 34 import org.openstreetmap.josm.tools.ExceptionUtil; 35 35 import org.openstreetmap.josm.tools.Shortcut; 36 import org.openstreetmap.josm.tools.Utils; 36 37 import org.xml.sax.SAXException; 37 38 … … 138 139 */ 139 140 public void uploadPrimitives(OsmDataLayer layer, Collection<OsmPrimitive> toUpload) { 140 if ( toUpload == null || toUpload.isEmpty()) return;141 if (Utils.isEmpty(toUpload)) return; 141 142 UploadHullBuilder builder = new UploadHullBuilder(); 142 143 toUpload = builder.build(toUpload); -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r18017 r18208 188 188 protected final void extractOsmFilename(DownloadParams settings, String pattern, String url) { 189 189 newLayerName = settings.getLayerName(); 190 if ( newLayerName == null || newLayerName.isEmpty()) {190 if (Utils.isEmpty(newLayerName)) { 191 191 Matcher matcher = Pattern.compile(pattern).matcher(url); 192 192 newLayerName = matcher.matches() && matcher.groupCount() > 0 ? Utils.decodeUrl(matcher.group(1)) : null; -
trunk/src/org/openstreetmap/josm/actions/relation/AbstractRelationAction.java
r17458 r18208 36 36 */ 37 37 protected static final Collection<IRelation<?>> getRelations(Collection<? extends IPrimitive> primitives) { 38 if ( primitives == null || primitives.isEmpty()) {38 if (Utils.isEmpty(primitives)) { 39 39 return Collections.<IRelation<?>>emptySet(); 40 40 } else { -
trunk/src/org/openstreetmap/josm/actions/relation/RecentRelationsAction.java
r16438 r18208 29 29 import org.openstreetmap.josm.tools.ImageProvider; 30 30 import org.openstreetmap.josm.tools.Shortcut; 31 import org.openstreetmap.josm.tools.Utils; 31 32 32 33 /** … … 73 74 public static Relation getLastRelation() { 74 75 List<Relation> recentRelations = getRecentRelationsOnActiveLayer(); 75 if ( recentRelations == null || recentRelations.isEmpty())76 if (Utils.isEmpty(recentRelations)) 76 77 return null; 77 78 return recentRelations.stream().filter(RecentRelationsAction::isRelationListable) -
trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r17358 r18208 26 26 import org.openstreetmap.josm.tools.I18n; 27 27 import org.openstreetmap.josm.tools.ImageProvider; 28 import org.openstreetmap.josm.tools.Utils; 28 29 29 30 /** … … 139 140 String newVal = tag.getValue(); 140 141 141 if ( newVal == null || newVal.isEmpty()) {142 if (Utils.isEmpty(newVal)) { 142 143 if (oldVal != null) { 143 144 // new value is null and tag exists (will delete tag) … … 173 174 String newVal = tag.getValue(); 174 175 175 if ( newVal == null || newVal.isEmpty()) {176 if (Utils.isEmpty(newVal)) { 176 177 if (oldVal != null) 177 178 osm.remove(tag.getKey()); … … 204 205 String msg; 205 206 Map.Entry<String, String> entry = tags.entrySet().iterator().next(); 206 if ( entry.getValue() == null || entry.getValue().isEmpty()) {207 if (Utils.isEmpty(entry.getValue())) { 207 208 switch(OsmPrimitiveType.from(primitive)) { 208 209 case NODE: msg = marktr("Remove \"{0}\" for node ''{1}''"); break; … … 223 224 } else if (objects.size() > 1 && tags.size() == 1) { 224 225 Map.Entry<String, String> entry = tags.entrySet().iterator().next(); 225 if ( entry.getValue() == null || entry.getValue().isEmpty()) {226 if (Utils.isEmpty(entry.getValue())) { 226 227 /* I18n: plural form for objects, but value < 2 not possible! */ 227 228 text = trn("Remove \"{0}\" for {1} object", "Remove \"{0}\" for {1} objects", objects.size(), entry.getKey(), objects.size()); … … 233 234 } else { 234 235 boolean allNull = this.tags.entrySet().stream() 235 .allMatch(tag -> tag.getValue() == null || tag.getValue().isEmpty());236 .allMatch(tag -> Utils.isEmpty(tag.getValue())); 236 237 237 238 if (allNull) { -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r17981 r18208 296 296 */ 297 297 public static Command deleteWithReferences(Collection<? extends OsmPrimitive> selection, boolean silent) { 298 if ( selection == null || selection.isEmpty()) return null;298 if (Utils.isEmpty(selection)) return null; 299 299 Set<OsmPrimitive> parents = OsmPrimitive.getReferrer(selection); 300 300 parents.addAll(selection); … … 402 402 */ 403 403 public static Command delete(Collection<? extends OsmPrimitive> selection, boolean alsoDeleteNodesInWay, boolean silent) { 404 if ( selection == null || selection.isEmpty())404 if (Utils.isEmpty(selection)) 405 405 return null; 406 406 -
trunk/src/org/openstreetmap/josm/command/SelectCommand.java
r15324 r18208 11 11 import org.openstreetmap.josm.data.osm.DataSet; 12 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 import org.openstreetmap.josm.tools.Utils; 13 14 14 15 /** … … 33 34 public SelectCommand(DataSet dataset, Collection<OsmPrimitive> newSelection) { 34 35 super(dataset); 35 if ( newSelection == null || newSelection.isEmpty()) {36 if (Utils.isEmpty(newSelection)) { 36 37 this.newSelection = Collections.emptySet(); 37 38 } else if (newSelection.contains(null)) { -
trunk/src/org/openstreetmap/josm/data/DataSource.java
r16599 r18208 10 10 11 11 import org.openstreetmap.josm.tools.CheckParameterUtil; 12 import org.openstreetmap.josm.tools.Utils; 12 13 13 14 /** … … 75 76 */ 76 77 public static Area getDataSourceArea(Collection<DataSource> dataSources) { 77 if ( dataSources == null || dataSources.isEmpty()) {78 if (Utils.isEmpty(dataSources)) { 78 79 return null; 79 80 } -
trunk/src/org/openstreetmap/josm/data/UserIdentityManager.java
r15725 r18208 24 24 import org.openstreetmap.josm.tools.ListenerList; 25 25 import org.openstreetmap.josm.tools.Logging; 26 import org.openstreetmap.josm.tools.Utils; 26 27 27 28 /** … … 277 278 switch (evt.getKey()) { 278 279 case "osm-server.username": 279 String newUserName = null;280 String newUserName = ""; 280 281 if (evt.getNewValue() instanceof StringSetting) { 281 282 newUserName = ((StringSetting) evt.getNewValue()).getValue(); 282 283 } 283 if ( newUserName == null || newUserName.trim().isEmpty()) {284 if (Utils.isBlank(newUserName)) { 284 285 setAnonymous(); 285 } else { 286 if (!newUserName.equals(userName)) { 287 setPartiallyIdentified(newUserName); 288 } 286 } else if (!newUserName.equals(userName)) { 287 setPartiallyIdentified(newUserName); 289 288 } 290 289 return; … … 294 293 newUrl = ((StringSetting) evt.getNewValue()).getValue(); 295 294 } 296 if ( newUrl == null || newUrl.trim().isEmpty()) {295 if (Utils.isBlank(newUrl)) { 297 296 setAnonymous(); 298 297 } else if (isFullyIdentified()) { -
trunk/src/org/openstreetmap/josm/data/gpx/GpxExtension.java
r16553 r18208 6 6 7 7 import org.openstreetmap.josm.data.gpx.GpxData.XMLNamespace; 8 import org.openstreetmap.josm.tools.Utils; 8 9 import org.xml.sax.Attributes; 9 10 … … 174 175 if (parent instanceof GpxExtension) { 175 176 GpxExtension gpx = ((GpxExtension) parent); 176 if ( (gpx.getValue() == null || gpx.getValue().trim().isEmpty())177 && gpx.getAttributes().isEmpty()178 && gpx.getExtensions().isEmpty()) {177 if (Utils.isBlank(gpx.getValue()) 178 && Utils.isEmpty(gpx.getAttributes()) 179 && Utils.isEmpty(gpx.getExtensions())) { 179 180 gpx.remove(); 180 181 } … … 190 191 if (parent != null && parent instanceof GpxExtension) { 191 192 GpxExtension gpx = (GpxExtension) parent; 192 if ( (gpx.getValue() == null || gpx.getValue().trim().isEmpty())193 if (Utils.isBlank(gpx.getValue()) 193 194 && gpx.getAttributes().isEmpty() 194 195 && !gpx.getExtensions().isVisible()) { -
trunk/src/org/openstreetmap/josm/data/gpx/GpxExtensionCollection.java
r17985 r18208 12 12 import org.openstreetmap.josm.io.GpxReader; 13 13 import org.openstreetmap.josm.tools.Logging; 14 import org.openstreetmap.josm.tools.Utils; 14 15 import org.xml.sax.Attributes; 15 16 … … 66 67 */ 67 68 public void closeChild(String qName, String value) { 68 if ( childStack == null || childStack.isEmpty()) {69 if (Utils.isEmpty(childStack)) { 69 70 Logging.warn("Can''t close child ''{0}'', no element in stack.", qName); 70 71 return; -
trunk/src/org/openstreetmap/josm/data/imagery/LayerDetails.java
r16553 r18208 10 10 11 11 import org.openstreetmap.josm.data.Bounds; 12 import org.openstreetmap.josm.tools.Utils; 12 13 13 14 /** … … 150 151 @Override 151 152 public String toString() { 152 String baseName = (title == null || title.isEmpty()) ? name : title;153 String baseName = Utils.isEmpty(title) ? name : title; 153 154 return abstr == null || abstr.equalsIgnoreCase(baseName) ? baseName : baseName + " (" + abstr + ')'; 154 155 } … … 184 185 */ 185 186 public boolean isSelectable() { 186 return ! (name == null || name.isEmpty());187 return !Utils.isEmpty(name); 187 188 } 188 189 -
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r18076 r18208 536 536 public void setKeys(Map<String, String> keys) { 537 537 Map<String, String> originalKeys = getKeys(); 538 if ( keys == null || keys.isEmpty()) {538 if (Utils.isEmpty(keys)) { 539 539 this.keys = null; 540 540 keysChangedImpl(originalKeys); -
trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java
r14153 r18208 17 17 import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener; 18 18 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 19 import org.openstreetmap.josm.tools.Utils; 19 20 20 21 /** … … 110 111 */ 111 112 public void update(Collection<Changeset> changesets) { 112 if ( changesets == null || changesets.isEmpty()) return;113 if (Utils.isEmpty(changesets)) return; 113 114 DefaultChangesetCacheEvent e = new DefaultChangesetCacheEvent(this); 114 115 for (Changeset cs: changesets) { -
trunk/src/org/openstreetmap/josm/data/osm/DefaultNameFormatter.java
r17825 r18208 247 247 } 248 248 } 249 if ( n == null || n.isEmpty()) {249 if (Utils.isEmpty(n)) { 250 250 n = String.valueOf(way.getId()); 251 251 } -
trunk/src/org/openstreetmap/josm/data/osm/NoteData.java
r18009 r18208 19 19 import org.openstreetmap.josm.tools.ListenerList; 20 20 import org.openstreetmap.josm.tools.Logging; 21 import org.openstreetmap.josm.tools.Utils; 21 22 22 23 /** … … 173 174 */ 174 175 public synchronized void createNote(LatLon location, String text) { 175 if ( text == null || text.isEmpty()) {176 if (Utils.isEmpty(text)) { 176 177 throw new IllegalArgumentException("Comment can not be blank when creating a note"); 177 178 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java
r18050 r18208 11 11 import org.openstreetmap.josm.tools.CheckParameterUtil; 12 12 import org.openstreetmap.josm.tools.TextTagParser; 13 import org.openstreetmap.josm.tools.Utils; 13 14 14 15 /** … … 224 225 */ 225 226 public static boolean isOsmCollectionEditable(Collection<? extends IPrimitive> collection) { 226 if ( collection == null || collection.isEmpty()) {227 if (Utils.isEmpty(collection)) { 227 228 return false; 228 229 } -
trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java
r17559 r18208 15 15 import org.openstreetmap.josm.data.coor.QuadTiling; 16 16 import org.openstreetmap.josm.tools.Logging; 17 import org.openstreetmap.josm.tools.Utils; 17 18 18 19 /** … … 352 353 353 354 boolean canRemove() { 354 return (content == null || content.isEmpty()) && !this.hasChildren();355 return Utils.isEmpty(content) && !this.hasChildren(); 355 356 } 356 357 } -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r17981 r18208 385 385 public void removeMembersFor(Collection<? extends OsmPrimitive> primitives) { 386 386 checkDatasetNotReadOnly(); 387 if ( primitives == null || primitives.isEmpty())387 if (Utils.isEmpty(primitives)) 388 388 return; 389 389 -
trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java
r17585 r18208 23 23 24 24 import org.openstreetmap.josm.tools.Logging; 25 import org.openstreetmap.josm.tools.Utils; 25 26 26 27 /** … … 118 119 public static TagCollection commonToAllPrimitives(Collection<? extends Tagged> primitives) { 119 120 TagCollection tags = new TagCollection(); 120 if ( primitives == null || primitives.isEmpty()) return tags;121 if (Utils.isEmpty(primitives)) return tags; 121 122 // initialize with the first 122 123 tags.add(TagCollection.from(primitives.iterator().next())); … … 565 566 ensureApplicableToPrimitive(); 566 567 for (Tag tag: tags.keySet()) { 567 if ( tag.getValue() == null || tag.getValue().isEmpty()) {568 if (Utils.isEmpty(tag.getValue())) { 568 569 primitive.remove(tag.getKey()); 569 570 } else { -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r18019 r18208 54 54 } 55 55 56 if ( nodes == null || nodes.isEmpty()) {56 if (Utils.isEmpty(nodes)) { 57 57 this.nodes = EMPTY_NODES; 58 58 } else { -
trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
r18202 r18208 54 54 import org.openstreetmap.josm.tools.Logging; 55 55 import org.openstreetmap.josm.tools.UncheckedParseException; 56 import org.openstreetmap.josm.tools.Utils; 56 57 import org.openstreetmap.josm.tools.date.DateUtils; 57 58 … … 1877 1878 protected Collection<Bounds> getBounds(OsmPrimitive primitive) { 1878 1879 final Collection<Bounds> bounds = super.getBounds(primitive); 1879 return bounds == null || bounds.isEmpty() ?1880 return Utils.isEmpty(bounds) ? 1880 1881 Collections.singleton(ProjectionRegistry.getProjection().getWorldBoundsLatLon()) : bounds; 1881 1882 } … … 1896 1897 Preset(String presetName) throws SearchParseError { 1897 1898 1898 if ( presetName == null || presetName.isEmpty()) {1899 if (Utils.isEmpty(presetName)) { 1899 1900 throw new SearchParseError("The name of the preset is required"); 1900 1901 } … … 2219 2220 public static String buildSearchStringForTag(String key, String value) { 2220 2221 final String forKey = '"' + escapeStringForSearch(key) + '"' + '='; 2221 if ( value == null || value.isEmpty()) {2222 if (Utils.isEmpty(value)) { 2222 2223 return forKey + '*'; 2223 2224 } else { -
trunk/src/org/openstreetmap/josm/data/osm/search/SearchSetting.java
r18197 r18208 7 7 8 8 import org.openstreetmap.josm.tools.Logging; 9 import org.openstreetmap.josm.tools.Utils; 9 10 10 11 /** … … 172 173 */ 173 174 public String writeToString() { 174 if ( text == null || text.isEmpty())175 if (Utils.isEmpty(text)) 175 176 return ""; 176 177 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r17986 r18208 613 613 TextLabel text = bs.text; 614 614 String s = text.labelCompositionStrategy.compose(n); 615 if ( s == null || s.isEmpty()) return;615 if (Utils.isEmpty(s)) return; 616 616 617 617 Font defaultFont = g.getFont(); … … 1145 1145 } 1146 1146 String name = text.getString(osm); 1147 if ( name == null || name.isEmpty()) {1147 if (Utils.isEmpty(name)) { 1148 1148 return; 1149 1149 } -
trunk/src/org/openstreetmap/josm/data/sources/SourceInfo.java
r17484 r18208 730 730 */ 731 731 public void setNoTileHeaders(MultiMap<String, String> noTileHeaders) { 732 if ( noTileHeaders == null || noTileHeaders.isEmpty()) {732 if (Utils.isEmpty(noTileHeaders)) { 733 733 this.noTileHeaders = null; 734 734 } else { … … 750 750 */ 751 751 public void setNoTileChecksums(MultiMap<String, String> noTileChecksums) { 752 if ( noTileChecksums == null || noTileChecksums.isEmpty()) {752 if (Utils.isEmpty(noTileChecksums)) { 753 753 this.noTileChecksums = null; 754 754 } else { … … 770 770 */ 771 771 public void setMetadataHeaders(Map<String, String> metadataHeaders) { 772 if ( metadataHeaders == null || metadataHeaders.isEmpty()) {772 if (Utils.isEmpty(metadataHeaders)) { 773 773 this.metadataHeaders = null; 774 774 } else { -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r17787 r18208 82 82 import org.openstreetmap.josm.tools.Logging; 83 83 import org.openstreetmap.josm.tools.Stopwatch; 84 import org.openstreetmap.josm.tools.Utils; 84 85 85 86 /** … … 505 506 int i = 0; 506 507 while (i < list.size()) { 507 if ( list.get(i) == null || list.get(i).isEmpty()) {508 if (Utils.isEmpty(list.get(i))) { 508 509 list.remove(i); 509 510 continue; -
trunk/src/org/openstreetmap/josm/data/validation/ValidationTask.java
r17858 r18208 20 20 import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor; 21 21 import org.openstreetmap.josm.gui.util.GuiHelper; 22 import org.openstreetmap.josm.tools.Utils; 22 23 23 24 /** … … 78 79 @Override 79 80 protected void realRun() { 80 if ( tests == null || tests.isEmpty())81 if (Utils.isEmpty(tests)) 81 82 return; 82 83 errors = new ArrayList<>(); -
trunk/src/org/openstreetmap/josm/data/validation/routines/InetAddressValidator.java
r16647 r18208 20 20 import java.util.Arrays; 21 21 import java.util.List; 22 23 import org.openstreetmap.josm.tools.Utils; 22 24 23 25 /** … … 96 98 // verify that address subgroups are legal 97 99 for (String ipSegment : groups) { 98 if ( ipSegment == null || ipSegment.isEmpty()) {100 if (Utils.isEmpty(ipSegment)) { 99 101 return false; 100 102 } -
trunk/src/org/openstreetmap/josm/data/validation/routines/RegexValidator.java
r16445 r18208 23 23 import java.util.stream.Collectors; 24 24 import java.util.stream.IntStream; 25 26 import org.openstreetmap.josm.tools.Utils; 25 27 26 28 /** … … 126 128 int flags = caseSensitive ? 0 : Pattern.CASE_INSENSITIVE; 127 129 for (int i = 0; i < regexs.length; i++) { 128 if ( regexs[i] == null || regexs[i].isEmpty()) {130 if (Utils.isEmpty(regexs[i])) { 129 131 throw new IllegalArgumentException("Regular expression[" + i + "] is missing"); 130 132 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/ConnectivityRelations.java
r17384 r18208 26 26 import org.openstreetmap.josm.data.validation.TestError; 27 27 import org.openstreetmap.josm.tools.Logging; 28 import org.openstreetmap.josm.tools.Utils; 28 29 29 30 /** … … 76 77 public static Map<Integer, Map<Integer, Boolean>> parseConnectivityTag(Relation relation) { 77 78 final String cnTag = relation.get(CONNECTIVITY_TAG); 78 if ( cnTag == null || cnTag.isEmpty()) {79 if (Utils.isEmpty(cnTag)) { 79 80 return Collections.emptyMap(); 80 81 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java
r17223 r18208 39 39 import org.openstreetmap.josm.tools.Geometry; 40 40 import org.openstreetmap.josm.tools.Geometry.PolygonIntersection; 41 import org.openstreetmap.josm.tools.Utils; 41 42 42 43 /** … … 440 441 PolygonLevelFinder levelFinder = new PolygonLevelFinder(sharedNodes); 441 442 List<PolygonLevel> list = levelFinder.findOuterWays(allPolygons); 442 if ( list == null || list.isEmpty()) {443 if (Utils.isEmpty(list)) { 443 444 return; 444 445 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java
r17643 r18208 16 16 import javax.swing.JPanel; 17 17 18 import ch.poole.openinghoursparser.OpeningHoursParseException;19 import ch.poole.openinghoursparser.OpeningHoursParser;20 import ch.poole.openinghoursparser.Rule;21 import ch.poole.openinghoursparser.Util;22 18 import org.openstreetmap.josm.command.ChangePropertyCommand; 23 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 28 24 import org.openstreetmap.josm.data.validation.TestError; 29 25 import org.openstreetmap.josm.tools.GBC; 26 import org.openstreetmap.josm.tools.Utils; 27 28 import ch.poole.openinghoursparser.OpeningHoursParseException; 29 import ch.poole.openinghoursparser.OpeningHoursParser; 30 import ch.poole.openinghoursparser.Rule; 31 import ch.poole.openinghoursparser.Util; 30 32 31 33 /** … … 93 95 */ 94 96 List<TestError> checkOpeningHourSyntax(final String key, final String value, OsmPrimitive p, Locale locale) { 95 if ( value == null || value.isEmpty()) {97 if (Utils.isEmpty(value)) { 96 98 return Collections.emptyList(); 97 99 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r17243 r18208 333 333 String templates = allroles.keySet().stream() 334 334 .map(r -> r.key) 335 .map(r -> r == null || r.isEmpty() ? tr("<empty>") : r)335 .map(r -> Utils.isEmpty(r) ? tr("<empty>") : r) 336 336 .distinct() 337 337 .collect(Collectors.joining("/")); -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r17766 r18208 880 880 881 881 private void checkSingleTagComplex(MultiMap<OsmPrimitive, String> withErrors, OsmPrimitive p, String key, String value) { 882 if (!checkValues || key == null || value == null || value.isEmpty())882 if (!checkValues || key == null || Utils.isEmpty(value)) 883 883 return; 884 884 if (additionalPresetsValueData != null && !isTagIgnored(key, value)) { … … 937 937 // try to fix common typos and check again if value is still unknown 938 938 final String harmonizedValue = harmonizeValue(value); 939 if ( harmonizedValue == null || harmonizedValue.isEmpty())939 if (Utils.isEmpty(harmonizedValue)) 940 940 return; 941 941 String fixedValue; … … 1219 1219 String key = prop.getKey(); 1220 1220 String value = prop.getValue(); 1221 if ( value == null || value.trim().isEmpty()) {1221 if (Utils.isBlank(value)) { 1222 1222 commands.add(new ChangePropertyCommand(p, key, null)); 1223 1223 } else if (value.startsWith(" ") || value.endsWith(" ") || value.contains(" ")) { -
trunk/src/org/openstreetmap/josm/data/vector/VectorNode.java
r17867 r18208 15 15 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 16 16 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 17 import org.openstreetmap.josm.tools.Utils; 17 18 18 19 /** … … 83 84 // when way is cloned 84 85 List<? extends IPrimitive> referrers = super.getReferrers(); 85 if ( referrers == null || referrers.isEmpty())86 if (Utils.isEmpty(referrers)) 86 87 return false; 87 88 if (referrers instanceof IPrimitive) -
trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java
r16953 r18208 44 44 import org.openstreetmap.josm.tools.ImageProvider.ImageSizes; 45 45 import org.openstreetmap.josm.tools.Logging; 46 import org.openstreetmap.josm.tools.Utils; 46 47 47 48 /** … … 151 152 private static boolean isPosInOneShapeIfAny(ImageryInfo info, LatLon pos) { 152 153 List<Shape> shapes = info.getBounds().getShapes(); 153 return shapes == null || shapes.isEmpty() || shapes.stream().anyMatch(s -> s.contains(pos));154 return Utils.isEmpty(shapes) || shapes.stream().anyMatch(s -> s.contains(pos)); 154 155 } 155 156 -
trunk/src/org/openstreetmap/josm/gui/PleaseWaitDialog.java
r15586 r18208 26 26 import org.openstreetmap.josm.tools.GBC; 27 27 import org.openstreetmap.josm.tools.ImageProvider; 28 import org.openstreetmap.josm.tools.Utils; 28 29 29 30 /** … … 106 107 @Override 107 108 public void setCustomText(String text) { 108 if ( text == null || text.trim().isEmpty()) {109 if (Utils.isBlank(text)) { 109 110 customText.setVisible(false); 110 111 adjustLayout(); … … 131 132 @Override 132 133 public void appendLogMessage(String message) { 133 if ( message == null || message.trim().isEmpty())134 if (Utils.isBlank(message)) 134 135 return; 135 136 if (!spLog.isVisible()) { -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java
r17353 r18208 51 51 import org.openstreetmap.josm.tools.StreamUtils; 52 52 import org.openstreetmap.josm.tools.UserCancelException; 53 import org.openstreetmap.josm.tools.Utils; 53 54 54 55 /** … … 637 638 String values = normalizedTags.getValues(key) 638 639 .stream() 639 .map(x -> (x == null || x.isEmpty()) ? tr("<i>missing</i>") : x)640 .map(x -> Utils.isEmpty(x) ? tr("<i>missing</i>") : x) 640 641 .collect(Collectors.joining(tr(", "))); 641 642 return tr("{0} ({1})", key, values); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java
r13597 r18208 195 195 if (tfValue.getText().trim().isEmpty()) 196 196 return null; 197 if ( primitives == null || primitives.isEmpty())197 if (Utils.isEmpty(primitives)) 198 198 return null; 199 199 return new ChangePropertyCommand(primitives, Utils.removeWhiteSpaces(tfKey.getText()), Utils.removeWhiteSpaces(tfValue.getText())); -
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r18067 r18208 664 664 final int sel = tblStyles.getSelectionModel().getLeadSelectionIndex(); 665 665 final StyleSource style = sel >= 0 && sel < model.getRowCount() ? model.getRow(sel) : null; 666 if (style == null || style.settings.isEmpty()) {666 if (style == null || Utils.isEmpty(style.settings)) { 667 667 setMenu.setEnabled(false); 668 668 } else { -
trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
r18009 r18208 59 59 import org.openstreetmap.josm.tools.OpenBrowser; 60 60 import org.openstreetmap.josm.tools.Shortcut; 61 import org.openstreetmap.josm.tools.Utils; 61 62 import org.openstreetmap.josm.tools.date.DateUtils; 62 63 … … 244 245 245 246 static boolean matchesNote(String filter, Note note) { 246 if ( filter == null || filter.isEmpty()) {247 if (Utils.isEmpty(filter)) { 247 248 return true; 248 249 } … … 287 288 String text = fstComment.getText(); 288 289 String userName = fstComment.getUser().getName(); 289 if ( userName == null || userName.isEmpty()) {290 if (Utils.isEmpty(userName)) { 290 291 userName = "<Anonymous>"; 291 292 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/OsmIdSelectionDialog.java
r18173 r18208 221 221 protected void tryToPasteFromClipboard(OsmIdTextField tfId, OsmPrimitiveTypesComboBox cbType) { 222 222 String buf = ClipboardUtils.getClipboardStringContent(); 223 if ( buf == null || buf.isEmpty()) return;223 if (Utils.isEmpty(buf)) return; 224 224 if (buf.length() > Config.getPref().getInt("downloadprimitive.max-autopaste-length", 2000)) return; 225 225 final List<SimplePrimitiveId> ids = SimplePrimitiveId.fuzzyParse(buf); -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r17768 r18208 308 308 */ 309 309 public void selectRelations(Collection<? extends IRelation<?>> relations) { 310 if ( relations == null || relations.isEmpty()) {310 if (Utils.isEmpty(relations)) { 311 311 model.setSelectedRelations(null); 312 312 } else { -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r17634 r18208 38 38 import javax.swing.event.PopupMenuEvent; 39 39 40 import org.openstreetmap.josm.actions.AbstractSelectAction; 40 41 import org.openstreetmap.josm.actions.AbstractShowHistoryAction; 41 import org.openstreetmap.josm.actions.AbstractSelectAction;42 42 import org.openstreetmap.josm.actions.AutoScaleAction; 43 43 import org.openstreetmap.josm.actions.AutoScaleAction.AutoScaleMode; … … 838 838 protected static class SelectionHistoryPopup extends JPopupMenu { 839 839 public static void launch(Component parent, Collection<Collection<? extends OsmPrimitive>> history) { 840 if ( history == null || history.isEmpty()) return;840 if (Utils.isEmpty(history)) return; 841 841 if (parent.isShowing()) { 842 842 JPopupMenu menu = new SelectionHistoryPopup(history); -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r17188 r18208 310 310 protected Map<User, Integer> computeStatistics(Collection<? extends OsmPrimitive> primitives) { 311 311 Map<User, Integer> ret = new HashMap<>(); 312 if ( primitives == null || primitives.isEmpty())312 if (Utils.isEmpty(primitives)) 313 313 return ret; 314 314 for (OsmPrimitive primitive: primitives) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorListManagementDialog.java
r16626 r18208 38 38 import org.openstreetmap.josm.tools.ImageProvider; 39 39 import org.openstreetmap.josm.tools.Logging; 40 import org.openstreetmap.josm.tools.Utils; 40 41 41 42 /** … … 224 225 List<TestError> errors = map.validatorDialog.tree.getErrors(); 225 226 ValidateAction validateAction = ValidatorDialog.validateAction; 226 if (!validateAction.isEnabled() || errors == null || errors.isEmpty()) return JOptionPane.NO_OPTION;227 if (!validateAction.isEnabled() || Utils.isEmpty(errors)) return JOptionPane.NO_OPTION; 227 228 final int answer = ConditionalOptionPaneUtil.showOptionDialog( 228 229 "rerun_validation_when_ignorelist_changed", -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/AbstractCellRenderer.java
r17717 r18208 14 14 15 15 import org.openstreetmap.josm.data.osm.User; 16 import org.openstreetmap.josm.tools.Utils; 16 17 import org.openstreetmap.josm.tools.date.DateUtils; 17 18 … … 56 57 57 58 protected void renderUser(User user) { 58 if (user == null || user.getName().trim().isEmpty()) {59 if (user == null || Utils.isBlank(user.getName())) { 59 60 setFont(UIManager.getFont("Table.font").deriveFont(Font.ITALIC)); 60 61 setText(tr("anonymous")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetListModel.java
r16601 r18208 23 23 import org.openstreetmap.josm.gui.util.GuiHelper; 24 24 import org.openstreetmap.josm.gui.util.TableHelper; 25 import org.openstreetmap.josm.tools.Utils; 25 26 26 27 /** … … 95 96 */ 96 97 public void initFromChangesetIds(Collection<Integer> ids) { 97 if ( ids == null || ids.isEmpty()) {98 if (Utils.isEmpty(ids)) { 98 99 setChangesets(null); 99 100 return; -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/UidInputFieldValidator.java
r11326 r18208 7 7 8 8 import org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator; 9 import org.openstreetmap.josm.tools.Utils; 9 10 10 11 /** … … 39 40 public void validate() { 40 41 String value = getComponent().getText(); 41 if ( value == null || value.trim().isEmpty()) {42 if (Utils.isBlank(value)) { 42 43 feedbackInvalid(""); 43 44 return; … … 62 63 public int getUid() { 63 64 String value = getComponent().getText(); 64 if ( value == null || value.trim().isEmpty()) return 0;65 if (Utils.isBlank(value)) return 0; 65 66 try { 66 67 int uid = Integer.parseInt(value.trim()); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/AbstractCopyAction.java
r16553 r18208 16 16 import org.openstreetmap.josm.data.osm.Tagged; 17 17 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 18 import org.openstreetmap.josm.tools.Utils; 18 19 19 20 /** … … 44 45 int[] rows = tagTable.getSelectedRows(); 45 46 Collection<? extends Tagged> sel = objectSupplier.get(); 46 if (rows.length == 0 || sel == null || sel.isEmpty()) return Stream.empty();47 if (rows.length == 0 || Utils.isEmpty(sel)) return Stream.empty(); 47 48 return Arrays.stream(rows) 48 49 .mapToObj(keySupplier) -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r18173 r18208 247 247 activeDataSet.beginUpdate(); 248 248 sel = OsmDataManager.getInstance().getInProgressSelection(); 249 if ( sel == null || sel.isEmpty())249 if (Utils.isEmpty(sel)) 250 250 return; 251 251 … … 281 281 changedKey = null; 282 282 sel = OsmDataManager.getInstance().getInProgressSelection(); 283 if ( sel == null || sel.isEmpty())283 if (Utils.isEmpty(sel)) 284 284 return; 285 285 … … 914 914 while (true) { 915 915 s = JOptionPane.showInputDialog(this, tr("Please enter the number of recently added tags to display"), s); 916 if ( s == null || s.isEmpty()) {916 if (Utils.isEmpty(s)) { 917 917 return; 918 918 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r17773 r18208 51 51 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel; 52 52 import org.openstreetmap.josm.tools.JosmRuntimeException; 53 import org.openstreetmap.josm.tools.Utils; 53 54 import org.openstreetmap.josm.tools.bugreport.BugReport; 54 55 … … 417 418 418 419 private void addMembersAtIndex(List<? extends OsmPrimitive> primitives, int index) { 419 if ( primitives == null || primitives.isEmpty())420 if (Utils.isEmpty(primitives)) 420 421 return; 421 422 int idx = index; … … 547 548 */ 548 549 public void setSelectedMembers(Collection<RelationMember> selectedMembers) { 549 if ( selectedMembers == null || selectedMembers.isEmpty()) {550 if (Utils.isEmpty(selectedMembers)) { 550 551 getSelectionModel().clearSelection(); 551 552 return; … … 571 572 */ 572 573 public void setSelectedMembersIdx(Collection<Integer> selectedIndices) { 573 if ( selectedIndices == null || selectedIndices.isEmpty()) {574 if (Utils.isEmpty(selectedIndices)) { 574 575 getSelectionModel().clearSelection(); 575 576 return; … … 652 653 */ 653 654 public static boolean hasMembersReferringTo(Collection<RelationMember> members, Collection<OsmPrimitive> primitives) { 654 if ( primitives == null || primitives.isEmpty())655 if (Utils.isEmpty(primitives)) 655 656 return false; 656 657 Set<OsmPrimitive> referrers = members.stream().map(RelationMember::getMember).collect(Collectors.toSet()); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/AddFromSelectionAction.java
r16651 r18208 12 12 import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor; 13 13 import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor.AddAbortException; 14 import org.openstreetmap.josm.tools.Utils; 14 15 15 16 /** … … 30 31 31 32 protected List<OsmPrimitive> filterConfirmedPrimitives(List<OsmPrimitive> primitives) throws AddAbortException { 32 if ( primitives == null || primitives.isEmpty())33 if (Utils.isEmpty(primitives)) 33 34 return primitives; 34 35 List<OsmPrimitive> ret = new ArrayList<>(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SetRoleAction.java
r17555 r18208 45 45 46 46 protected boolean isEmptyRole() { 47 return tfRole.getText() == null || tfRole.getText().trim().isEmpty();47 return Utils.isBlank(tfRole.getText()); 48 48 } 49 49 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationNodeMap.java
r17867 r18208 15 15 import org.openstreetmap.josm.data.osm.IRelationMember; 16 16 import org.openstreetmap.josm.data.osm.IWay; 17 import org.openstreetmap.josm.tools.Utils; 17 18 18 19 /** … … 260 261 private static Integer findAdjacentWay(NodesWays nw, INode n) { 261 262 Set<Integer> adj = nw.nodes.get(n); 262 if ( adj == null || adj.isEmpty()) return null;263 if (Utils.isEmpty(adj)) return null; 263 264 return adj.iterator().next(); 264 265 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanel.java
r17437 r18208 43 43 import org.openstreetmap.josm.tools.Destroyable; 44 44 import org.openstreetmap.josm.tools.ListenerList; 45 import org.openstreetmap.josm.tools.Utils; 45 46 46 47 /** … … 260 261 if (groupNode != null) { 261 262 searchMsg = description; 262 } else if ( description == null || description.isEmpty()) {263 } else if (Utils.isEmpty(description)) { 263 264 searchMsg = message; 264 265 } else { -
trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java
r14153 r18208 29 29 import org.openstreetmap.josm.gui.widgets.JosmTextArea; 30 30 import org.openstreetmap.josm.tools.ImageProvider; 31 import org.openstreetmap.josm.tools.Utils; 31 32 32 33 /** … … 223 224 public void actionPerformed(ActionEvent e) { 224 225 List<Bookmark> sels = bookmarks.getSelectedValuesList(); 225 if ( sels == null || sels.isEmpty())226 if (Utils.isEmpty(sels)) 226 227 return; 227 228 for (Object sel: sels) { -
trunk/src/org/openstreetmap/josm/gui/help/HelpUtil.java
r14119 r18208 16 16 import org.openstreetmap.josm.tools.LanguageInfo; 17 17 import org.openstreetmap.josm.tools.LanguageInfo.LocaleType; 18 import org.openstreetmap.josm.tools.Utils; 18 19 19 20 /** … … 149 150 public static String buildAbsoluteHelpTopic(String topic, LocaleType type) { 150 151 String prefix = getHelpTopicPrefix(type); 151 if (prefix == null || topic == null || topic.trim().isEmpty() || "/".equals(topic.trim()))152 if (prefix == null || Utils.isBlank(topic) || "/".equals(topic.trim())) 152 153 return prefix; 153 154 prefix += '/' + topic; -
trunk/src/org/openstreetmap/josm/gui/io/CustomConfigurator.java
r17333 r18208 149 149 */ 150 150 public static void messageBox(String type, String text) { 151 char c = ( type == null || type.isEmpty() ? "plain" : type).charAt(0);151 char c = (Utils.isEmpty(type) ? "plain" : type).charAt(0); 152 152 MainFrame parent = MainApplication.getMainFrame(); 153 153 switch (c) { -
trunk/src/org/openstreetmap/josm/gui/io/LayerNameAndFilePathTableCell.java
r13115 r18208 30 30 import org.openstreetmap.josm.gui.widgets.JosmTextField; 31 31 import org.openstreetmap.josm.tools.GBC; 32 import org.openstreetmap.josm.tools.Utils; 32 33 33 34 /** … … 229 230 @Override 230 231 public boolean stopCellEditing() { 231 if ( tfFilename.getText() == null || tfFilename.getText().trim().isEmpty()) {232 if (Utils.isBlank(tfFilename.getText())) { 232 233 value = null; 233 234 } else { -
trunk/src/org/openstreetmap/josm/gui/io/OpenChangesetComboBoxModel.java
r16438 r18208 12 12 import org.openstreetmap.josm.data.osm.ChangesetCacheListener; 13 13 import org.openstreetmap.josm.gui.util.GuiHelper; 14 import org.openstreetmap.josm.tools.Utils; 14 15 15 16 /** … … 54 55 */ 55 56 public void selectFirstChangeset() { 56 if ( changesets == null || changesets.isEmpty()) {57 if (Utils.isEmpty(changesets)) { 57 58 setSelectedItem(null); 58 59 } else { -
trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java
r17712 r18208 57 57 import org.openstreetmap.josm.tools.ImageProvider; 58 58 import org.openstreetmap.josm.tools.Logging; 59 import org.openstreetmap.josm.tools.Utils; 59 60 import org.openstreetmap.josm.tools.date.DateUtils; 60 61 … … 314 315 sb.append("<hr/>"); 315 316 String userName = XmlWriter.encode(comment.getUser().getName()); 316 if ( userName == null || userName.trim().isEmpty()) {317 if (Utils.isBlank(userName)) { 317 318 userName = "<Anonymous>"; 318 319 } -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r18078 r18208 135 135 import org.openstreetmap.josm.tools.Logging; 136 136 import org.openstreetmap.josm.tools.UncheckedParseException; 137 import org.openstreetmap.josm.tools.Utils; 137 138 import org.openstreetmap.josm.tools.date.DateUtils; 138 139 … … 653 654 public void cleanupAfterUpload(final Collection<? extends IPrimitive> processed) { 654 655 // return immediately if an upload attempt failed 655 if ( processed == null || processed.isEmpty())656 if (Utils.isEmpty(processed)) 656 657 return; 657 658 -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java
r17845 r18208 54 54 import org.openstreetmap.josm.tools.ImageProvider; 55 55 import org.openstreetmap.josm.tools.OpenBrowser; 56 import org.openstreetmap.josm.tools.Utils; 56 57 import org.openstreetmap.josm.tools.date.Interval; 57 58 … … 181 182 int row = t.rowAtPoint(e.getPoint()); 182 183 String url = (String) t.getValueAt(row, col); 183 if ( url == null || url.isEmpty()) {184 if (Utils.isEmpty(url)) { 184 185 return; 185 186 } -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ConvertFromGpxLayerAction.java
r18078 r18208 37 37 import org.openstreetmap.josm.spi.preferences.Config; 38 38 import org.openstreetmap.josm.tools.GBC; 39 import org.openstreetmap.josm.tools.Utils; 39 40 40 41 /** … … 159 160 String extpre = "extension:"; 160 161 String pre = ext.getPrefix(); 161 if ( pre == null || pre.isEmpty()) {162 if (Utils.isEmpty(pre)) { 162 163 pre = "other"; 163 164 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSRuleIndex.java
r17593 r18208 157 157 } 158 158 final List<Condition> conditions = selRightmost.getConditions(); 159 if ( conditions == null || conditions.isEmpty()) {159 if (Utils.isEmpty(conditions)) { 160 160 remaining.set(ruleIndex); 161 161 continue; -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r17808 r18208 458 458 459 459 void execGeometryTests() { 460 if ( toCheck == null || toCheck.isEmpty())460 if (Utils.isEmpty(toCheck)) 461 461 return; 462 462 for (IPrimitive p : Geometry.filterInsideAnyPolygon(toCheck, e.osm)) { -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r17713 r18208 759 759 760 760 private static void prepareFileChooser(String url, AbstractFileChooser fc) { 761 if ( url == null || url.trim().isEmpty()) return;761 if (Utils.isBlank(url)) return; 762 762 URL sourceUrl = null; 763 763 try { -
trunk/src/org/openstreetmap/josm/gui/preferences/TabPreferenceSetting.java
r17231 r18208 7 7 8 8 import org.openstreetmap.josm.tools.ImageProvider; 9 import org.openstreetmap.josm.tools.Utils; 9 10 10 11 /** … … 28 29 default ImageIcon getIcon(ImageProvider.ImageSizes size) { 29 30 String iconName = getIconName(); 30 return iconName == null || iconName.isEmpty()31 return Utils.isEmpty(iconName) 31 32 ? null 32 33 : iconName.contains("/") -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r17667 r18208 85 85 import org.openstreetmap.josm.tools.Logging; 86 86 import org.openstreetmap.josm.tools.Shortcut; 87 import org.openstreetmap.josm.tools.Utils; 87 88 88 89 /** … … 1088 1089 1089 1090 public static Collection<String> getToolString() { 1090 1091 1091 Collection<String> toolStr = Config.getPref().getList("toolbar", Arrays.asList(deftoolbar)); 1092 if ( toolStr == null || toolStr.isEmpty()) {1092 if (Utils.isEmpty(toolStr)) { 1093 1093 toolStr = Arrays.asList(deftoolbar); 1094 1094 } -
trunk/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java
r17997 r18208 40 40 import org.openstreetmap.josm.tools.GBC; 41 41 import org.openstreetmap.josm.tools.Logging; 42 import org.openstreetmap.josm.tools.Utils; 42 43 import org.openstreetmap.josm.tools.template_engine.ParseError; 43 44 import org.openstreetmap.josm.tools.template_engine.TemplateParser; … … 143 144 super(new GridBagLayout()); 144 145 this.layers = layers; 145 if ( layers == null || layers.isEmpty()) {146 if (Utils.isEmpty(layers)) { 146 147 throw new InvalidArgumentException("At least one layer required"); 147 148 } … … 262 263 */ 263 264 public static void putLayerPrefLocal(GpxData data, String key, String value) { 264 if ( value == null || value.trim().isEmpty() ||265 if (Utils.isBlank(value) || 265 266 (getLayerPref(null, key).equals(value) && DEFAULT_PREFS.get(key) != null && DEFAULT_PREFS.get(key).toString().equals(value))) { 266 267 data.getLayerPrefs().remove(key); -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryProvidersPanel.java
r17862 r18208 73 73 import org.openstreetmap.josm.tools.LanguageInfo; 74 74 import org.openstreetmap.josm.tools.Logging; 75 import org.openstreetmap.josm.tools.Utils; 75 76 76 77 /** … … 479 480 activeModel.addRow(p.getImageryInfo()); 480 481 } catch (IllegalArgumentException ex) { 481 if ( ex.getMessage() == null || ex.getMessage().isEmpty())482 if (Utils.isEmpty(ex.getMessage())) 482 483 throw ex; 483 484 else { -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java
r17793 r18208 22 22 import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel; 23 23 import org.openstreetmap.josm.plugins.PluginInformation; 24 import org.openstreetmap.josm.tools.Utils; 24 25 25 26 /** … … 63 64 protected static String formatPluginRemoteVersion(PluginInformation pi) { 64 65 StringBuilder sb = new StringBuilder(); 65 if ( pi.version == null || pi.version.trim().isEmpty()) {66 if (Utils.isBlank(pi.version)) { 66 67 sb.append(tr("unknown")); 67 68 } else { … … 77 78 if (pi == null) 78 79 return tr("unknown"); 79 if ( pi.localversion == null || pi.localversion.trim().isEmpty())80 if (Utils.isBlank(pi.localversion)) 80 81 return tr("unknown"); 81 82 return pi.localversion; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r18099 r18208 414 414 return roles.roles.stream() 415 415 .filter(i -> i.memberExpression != null && i.memberExpression.match(osm)) 416 .filter(i -> i.types == null || i.types.isEmpty() || i.types.contains(TaggingPresetType.forPrimitive(osm)))416 .filter(i -> Utils.isEmpty(i.types) || i.types.contains(TaggingPresetType.forPrimitive(osm))) 417 417 .findFirst() 418 418 .map(i -> i.key) -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java
r17787 r18208 27 27 import org.openstreetmap.josm.tools.ImageProvider; 28 28 import org.openstreetmap.josm.tools.Logging; 29 import org.openstreetmap.josm.tools.Utils; 29 30 import org.xml.sax.SAXException; 30 31 … … 83 84 84 85 protected static Set<TaggingPresetType> getType(String types) throws SAXException { 85 if ( types == null || types.isEmpty()) {86 if (Utils.isEmpty(types)) { 86 87 throw new SAXException(tr("Unknown type: {0}", types)); 87 88 } … … 118 119 119 120 protected static Integer parseInteger(String str) { 120 if ( str == null || str.isEmpty())121 if (Utils.isEmpty(str)) 121 122 return null; 122 123 try { -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItemGuiSupport.java
r18080 r18208 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.tagging.presets; 3 4 import java.util.Arrays; 5 import java.util.Collection; 6 import java.util.Collections; 7 import java.util.function.Supplier; 3 8 4 9 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 7 12 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 8 13 import org.openstreetmap.josm.tools.ListenerList; 14 import org.openstreetmap.josm.tools.Utils; 9 15 import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider; 10 11 import java.util.Arrays;12 import java.util.Collection;13 import java.util.Collections;14 import java.util.function.Supplier;15 16 16 17 /** … … 92 93 /** 93 94 * Get tags with values as currently shown in the dialog. 94 * If exactly one primitive is selected, get all tags of it, then 95 * If exactly one primitive is selected, get all tags of it, then 95 96 * overwrite with the current values shown in the dialog. 96 97 * Else get only the tags shown in the dialog. … … 116 117 public Object getTemplateValue(String key, boolean special) { 117 118 String value = getTagged().get(key); 118 return (value == null || value.isEmpty()) ? null : value;119 return Utils.isEmpty(value) ? null : value; 119 120 } 120 121 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/PresetListEntry.java
r16690 r18208 67 67 String shortDescription = getShortDescription(true); 68 68 69 if (displayValue.isEmpty() && (shortDescription == null || shortDescription.isEmpty()))69 if (displayValue.isEmpty() && Utils.isEmpty(shortDescription)) 70 70 return " "; 71 71 72 72 final StringBuilder res = new StringBuilder("<b>").append(displayValue).append("</b>"); 73 if ( shortDescription != null) {73 if (!Utils.isEmpty(shortDescription)) { 74 74 // wrap in table to restrict the text width 75 75 res.append("<div style=\"width:300px; padding:0 0 5px 5px\">") -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java
r18080 r18208 234 234 @Override 235 235 public Collection<String> getValues() { 236 if ( default_ == null || default_.isEmpty())236 if (Utils.isEmpty(default_)) 237 237 return Collections.emptyList(); 238 238 return Collections.singleton(default_); … … 254 254 255 255 private void setupListeners(AutoCompletingTextField textField, TaggingPresetItemGuiSupport support) { 256 // value_templates don't work well with multiple selected items because, 257 // as the command queue is currently implemented, we can only save 258 // the same value to all selected primitives, which is probably not 256 // value_templates don't work well with multiple selected items because, 257 // as the command queue is currently implemented, we can only save 258 // the same value to all selected primitives, which is probably not 259 259 // what you want. 260 260 if (valueTemplate == null || support.getSelected().size() > 1) { // only fire on normal fields -
trunk/src/org/openstreetmap/josm/gui/widgets/FileChooserManager.java
r18113 r18208 19 19 import org.openstreetmap.josm.spi.preferences.Config; 20 20 import org.openstreetmap.josm.tools.PlatformManager; 21 import org.openstreetmap.josm.tools.Utils; 21 22 22 23 /** … … 98 99 public FileChooserManager(boolean open, String lastDirProperty, String defaultDir) { 99 100 this.open = open; 100 this.lastDirProperty = lastDirProperty == null || lastDirProperty.isEmpty() ? "lastDirectory" : lastDirProperty;101 this.lastDirProperty = Utils.isEmpty(lastDirProperty) ? "lastDirectory" : lastDirProperty; 101 102 this.curDir = Config.getPref().get(this.lastDirProperty).isEmpty() ? 102 defaultDir == null || defaultDir.isEmpty() ? "." : defaultDir103 Utils.isEmpty(defaultDir) ? "." : defaultDir 103 104 : Config.getPref().get(this.lastDirProperty); 104 105 } -
trunk/src/org/openstreetmap/josm/gui/widgets/FilterField.java
r18114 r18208 93 93 final TableRowSorter<? extends TableModel> sorter = 94 94 (TableRowSorter<? extends TableModel>) table.getRowSorter(); 95 if ( expr == null || expr.isEmpty()) {95 if (Utils.isEmpty(expr)) { 96 96 sorter.setRowFilter(null); 97 97 } else { -
trunk/src/org/openstreetmap/josm/gui/widgets/OsmIdTextField.java
r13969 r18208 14 14 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 15 15 import org.openstreetmap.josm.tools.Logging; 16 import org.openstreetmap.josm.tools.Utils; 16 17 17 18 /** … … 94 95 String value = getComponent().getText(); 95 96 char c; 96 if ( value == null || value.trim().isEmpty()) {97 if (Utils.isBlank(value)) { 97 98 return false; 98 99 } -
trunk/src/org/openstreetmap/josm/io/AbstractReader.java
r17822 r18208 427 427 428 428 protected final void parseTimestamp(PrimitiveData current, String time) { 429 if ( time == null || time.isEmpty()) {429 if (Utils.isEmpty(time)) { 430 430 return; 431 431 } -
trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java
r17843 r18208 432 432 public static class ChangesetQueryUrlParser { 433 433 protected int parseUid(String value) throws ChangesetQueryUrlException { 434 if ( value == null || value.trim().isEmpty())434 if (Utils.isBlank(value)) 435 435 throw new ChangesetQueryUrlException( 436 436 tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "uid", value)); … … 449 449 450 450 protected boolean parseBoolean(String value, String parameter) throws ChangesetQueryUrlException { 451 if ( value == null || value.trim().isEmpty())451 if (Utils.isBlank(value)) 452 452 throw new ChangesetQueryUrlException( 453 453 tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value)); … … 464 464 465 465 protected Instant parseDate(String value, String parameter) throws ChangesetQueryUrlException { 466 if ( value == null || value.trim().isEmpty())466 if (Utils.isBlank(value)) 467 467 throw new ChangesetQueryUrlException( 468 468 tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value)); … … 488 488 489 489 protected Collection<Long> parseLongs(String value) { 490 if ( value == null || value.isEmpty()) {490 if (Utils.isEmpty(value)) { 491 491 return Collections.<Long>emptySet(); 492 492 } else { -
trunk/src/org/openstreetmap/josm/io/OsmApiException.java
r15085 r18208 215 215 String header = Utils.strip(errorHeader); 216 216 String body = Utils.strip(errorBody); 217 if ( (header == null || header.isEmpty()) && (body == null || body.isEmpty())) {217 if (Utils.isEmpty(header) && Utils.isEmpty(body)) { 218 218 sb.append(tr("The server replied an error with code {0}.", responseCode)); 219 219 } else { -
trunk/src/org/openstreetmap/josm/io/OsmServerChangesetReader.java
r16628 r18208 20 20 import org.openstreetmap.josm.tools.CheckParameterUtil; 21 21 import org.openstreetmap.josm.tools.Logging; 22 import org.openstreetmap.josm.tools.Utils; 22 23 import org.openstreetmap.josm.tools.XmlParsingException; 23 24 … … 124 125 monitor.indeterminateSubTask(tr("Downloading changeset {0} ...", id)); 125 126 List<Changeset> changesets = OsmChangesetParser.parse(in, monitor.createSubTaskMonitor(1, true)); 126 if ( changesets == null || changesets.isEmpty())127 if (Utils.isEmpty(changesets)) 127 128 return null; 128 129 result = changesets.get(0); … … 173 174 monitor.indeterminateSubTask(tr("({0}/{1}) Downloading changeset {2}...", i, ids.size(), id)); 174 175 List<Changeset> changesets = OsmChangesetParser.parse(in, monitor.createSubTaskMonitor(1, true)); 175 if ( changesets == null || changesets.isEmpty()) {176 if (Utils.isEmpty(changesets)) { 176 177 continue; 177 178 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java
r18134 r18208 279 279 for (String key : mandatory) { 280 280 String value = args.get(key); 281 if ( value == null || value.isEmpty()) {281 if (Utils.isEmpty(value)) { 282 282 error = true; 283 283 Logging.warn('\'' + myCommand + "' remote control request must have '" + key + "' parameter"); -
trunk/src/org/openstreetmap/josm/io/session/GpxTracksSessionImporter.java
r16866 r18208 20 20 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 21 21 import org.openstreetmap.josm.io.IllegalDataException; 22 import org.openstreetmap.josm.tools.Utils; 22 23 import org.w3c.dom.Element; 23 24 … … 40 41 XPathExpression fileExp = xpath.compile("file/text()"); 41 42 String fileStr = (String) fileExp.evaluate(elem, XPathConstants.STRING); 42 if ( fileStr == null || fileStr.isEmpty()) {43 if (Utils.isEmpty(fileStr)) { 43 44 throw new IllegalDataException(tr("File name expected for layer no. {0}", support.getLayerIndex())); 44 45 } -
trunk/src/org/openstreetmap/josm/io/session/MarkerSessionImporter.java
r16866 r18208 21 21 import org.openstreetmap.josm.io.IllegalDataException; 22 22 import org.openstreetmap.josm.io.session.SessionReader.ImportSupport; 23 import org.openstreetmap.josm.tools.Utils; 23 24 import org.w3c.dom.Element; 24 25 … … 40 41 XPathExpression fileExp = xpath.compile("file/text()"); 41 42 String fileStr = (String) fileExp.evaluate(elem, XPathConstants.STRING); 42 if ( fileStr == null || fileStr.isEmpty()) {43 if (Utils.isEmpty(fileStr)) { 43 44 throw new IllegalDataException(tr("File name expected for layer no. {0}", support.getLayerIndex())); 44 45 } -
trunk/src/org/openstreetmap/josm/io/session/NoteSessionImporter.java
r12671 r18208 19 19 import org.openstreetmap.josm.io.IllegalDataException; 20 20 import org.openstreetmap.josm.io.session.SessionReader.ImportSupport; 21 import org.openstreetmap.josm.tools.Utils; 21 22 import org.w3c.dom.Element; 22 23 import org.xml.sax.SAXException; … … 39 40 XPathExpression fileExp = xpath.compile("file/text()"); 40 41 String fileStr = (String) fileExp.evaluate(elem, XPathConstants.STRING); 41 if ( fileStr == null || fileStr.isEmpty()) {42 if (Utils.isEmpty(fileStr)) { 42 43 throw new IllegalDataException(tr("File name expected for layer no. {0}", support.getLayerIndex())); 43 44 } -
trunk/src/org/openstreetmap/josm/io/session/OsmDataSessionImporter.java
r15377 r18208 19 19 import org.openstreetmap.josm.io.IllegalDataException; 20 20 import org.openstreetmap.josm.io.session.SessionReader.ImportSupport; 21 import org.openstreetmap.josm.tools.Utils; 21 22 import org.w3c.dom.Element; 22 23 … … 61 62 XPathExpression fileExp = xpath.compile("file/text()"); 62 63 String fileStr = (String) fileExp.evaluate(elem, XPathConstants.STRING); 63 if ( fileStr == null || fileStr.isEmpty()) {64 if (Utils.isEmpty(fileStr)) { 64 65 throw new IllegalDataException(tr("File name expected for layer no. {0}", support.getLayerIndex())); 65 66 } -
trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
r16643 r18208 204 204 private void handleIOException(final ProgressMonitor monitor, IOException e, String details) { 205 205 final String msg = e.getMessage(); 206 if ( details == null || details.isEmpty()) {206 if (Utils.isEmpty(details)) { 207 207 Logging.error(e.getClass().getSimpleName()+": " + msg); 208 208 } else { -
trunk/src/org/openstreetmap/josm/spi/preferences/AbstractPreferences.java
r16436 r18208 10 10 11 11 import org.openstreetmap.josm.tools.Logging; 12 13 import com.jayway.jsonpath.internal.Utils; 12 14 13 15 /** … … 24 26 @Override 25 27 public boolean put(final String key, String value) { 26 return putSetting(key, value == null || value.isEmpty() ? null : new StringSetting(value));28 return putSetting(key, Utils.isEmpty(value) ? null : new StringSetting(value)); 27 29 } 28 30 -
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r17840 r18208 461 461 public static String explainGeneric(Exception e) { 462 462 String msg = e.getMessage(); 463 if ( msg == null || msg.trim().isEmpty()) {463 if (Utils.isBlank(msg)) { 464 464 msg = e.toString(); 465 465 } -
trunk/src/org/openstreetmap/josm/tools/Mediawiki.java
r18046 r18208 62 62 for (String page : distinctPages) { 63 63 String normalized = xPath.evaluate("/api/query/normalized/n[@from='" + page + "']/@to", document); 64 if ( normalized == null || normalized.isEmpty()) {64 if (Utils.isEmpty(normalized)) { 65 65 normalized = page; 66 66 } -
trunk/src/org/openstreetmap/josm/tools/OsmPrimitiveImageProvider.java
r16848 r18208 58 58 final Optional<ImageResource> icon = TaggingPresets.getMatchingPresets(primitive).stream() 59 59 .sorted(Comparator.comparing(p -> (p.iconName != null && p.iconName.contains("multipolygon")) 60 || p.types == null || p.types.isEmpty() ? Integer.MAX_VALUE : p.types.size()))60 || Utils.isEmpty(p.types) ? Integer.MAX_VALUE : p.types.size())) 61 61 .map(TaggingPreset::getImageResource) 62 62 .filter(Objects::nonNull) -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r17688 r18208 390 390 public File getDefaultCacheDirectory() { 391 391 String p = getSystemEnv("LOCALAPPDATA"); 392 if ( p == null || p.isEmpty()) {392 if (Utils.isEmpty(p)) { 393 393 // Fallback for Windows OS earlier than Windows Vista, where the variable is not defined 394 394 p = getSystemEnv("APPDATA"); -
trunk/src/org/openstreetmap/josm/tools/Tag2Link.java
r17909 r18208 35 35 /** 36 36 * Extracts web links from OSM tags. 37 * 37 * 38 38 * The following rules are used: 39 39 * <ul> … … 144 144 public static void getLinksForTag(String key, String value, LinkConsumer linkConsumer) { 145 145 146 if ( value == null || value.isEmpty()) {146 if (Utils.isEmpty(value)) { 147 147 return; 148 148 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r18207 r18208 709 709 710 710 /** 711 * Determines if a multimap is null or empty. 712 * @param map map 713 * @return {@code true} if map is null or empty 714 * @since 18208 715 */ 716 public static boolean isEmpty(MultiMap<?, ?> map) { 717 return map == null || map.isEmpty(); 718 } 719 720 /** 711 721 * Determines if a string is null or empty. 712 722 * @param string string … … 716 726 public static boolean isEmpty(String string) { 717 727 return string == null || string.isEmpty(); 728 } 729 730 /** 731 * Determines if a string is null or blank. 732 * @param string string 733 * @return {@code true} if string is null or blank 734 * @since 18208 735 */ 736 public static boolean isBlank(String string) { 737 return string == null || strip(string).isEmpty(); 718 738 } 719 739 -
trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java
r17885 r18208 37 37 import org.openstreetmap.josm.tools.Logging; 38 38 import org.openstreetmap.josm.tools.PlatformManager; 39 import org.openstreetmap.josm.tools.Utils; 39 40 import org.openstreetmap.josm.tools.date.DateUtils; 40 41 … … 122 123 pref.init(false); 123 124 String url = OsmApi.getOsmApi().getServerUrl(); 124 if ( url == null || url.isEmpty() || isProductionApiUrl(url)) {125 if (Utils.isEmpty(url) || isProductionApiUrl(url)) { 125 126 Config.getPref().put("osm-server.url", "https://api06.dev.openstreetmap.org/api"); 126 127 } -
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r18109 r18208 86 86 public static String getTestDataRoot() { 87 87 String testDataRoot = System.getProperty("josm.test.data"); 88 if ( testDataRoot == null || testDataRoot.isEmpty()) {88 if (Utils.isEmpty(testDataRoot)) { 89 89 testDataRoot = "test/data"; 90 90 System.out.println("System property josm.test.data is not set, using '" + testDataRoot + "'");
Note:
See TracChangeset
for help on using the changeset viewer.