- Timestamp:
- 2024-05-14T21:30:11+02:00 (7 months ago)
- Location:
- trunk
- Files:
-
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGeoJsonTask.java
r15784 r19080 6 6 import java.util.Optional; 7 7 import java.util.concurrent.Future; 8 import java.util.function.Predicate; 8 9 9 10 import org.openstreetmap.josm.data.Bounds; … … 57 58 protected String generateLayerName() { 58 59 return Optional.of(url.substring(url.lastIndexOf('/')+1)) 59 .filter( it -> !Utils.isStripEmpty(it))60 .filter(Predicate.not(Utils::isStripEmpty)) 60 61 .orElse(super.generateLayerName()); 61 62 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r18801 r19080 2 2 package org.openstreetmap.josm.actions.downloadtasks; 3 3 4 import static java.util.function.Predicate.not; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 299 300 protected String generateLayerName() { 300 301 return Optional.ofNullable(settings.getLayerName()) 301 .filter( layerName -> !Utils.isStripEmpty(layerName))302 .filter(not(Utils::isStripEmpty)) 302 303 .orElse(OsmDataLayer.createNewName()); 303 304 } … … 360 361 // the user explicitly wants a new layer, we don't have any layer at all 361 362 // or it is not clear which layer to merge to 362 final OsmDataLayer layer = createNewLayer(Optional.ofNullable(newLayerName).filter( it -> !Utils.isStripEmpty(it)));363 final OsmDataLayer layer = createNewLayer(Optional.ofNullable(newLayerName).filter(not(Utils::isStripEmpty))); 363 364 MainApplication.getLayerManager().addLayer(layer, zoomAfterDownload); 364 365 return layer; -
trunk/src/org/openstreetmap/josm/data/UserIdentityManager.java
r18655 r19080 215 215 String credentialsUserName = CredentialsManager.getInstance().getUsername(); 216 216 if (isAnonymous()) { 217 if (!Utils.is Blank(credentialsUserName)) {217 if (!Utils.isStripEmpty(credentialsUserName)) { 218 218 setPartiallyIdentified(credentialsUserName); 219 219 } … … 280 280 newUserName = ((StringSetting) evt.getNewValue()).getValue(); 281 281 } 282 if (Utils.is Blank(newUserName)) {282 if (Utils.isStripEmpty(newUserName)) { 283 283 setAnonymous(); 284 284 } else if (!newUserName.equals(userName)) { … … 291 291 newUrl = ((StringSetting) evt.getNewValue()).getValue(); 292 292 } 293 if (Utils.is Blank(newUrl)) {293 if (Utils.isStripEmpty(newUrl)) { 294 294 setAnonymous(); 295 295 } else if (isFullyIdentified()) { -
trunk/src/org/openstreetmap/josm/data/gpx/GpxExtension.java
r18208 r19080 175 175 if (parent instanceof GpxExtension) { 176 176 GpxExtension gpx = ((GpxExtension) parent); 177 if (Utils.is Blank(gpx.getValue())177 if (Utils.isStripEmpty(gpx.getValue()) 178 178 && Utils.isEmpty(gpx.getAttributes()) 179 179 && Utils.isEmpty(gpx.getExtensions())) { … … 191 191 if (parent != null && parent instanceof GpxExtension) { 192 192 GpxExtension gpx = (GpxExtension) parent; 193 if (Utils.is Blank(gpx.getValue())193 if (Utils.isStripEmpty(gpx.getValue()) 194 194 && gpx.getAttributes().isEmpty() 195 195 && !gpx.getExtensions().isVisible()) { -
trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/style/Layers.java
r18871 r19080 273 273 if (layoutObject.containsKey("icon-image")) { 274 274 sb.append(/* NO-ICON */"icon-image:concat("); 275 if (!Utils.is Blank(this.styleId)) {275 if (!Utils.isStripEmpty(this.styleId)) { 276 276 sb.append('"').append(this.styleId).append('/').append("\","); 277 277 } -
trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/style/MapboxVectorStyle.java
r18723 r19080 143 143 this.sources.put(source, new ElemStyles(Collections.singleton(style))); 144 144 } 145 if (!Utils.is Blank(this.spriteUrl)) {145 if (!Utils.isStripEmpty(this.spriteUrl)) { 146 146 MainApplication.worker.execute(this::fetchSprites); 147 147 } -
trunk/src/org/openstreetmap/josm/data/oauth/OAuth20Token.java
r18723 r19080 82 82 @Override 83 83 public void sign(HttpClient client) throws OAuthException { 84 if (!Utils.is Blank(this.oauthParameters.getApiUrl())84 if (!Utils.isStripEmpty(this.oauthParameters.getApiUrl()) 85 85 && !this.oauthParameters.getApiUrl().contains(client.getURL().getHost())) { 86 86 String host = URI.create(this.oauthParameters.getAccessTokenUrl()).getHost(); -
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r19078 r19080 719 719 List<Map.Entry<String, String>> tagsToAdd = new ArrayList<>(tags.size()); 720 720 for (Map.Entry<String, String> tag : tags.entrySet()) { 721 if (!Utils.is Blank(tag.getKey())) {721 if (!Utils.isStripEmpty(tag.getKey())) { 722 722 int keyIndex = indexOfKey(newKeys, tag.getKey()); 723 723 // Realistically, we will not hit the newKeys == null branch. If it is null, keyIndex is always < 0 -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r18984 r19080 1403 1403 String key = prop.getKey(); 1404 1404 String value = prop.getValue(); 1405 if (Utils.is Blank(value)) {1405 if (Utils.isStripEmpty(value)) { 1406 1406 commands.add(new ChangePropertyCommand(p, key, null)); 1407 1407 } else if (value.startsWith(" ") || value.endsWith(" ") || value.contains(" ")) { -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r19060 r19080 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui; 3 4 import static java.util.function.Predicate.not; 3 5 4 6 import java.awt.AlphaComposite; … … 827 829 public String getLayerInformationForSourceTag() { 828 830 return layerManager.getVisibleLayersInZOrder().stream() 829 .filter(layer -> !Utils.isBlank(layer.getChangesetSourceTag())) 830 .map(layer -> layer.getChangesetSourceTag().trim()) 831 .map(Layer::getChangesetSourceTag) 832 .filter(not(Utils::isStripEmpty)) 833 .map(String::trim) 831 834 .distinct() 832 835 .collect(Collectors.joining("; ")); -
trunk/src/org/openstreetmap/josm/gui/PleaseWaitDialog.java
r18208 r19080 107 107 @Override 108 108 public void setCustomText(String text) { 109 if (Utils.is Blank(text)) {109 if (Utils.isStripEmpty(text)) { 110 110 customText.setVisible(false); 111 111 adjustLayout(); … … 132 132 @Override 133 133 public void appendLogMessage(String message) { 134 if (Utils.is Blank(message))134 if (Utils.isStripEmpty(message)) 135 135 return; 136 136 if (!spLog.isVisible()) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/AbstractCellRenderer.java
r18208 r19080 57 57 58 58 protected void renderUser(User user) { 59 if (user == null || Utils.is Blank(user.getName())) {59 if (user == null || Utils.isStripEmpty(user.getName())) { 60 60 setFont(UIManager.getFont("Table.font").deriveFont(Font.ITALIC)); 61 61 setText(tr("anonymous")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/UidInputFieldValidator.java
r18801 r19080 40 40 public void validate() { 41 41 String value = getComponent().getText(); 42 if (Utils.is Blank(value)) {42 if (Utils.isStripEmpty(value)) { 43 43 feedbackInvalid(""); 44 44 return; … … 63 63 public int getUid() { 64 64 String value = getComponent().getText(); 65 if (Utils.is Blank(value)) return 0;65 if (Utils.isStripEmpty(value)) return 0; 66 66 try { 67 67 int uid = Integer.parseInt(value.trim()); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SetRoleAction.java
r19050 r19080 45 45 46 46 protected boolean isEmptyRole() { 47 return Utils.is Blank(tfRole.getText());47 return Utils.isStripEmpty(tfRole.getText()); 48 48 } 49 49 -
trunk/src/org/openstreetmap/josm/gui/help/HelpUtil.java
r18208 r19080 150 150 public static String buildAbsoluteHelpTopic(String topic, LocaleType type) { 151 151 String prefix = getHelpTopicPrefix(type); 152 if (prefix == null || Utils.is Blank(topic) || "/".equals(topic.trim()))152 if (prefix == null || Utils.isStripEmpty(topic) || "/".equals(topic.trim())) 153 153 return prefix; 154 154 prefix += '/' + topic; -
trunk/src/org/openstreetmap/josm/gui/io/LayerNameAndFilePathTableCell.java
r18211 r19080 230 230 @Override 231 231 public boolean stopCellEditing() { 232 if (Utils.is Blank(tfFilename.getText())) {232 if (Utils.isStripEmpty(tfFilename.getText())) { 233 233 value = null; 234 234 } else { -
trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java
r18211 r19080 312 312 String commentText = comment.getText(); 313 313 //closing a note creates an empty comment that we don't want to show 314 if (!Utils.is Blank(commentText)) {314 if (!Utils.isStripEmpty(commentText)) { 315 315 sb.append("<hr/>"); 316 316 String userName = XmlWriter.encode(comment.getUser().getName()); 317 if (Utils.is Blank(userName)) {317 if (Utils.isStripEmpty(userName)) { 318 318 userName = "<Anonymous>"; 319 319 } -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r18941 r19080 186 186 */ 187 187 public GeoImageLayer(final List<ImageEntry> data, GpxData gpxData, final String name, boolean useThumbs) { 188 super(!Utils.is Blank(name) ? name : tr("Geotagged Images"));188 super(!Utils.isStripEmpty(name) ? name : tr("Geotagged Images")); 189 189 this.data = new ImageData(data); 190 190 this.gpxData = gpxData; -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
r19050 r19080 772 772 errorMessage = null; 773 773 } 774 if (!Utils.is Blank(errorMessage)) {774 if (!Utils.isStripEmpty(errorMessage)) { 775 775 Rectangle2D errorStringSize = g.getFontMetrics(g.getFont()).getStringBounds(errorMessage, g); 776 776 if (Boolean.TRUE.equals(ERROR_MESSAGE_BACKGROUND.get())) { -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarker.java
r18634 r19080 62 62 remoteEntry.setPos(this); 63 63 } 64 if (!Utils.is Blank(this.getText())) {64 if (!Utils.isStripEmpty(this.getText())) { 65 65 remoteEntry.setDisplayName(this.getText()); 66 66 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LabelCompositionStrategy.java
r19050 r19080 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.mappaint.styleelement; 3 4 import static java.util.function.Predicate.not; 3 5 4 6 import java.util.ArrayList; … … 186 188 } 187 189 return nameTags.stream() 188 .filter( tag -> !Utils.isStripEmpty(tag))190 .filter(not(Utils::isStripEmpty)) 189 191 .collect(Collectors.toList()); 190 192 } -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r18871 r19080 764 764 765 765 private static void prepareFileChooser(String url, AbstractFileChooser fc) { 766 if (Utils.is Blank(url)) return;766 if (Utils.isStripEmpty(url)) return; 767 767 URL sourceUrl; 768 768 try { -
trunk/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java
r18738 r19080 293 293 if (data == null) return; 294 294 data.setModified(true); 295 if (Utils.is Blank(value) ||295 if (Utils.isStripEmpty(value) || 296 296 (getLayerPref(null, key).equals(value) && DEFAULT_PREFS.get(key) != null && DEFAULT_PREFS.get(key).toString().equals(value))) { 297 297 data.getLayerPrefs().remove(key); -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java
r18211 r19080 64 64 protected static String formatPluginRemoteVersion(PluginInformation pi) { 65 65 StringBuilder sb = new StringBuilder(); 66 if (Utils.is Blank(pi.version)) {66 if (Utils.isStripEmpty(pi.version)) { 67 67 sb.append(tr("unknown")); 68 68 } else { … … 78 78 if (pi == null) 79 79 return tr("unknown"); 80 if (Utils.is Blank(pi.localversion))80 if (Utils.isStripEmpty(pi.localversion)) 81 81 return tr("unknown"); 82 82 return pi.localversion; -
trunk/src/org/openstreetmap/josm/gui/progress/CLIProgressMonitor.java
r18428 r19080 38 38 @Override 39 39 protected void doBeginTask() { 40 if (!Utils.is Blank(this.title)) {40 if (!Utils.isStripEmpty(this.title)) { 41 41 Logging.info(tr("Beginning task {2}: {0}{1}", this.title, this.customText, 42 42 Optional.ofNullable(this.taskId).map(ProgressTaskId::getId).map(id -> ' ' + id).orElse(""))); -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java
r19050 r19080 2 2 package org.openstreetmap.josm.gui.tagging; 3 3 4 import static java.util.function.Predicate.not; 4 5 import static org.openstreetmap.josm.tools.I18n.trn; 5 6 … … 532 533 return tags.stream() 533 534 .map(TagModel::getName) 534 .filter(n ame -> !Utils.isStripEmpty(name))535 .filter(not(Utils::isStripEmpty)) 535 536 .collect(Collectors.toList()); 536 537 } -
trunk/src/org/openstreetmap/josm/gui/widgets/AbstractIdTextField.java
r18221 r19080 82 82 */ 83 83 public boolean tryToPasteFrom(String contents) { 84 if (!Utils.is Blank(contents)) {84 if (!Utils.isStripEmpty(contents)) { 85 85 setText(contents.trim()); 86 86 clearTextIfInvalid(); -
trunk/src/org/openstreetmap/josm/gui/widgets/ChangesetIdTextField.java
r18211 r19080 75 75 public boolean readChangesetId() { 76 76 String value = getComponent().getText(); 77 if (!Utils.is Blank(value)) {77 if (!Utils.isStripEmpty(value)) { 78 78 value = value.trim(); 79 79 id = 0; -
trunk/src/org/openstreetmap/josm/gui/widgets/OsmIdTextField.java
r18208 r19080 95 95 String value = getComponent().getText(); 96 96 char c; 97 if (Utils.is Blank(value)) {97 if (Utils.isStripEmpty(value)) { 98 98 return false; 99 99 } -
trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
r19078 r19080 76 76 if (trackUrl instanceof String) { 77 77 String sTrackUrl = (String) trackUrl; 78 if (!Utils.is Blank(sTrackUrl) && !sTrackUrl.startsWith("http")) {78 if (!Utils.isStripEmpty(sTrackUrl) && !sTrackUrl.startsWith("http")) { 79 79 track.put("url", browseUrl + sTrackUrl); 80 80 } -
trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java
r19050 r19080 432 432 public static class ChangesetQueryUrlParser { 433 433 protected int parseUid(String value) throws ChangesetQueryUrlException { 434 if (Utils.is Blank(value))434 if (Utils.isStripEmpty(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 (Utils.is Blank(value))451 if (Utils.isStripEmpty(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 (Utils.is Blank(value))466 if (Utils.isStripEmpty(value)) 467 467 throw new ChangesetQueryUrlException( 468 468 tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value)); -
trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java
r18801 r19080 148 148 httpProxySocketAddress = null; 149 149 if (proxyPolicy == ProxyPolicy.USE_HTTP_PROXY) { 150 if (!Utils.is Blank(host) && port > 0) {150 if (!Utils.isStripEmpty(host) && port > 0) { 151 151 httpProxySocketAddress = new InetSocketAddress(host, port); 152 152 } else { … … 160 160 socksProxySocketAddress = null; 161 161 if (proxyPolicy == ProxyPolicy.USE_SOCKS_PROXY) { 162 if (!Utils.is Blank(host) && port > 0) {162 if (!Utils.isStripEmpty(host) && port > 0) { 163 163 socksProxySocketAddress = new InetSocketAddress(host, port); 164 164 } else { -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r18817 r19080 75 75 message += '.'; 76 76 } 77 if (!Utils.is Blank(parser.getData().creator)) {77 if (!Utils.isStripEmpty(parser.getData().creator)) { 78 78 message += "\n" + tr("The file was created by \"{0}\".", parser.getData().creator); 79 79 } -
trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java
r18991 r19080 129 129 if (requestorType == RequestorType.SERVER && Objects.equals(OsmApi.getOsmApi().getHost(), host)) { 130 130 String username = credentials.getUserName(); 131 if (!Utils.is Blank(username)) {131 if (!Utils.isStripEmpty(username)) { 132 132 UserIdentityManager.getInstance().setPartiallyIdentified(username); 133 133 } -
trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialAgent.java
r19050 r19080 115 115 String token = Config.getPref().get(hostKey, null); 116 116 String parameters = Config.getPref().get(parametersKey, null); 117 if (!Utils.is Blank(token) && !Utils.isBlank(parameters) && OAuthVersion.OAuth20 == oauthType) {117 if (!Utils.isStripEmpty(token) && !Utils.isStripEmpty(parameters) && OAuthVersion.OAuth20 == oauthType) { 118 118 try { 119 119 OAuth20Parameters oAuth20Parameters = new OAuth20Parameters(parameters); -
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r18991 r19080 461 461 public static String explainGeneric(Exception e) { 462 462 String msg = e.getMessage(); 463 if (Utils.is Blank(msg)) {463 if (Utils.isStripEmpty(msg)) { 464 464 msg = e.toString(); 465 465 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r19079 r19080 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static java.util.function.Predicate.not; 4 5 import static org.openstreetmap.josm.tools.I18n.marktr; 5 6 import static org.openstreetmap.josm.tools.I18n.tr; … … 737 738 * @return {@code true} if string is null or blank 738 739 * @since 18208 739 */ 740 * @deprecated use {@link #isStripEmpty(String)} or {@link String#isBlank()} instead 741 */ 742 @Deprecated(since = "19080", forRemoval = true) 740 743 public static boolean isBlank(String string) { 741 744 return isStripEmpty(string); … … 751 754 public static String firstNotEmptyString(String defaultString, String... candidates) { 752 755 return Arrays.stream(candidates) 753 .filter( candidate -> !Utils.isStripEmpty(candidate))756 .filter(not(Utils::isStripEmpty)) 754 757 .findFirst().orElse(defaultString); 755 758 } -
trunk/test/unit/org/openstreetmap/josm/testutils/annotations/ProjectionNadGrids.java
r18972 r19080 34 34 @Override 35 35 public void beforeEach(ExtensionContext extensionContext) throws Exception { 36 if (Utils.is Blank(Utils.getSystemProperty("PROJ_LIB"))) {36 if (Utils.isStripEmpty(Utils.getSystemProperty("PROJ_LIB"))) { 37 37 Utils.updateSystemProperty("PROJ_LIB", Paths.get("nodist", "data", "projection").toString()); 38 38 }
Note:
See TracChangeset
for help on using the changeset viewer.