Changeset 19080 in josm


Ignore:
Timestamp:
2024-05-14T21:30:11+02:00 (7 weeks ago)
Author:
taylor.smock
Message:

See #23671: Deprecate Utils#isBlank and replace instances of it with Utils#isStripEmpty

As noted in r19079, the two functions were identical in behavior.

Location:
trunk
Files:
38 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGeoJsonTask.java

    r15784 r19080  
    66import java.util.Optional;
    77import java.util.concurrent.Future;
     8import java.util.function.Predicate;
    89
    910import org.openstreetmap.josm.data.Bounds;
     
    5758        protected String generateLayerName() {
    5859            return Optional.of(url.substring(url.lastIndexOf('/')+1))
    59                 .filter(it -> !Utils.isStripEmpty(it))
     60                .filter(Predicate.not(Utils::isStripEmpty))
    6061                .orElse(super.generateLayerName());
    6162        }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r18801 r19080  
    22package org.openstreetmap.josm.actions.downloadtasks;
    33
     4import static java.util.function.Predicate.not;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56
     
    299300        protected String generateLayerName() {
    300301            return Optional.ofNullable(settings.getLayerName())
    301                 .filter(layerName -> !Utils.isStripEmpty(layerName))
     302                .filter(not(Utils::isStripEmpty))
    302303                .orElse(OsmDataLayer.createNewName());
    303304        }
     
    360361                // the user explicitly wants a new layer, we don't have any layer at all
    361362                // 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)));
    363364                MainApplication.getLayerManager().addLayer(layer, zoomAfterDownload);
    364365                return layer;
  • trunk/src/org/openstreetmap/josm/data/UserIdentityManager.java

    r18655 r19080  
    215215        String credentialsUserName = CredentialsManager.getInstance().getUsername();
    216216        if (isAnonymous()) {
    217             if (!Utils.isBlank(credentialsUserName)) {
     217            if (!Utils.isStripEmpty(credentialsUserName)) {
    218218                setPartiallyIdentified(credentialsUserName);
    219219            }
     
    280280                newUserName = ((StringSetting) evt.getNewValue()).getValue();
    281281            }
    282             if (Utils.isBlank(newUserName)) {
     282            if (Utils.isStripEmpty(newUserName)) {
    283283                setAnonymous();
    284284            } else if (!newUserName.equals(userName)) {
     
    291291                newUrl = ((StringSetting) evt.getNewValue()).getValue();
    292292            }
    293             if (Utils.isBlank(newUrl)) {
     293            if (Utils.isStripEmpty(newUrl)) {
    294294                setAnonymous();
    295295            } else if (isFullyIdentified()) {
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxExtension.java

    r18208 r19080  
    175175        if (parent instanceof GpxExtension) {
    176176            GpxExtension gpx = ((GpxExtension) parent);
    177             if (Utils.isBlank(gpx.getValue())
     177            if (Utils.isStripEmpty(gpx.getValue())
    178178                    && Utils.isEmpty(gpx.getAttributes())
    179179                    && Utils.isEmpty(gpx.getExtensions())) {
     
    191191        if (parent != null && parent instanceof GpxExtension) {
    192192            GpxExtension gpx = (GpxExtension) parent;
    193             if (Utils.isBlank(gpx.getValue())
     193            if (Utils.isStripEmpty(gpx.getValue())
    194194                    && gpx.getAttributes().isEmpty()
    195195                    && !gpx.getExtensions().isVisible()) {
  • trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/style/Layers.java

    r18871 r19080  
    273273        if (layoutObject.containsKey("icon-image")) {
    274274            sb.append(/* NO-ICON */"icon-image:concat(");
    275             if (!Utils.isBlank(this.styleId)) {
     275            if (!Utils.isStripEmpty(this.styleId)) {
    276276                sb.append('"').append(this.styleId).append('/').append("\",");
    277277            }
  • trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/style/MapboxVectorStyle.java

    r18723 r19080  
    143143                this.sources.put(source, new ElemStyles(Collections.singleton(style)));
    144144            }
    145             if (!Utils.isBlank(this.spriteUrl)) {
     145            if (!Utils.isStripEmpty(this.spriteUrl)) {
    146146                MainApplication.worker.execute(this::fetchSprites);
    147147            }
  • trunk/src/org/openstreetmap/josm/data/oauth/OAuth20Token.java

    r18723 r19080  
    8282    @Override
    8383    public void sign(HttpClient client) throws OAuthException {
    84         if (!Utils.isBlank(this.oauthParameters.getApiUrl())
     84        if (!Utils.isStripEmpty(this.oauthParameters.getApiUrl())
    8585                && !this.oauthParameters.getApiUrl().contains(client.getURL().getHost())) {
    8686            String host = URI.create(this.oauthParameters.getAccessTokenUrl()).getHost();
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r19078 r19080  
    719719        List<Map.Entry<String, String>> tagsToAdd = new ArrayList<>(tags.size());
    720720        for (Map.Entry<String, String> tag : tags.entrySet()) {
    721             if (!Utils.isBlank(tag.getKey())) {
     721            if (!Utils.isStripEmpty(tag.getKey())) {
    722722                int keyIndex = indexOfKey(newKeys, tag.getKey());
    723723                // 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  
    14031403                String key = prop.getKey();
    14041404                String value = prop.getValue();
    1405                 if (Utils.isBlank(value)) {
     1405                if (Utils.isStripEmpty(value)) {
    14061406                    commands.add(new ChangePropertyCommand(p, key, null));
    14071407                } else if (value.startsWith(" ") || value.endsWith(" ") || value.contains("  ")) {
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r19060 r19080  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui;
     3
     4import static java.util.function.Predicate.not;
    35
    46import java.awt.AlphaComposite;
     
    827829    public String getLayerInformationForSourceTag() {
    828830        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)
    831834                .distinct()
    832835                .collect(Collectors.joining("; "));
  • trunk/src/org/openstreetmap/josm/gui/PleaseWaitDialog.java

    r18208 r19080  
    107107    @Override
    108108    public void setCustomText(String text) {
    109         if (Utils.isBlank(text)) {
     109        if (Utils.isStripEmpty(text)) {
    110110            customText.setVisible(false);
    111111            adjustLayout();
     
    132132    @Override
    133133    public void appendLogMessage(String message) {
    134         if (Utils.isBlank(message))
     134        if (Utils.isStripEmpty(message))
    135135            return;
    136136        if (!spLog.isVisible()) {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/AbstractCellRenderer.java

    r18208 r19080  
    5757
    5858    protected void renderUser(User user) {
    59         if (user == null || Utils.isBlank(user.getName())) {
     59        if (user == null || Utils.isStripEmpty(user.getName())) {
    6060            setFont(UIManager.getFont("Table.font").deriveFont(Font.ITALIC));
    6161            setText(tr("anonymous"));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/UidInputFieldValidator.java

    r18801 r19080  
    4040    public void validate() {
    4141        String value = getComponent().getText();
    42         if (Utils.isBlank(value)) {
     42        if (Utils.isStripEmpty(value)) {
    4343            feedbackInvalid("");
    4444            return;
     
    6363    public int getUid() {
    6464        String value = getComponent().getText();
    65         if (Utils.isBlank(value)) return 0;
     65        if (Utils.isStripEmpty(value)) return 0;
    6666        try {
    6767            int uid = Integer.parseInt(value.trim());
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SetRoleAction.java

    r19050 r19080  
    4545
    4646    protected boolean isEmptyRole() {
    47         return Utils.isBlank(tfRole.getText());
     47        return Utils.isStripEmpty(tfRole.getText());
    4848    }
    4949
  • trunk/src/org/openstreetmap/josm/gui/help/HelpUtil.java

    r18208 r19080  
    150150    public static String buildAbsoluteHelpTopic(String topic, LocaleType type) {
    151151        String prefix = getHelpTopicPrefix(type);
    152         if (prefix == null || Utils.isBlank(topic) || "/".equals(topic.trim()))
     152        if (prefix == null || Utils.isStripEmpty(topic) || "/".equals(topic.trim()))
    153153            return prefix;
    154154        prefix += '/' + topic;
  • trunk/src/org/openstreetmap/josm/gui/io/LayerNameAndFilePathTableCell.java

    r18211 r19080  
    230230    @Override
    231231    public boolean stopCellEditing() {
    232         if (Utils.isBlank(tfFilename.getText())) {
     232        if (Utils.isStripEmpty(tfFilename.getText())) {
    233233            value = null;
    234234        } else {
  • trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java

    r18211 r19080  
    312312            String commentText = comment.getText();
    313313            //closing a note creates an empty comment that we don't want to show
    314             if (!Utils.isBlank(commentText)) {
     314            if (!Utils.isStripEmpty(commentText)) {
    315315                sb.append("<hr/>");
    316316                String userName = XmlWriter.encode(comment.getUser().getName());
    317                 if (Utils.isBlank(userName)) {
     317                if (Utils.isStripEmpty(userName)) {
    318318                    userName = "&lt;Anonymous&gt;";
    319319                }
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r18941 r19080  
    186186     */
    187187    public GeoImageLayer(final List<ImageEntry> data, GpxData gpxData, final String name, boolean useThumbs) {
    188         super(!Utils.isBlank(name) ? name : tr("Geotagged Images"));
     188        super(!Utils.isStripEmpty(name) ? name : tr("Geotagged Images"));
    189189        this.data = new ImageData(data);
    190190        this.gpxData = gpxData;
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java

    r19050 r19080  
    772772            errorMessage = null;
    773773        }
    774         if (!Utils.isBlank(errorMessage)) {
     774        if (!Utils.isStripEmpty(errorMessage)) {
    775775            Rectangle2D errorStringSize = g.getFontMetrics(g.getFont()).getStringBounds(errorMessage, g);
    776776            if (Boolean.TRUE.equals(ERROR_MESSAGE_BACKGROUND.get())) {
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarker.java

    r18634 r19080  
    6262                remoteEntry.setPos(this);
    6363            }
    64             if (!Utils.isBlank(this.getText())) {
     64            if (!Utils.isStripEmpty(this.getText())) {
    6565                remoteEntry.setDisplayName(this.getText());
    6666            }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LabelCompositionStrategy.java

    r19050 r19080  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint.styleelement;
     3
     4import static java.util.function.Predicate.not;
    35
    46import java.util.ArrayList;
     
    186188            }
    187189            return nameTags.stream()
    188                     .filter(tag -> !Utils.isStripEmpty(tag))
     190                    .filter(not(Utils::isStripEmpty))
    189191                    .collect(Collectors.toList());
    190192        }
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r18871 r19080  
    764764
    765765    private static void prepareFileChooser(String url, AbstractFileChooser fc) {
    766         if (Utils.isBlank(url)) return;
     766        if (Utils.isStripEmpty(url)) return;
    767767        URL sourceUrl;
    768768        try {
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java

    r18738 r19080  
    293293        if (data == null) return;
    294294        data.setModified(true);
    295         if (Utils.isBlank(value) ||
     295        if (Utils.isStripEmpty(value) ||
    296296                (getLayerPref(null, key).equals(value) && DEFAULT_PREFS.get(key) != null && DEFAULT_PREFS.get(key).toString().equals(value))) {
    297297            data.getLayerPrefs().remove(key);
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java

    r18211 r19080  
    6464    protected static String formatPluginRemoteVersion(PluginInformation pi) {
    6565        StringBuilder sb = new StringBuilder();
    66         if (Utils.isBlank(pi.version)) {
     66        if (Utils.isStripEmpty(pi.version)) {
    6767            sb.append(tr("unknown"));
    6868        } else {
     
    7878        if (pi == null)
    7979            return tr("unknown");
    80         if (Utils.isBlank(pi.localversion))
     80        if (Utils.isStripEmpty(pi.localversion))
    8181            return tr("unknown");
    8282        return pi.localversion;
  • trunk/src/org/openstreetmap/josm/gui/progress/CLIProgressMonitor.java

    r18428 r19080  
    3838    @Override
    3939    protected void doBeginTask() {
    40         if (!Utils.isBlank(this.title)) {
     40        if (!Utils.isStripEmpty(this.title)) {
    4141            Logging.info(tr("Beginning task {2}: {0}{1}", this.title, this.customText,
    4242                    Optional.ofNullable(this.taskId).map(ProgressTaskId::getId).map(id -> ' ' + id).orElse("")));
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java

    r19050 r19080  
    22package org.openstreetmap.josm.gui.tagging;
    33
     4import static java.util.function.Predicate.not;
    45import static org.openstreetmap.josm.tools.I18n.trn;
    56
     
    532533        return tags.stream()
    533534                .map(TagModel::getName)
    534                 .filter(name -> !Utils.isStripEmpty(name))
     535                .filter(not(Utils::isStripEmpty))
    535536                .collect(Collectors.toList());
    536537    }
  • trunk/src/org/openstreetmap/josm/gui/widgets/AbstractIdTextField.java

    r18221 r19080  
    8282     */
    8383    public boolean tryToPasteFrom(String contents) {
    84         if (!Utils.isBlank(contents)) {
     84        if (!Utils.isStripEmpty(contents)) {
    8585            setText(contents.trim());
    8686            clearTextIfInvalid();
  • trunk/src/org/openstreetmap/josm/gui/widgets/ChangesetIdTextField.java

    r18211 r19080  
    7575        public boolean readChangesetId() {
    7676            String value = getComponent().getText();
    77             if (!Utils.isBlank(value)) {
     77            if (!Utils.isStripEmpty(value)) {
    7878                value = value.trim();
    7979                id = 0;
  • trunk/src/org/openstreetmap/josm/gui/widgets/OsmIdTextField.java

    r18208 r19080  
    9595            String value = getComponent().getText();
    9696            char c;
    97             if (Utils.isBlank(value)) {
     97            if (Utils.isStripEmpty(value)) {
    9898                return false;
    9999            }
  • trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r19078 r19080  
    7676                    if (trackUrl instanceof String) {
    7777                        String sTrackUrl = (String) trackUrl;
    78                         if (!Utils.isBlank(sTrackUrl) && !sTrackUrl.startsWith("http")) {
     78                        if (!Utils.isStripEmpty(sTrackUrl) && !sTrackUrl.startsWith("http")) {
    7979                            track.put("url", browseUrl + sTrackUrl);
    8080                        }
  • trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java

    r19050 r19080  
    432432    public static class ChangesetQueryUrlParser {
    433433        protected int parseUid(String value) throws ChangesetQueryUrlException {
    434             if (Utils.isBlank(value))
     434            if (Utils.isStripEmpty(value))
    435435                throw new ChangesetQueryUrlException(
    436436                        tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "uid", value));
     
    449449
    450450        protected boolean parseBoolean(String value, String parameter) throws ChangesetQueryUrlException {
    451             if (Utils.isBlank(value))
     451            if (Utils.isStripEmpty(value))
    452452                throw new ChangesetQueryUrlException(
    453453                        tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value));
     
    464464
    465465        protected Instant parseDate(String value, String parameter) throws ChangesetQueryUrlException {
    466             if (Utils.isBlank(value))
     466            if (Utils.isStripEmpty(value))
    467467                throw new ChangesetQueryUrlException(
    468468                        tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value));
  • trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java

    r18801 r19080  
    148148        httpProxySocketAddress = null;
    149149        if (proxyPolicy == ProxyPolicy.USE_HTTP_PROXY) {
    150             if (!Utils.isBlank(host) && port > 0) {
     150            if (!Utils.isStripEmpty(host) && port > 0) {
    151151                httpProxySocketAddress = new InetSocketAddress(host, port);
    152152            } else {
     
    160160        socksProxySocketAddress = null;
    161161        if (proxyPolicy == ProxyPolicy.USE_SOCKS_PROXY) {
    162             if (!Utils.isBlank(host) && port > 0) {
     162            if (!Utils.isStripEmpty(host) && port > 0) {
    163163                socksProxySocketAddress = new InetSocketAddress(host, port);
    164164            } else {
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r18817 r19080  
    7575                        message += '.';
    7676                }
    77                 if (!Utils.isBlank(parser.getData().creator)) {
     77                if (!Utils.isStripEmpty(parser.getData().creator)) {
    7878                    message += "\n" + tr("The file was created by \"{0}\".", parser.getData().creator);
    7979                }
  • trunk/src/org/openstreetmap/josm/io/auth/CredentialsManager.java

    r18991 r19080  
    129129        if (requestorType == RequestorType.SERVER && Objects.equals(OsmApi.getOsmApi().getHost(), host)) {
    130130            String username = credentials.getUserName();
    131             if (!Utils.isBlank(username)) {
     131            if (!Utils.isStripEmpty(username)) {
    132132                UserIdentityManager.getInstance().setPartiallyIdentified(username);
    133133            }
  • trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialAgent.java

    r19050 r19080  
    115115            String token = Config.getPref().get(hostKey, null);
    116116            String parameters = Config.getPref().get(parametersKey, null);
    117             if (!Utils.isBlank(token) && !Utils.isBlank(parameters) && OAuthVersion.OAuth20 == oauthType) {
     117            if (!Utils.isStripEmpty(token) && !Utils.isStripEmpty(parameters) && OAuthVersion.OAuth20 == oauthType) {
    118118                try {
    119119                    OAuth20Parameters oAuth20Parameters = new OAuth20Parameters(parameters);
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r18991 r19080  
    461461    public static String explainGeneric(Exception e) {
    462462        String msg = e.getMessage();
    463         if (Utils.isBlank(msg)) {
     463        if (Utils.isStripEmpty(msg)) {
    464464            msg = e.toString();
    465465        }
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r19079 r19080  
    22package org.openstreetmap.josm.tools;
    33
     4import static java.util.function.Predicate.not;
    45import static org.openstreetmap.josm.tools.I18n.marktr;
    56import static org.openstreetmap.josm.tools.I18n.tr;
     
    737738     * @return {@code true} if string is null or blank
    738739     * @since 18208
    739      */
     740     * @deprecated use {@link #isStripEmpty(String)} or {@link String#isBlank()} instead
     741     */
     742    @Deprecated(since = "19080", forRemoval = true)
    740743    public static boolean isBlank(String string) {
    741744        return isStripEmpty(string);
     
    751754    public static String firstNotEmptyString(String defaultString, String... candidates) {
    752755        return Arrays.stream(candidates)
    753                 .filter(candidate -> !Utils.isStripEmpty(candidate))
     756                .filter(not(Utils::isStripEmpty))
    754757                .findFirst().orElse(defaultString);
    755758    }
  • trunk/test/unit/org/openstreetmap/josm/testutils/annotations/ProjectionNadGrids.java

    r18972 r19080  
    3434        @Override
    3535        public void beforeEach(ExtensionContext extensionContext) throws Exception {
    36             if (Utils.isBlank(Utils.getSystemProperty("PROJ_LIB"))) {
     36            if (Utils.isStripEmpty(Utils.getSystemProperty("PROJ_LIB"))) {
    3737                Utils.updateSystemProperty("PROJ_LIB", Paths.get("nodist", "data", "projection").toString());
    3838            }
Note: See TracChangeset for help on using the changeset viewer.