From 5cdace31cf7a2d7b09459ad8f9cd02ca30f679e6 Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Tue, 14 May 2024 13:29:51 -0600 Subject: [PATCH] See #23671: Deprecate Utils#isBlank and replace instances of it with Utils#isStripEmpty As noted in r19079, the two functions were identical in behavior. --- .../josm/plugins/maproulette/api/TaskAPI.java | 2 +- .../josm/plugins/maproulette/data/TaskPrimitives.java | 2 +- .../josm/plugins/maproulette/gui/MRGuiHelper.java | 8 ++++---- .../gui/preferences/MapRouletteServerPreference.java | 4 ++-- .../maproulette/gui/task/current/CurrentTaskPanel.java | 2 +- .../plugins/maproulette/io/upload/EarlyUploadHook.java | 4 ++-- .../josm/plugins/maproulette/util/OsmPreferenceUtils.java | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/openstreetmap/josm/plugins/maproulette/api/TaskAPI.java b/src/main/java/org/openstreetmap/josm/plugins/maproulette/api/TaskAPI.java index f03387c..93d1cc1 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/maproulette/api/TaskAPI.java +++ b/src/main/java/org/openstreetmap/josm/plugins/maproulette/api/TaskAPI.java @@ -216,7 +216,7 @@ public static boolean updateStatus(long task, TaskStatus status, String comment, try { final var response = client.connect(); final var content = response.fetchContent(); - if (!Utils.isBlank(content)) { + if (!Utils.isStripEmpty(content)) { Logging.info(content); } return response.getResponseCode() == 204; diff --git a/src/main/java/org/openstreetmap/josm/plugins/maproulette/data/TaskPrimitives.java b/src/main/java/org/openstreetmap/josm/plugins/maproulette/data/TaskPrimitives.java index bddc716..8a2522a 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/maproulette/data/TaskPrimitives.java +++ b/src/main/java/org/openstreetmap/josm/plugins/maproulette/data/TaskPrimitives.java @@ -61,7 +61,7 @@ public static Map getPrimitiveIdMap(@Nullable Task task try { final var challenge = ChallengeCache.challenge(task.parentId()); final var property = challenge.extra().osmIdProperty(); - if (!Utils.isBlank(property)) { + if (!Utils.isStripEmpty(property)) { return getPrimitiveIdMap(task, property); } } catch (IOException ioException) { diff --git a/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/MRGuiHelper.java b/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/MRGuiHelper.java index e97e98c..1db447b 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/MRGuiHelper.java +++ b/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/MRGuiHelper.java @@ -59,7 +59,7 @@ public static String getInstructionText(@Nullable Task currentTask) { return ""; } final String instruction; - if (Utils.isBlank(currentTask.instruction())) { + if (Utils.isStripEmpty(currentTask.instruction())) { Challenge challenge; try { challenge = ChallengeCache.challenge(currentTask.parentId()); @@ -69,9 +69,9 @@ public static String getInstructionText(@Nullable Task currentTask) { } if (challenge == null) { instruction = tr("Could not fetch instruction from parent challenge"); - } else if (!Utils.isBlank(challenge.general().instruction())) { + } else if (!Utils.isStripEmpty(challenge.general().instruction())) { instruction = challenge.general().instruction(); - } else if (!Utils.isBlank(challenge.description())) { + } else if (!Utils.isStripEmpty(challenge.description())) { instruction = challenge.description(); } else { instruction = challenge.name(); @@ -85,7 +85,7 @@ public static String getInstructionText(@Nullable Task currentTask) { final var tag = matcher.group(1); final var replacement = currentTask.geometries().allPrimitives().stream().map(prim -> prim.get(tag)) .filter(Objects::nonNull).collect(Collectors.joining(System.lineSeparator())); - matcher.appendReplacement(builder, Utils.isBlank(replacement) ? matcher.group(0) : replacement); + matcher.appendReplacement(builder, Utils.isStripEmpty(replacement) ? matcher.group(0) : replacement); } matcher.appendTail(builder); diff --git a/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/preferences/MapRouletteServerPreference.java b/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/preferences/MapRouletteServerPreference.java index 59b34b7..dab0ab3 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/preferences/MapRouletteServerPreference.java +++ b/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/preferences/MapRouletteServerPreference.java @@ -75,7 +75,7 @@ public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) { public boolean ok() { final var newApiUrl = this.apiUrl.getText(); final var newApiKey = this.apiKey.getText(); - if (!Utils.isBlank(newApiUrl)) { + if (!Utils.isStripEmpty(newApiUrl)) { if (newApiUrl.equals(MAPROULETTE_URL.getDefaultValue())) { MAPROULETTE_URL.remove(); } else if (!newApiUrl.equals(MAPROULETTE_URL.get())) { @@ -84,7 +84,7 @@ public boolean ok() { } final var prefKeyApi = "maproulette.openstreetmap." + MAPROULETTE_URL.get() + ".api_key"; - if (!Utils.isBlank(newApiKey)) { + if (!Utils.isStripEmpty(newApiKey)) { if (DEFAULT_MAPROULETTE_API_KEY.equals(newApiKey)) { Config.getPref().put(prefKeyApi, null); } else { diff --git a/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/task/current/CurrentTaskPanel.java b/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/task/current/CurrentTaskPanel.java index 88180b7..553cda6 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/task/current/CurrentTaskPanel.java +++ b/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/task/current/CurrentTaskPanel.java @@ -273,7 +273,7 @@ public static Map getSelections(HTMLDocument doc) { final var name = (String) attribs.getAttribute(HTML.Attribute.NAME); if (attribs.getAttribute(StyleConstants.ModelAttribute)instanceof DefaultComboBoxModel listModel) { final var option = (Option) listModel.getSelectedItem(); - if (!Utils.isBlank(option.getValue())) { + if (!Utils.isStripEmpty(option.getValue())) { selectionMap.put(name, option); } } diff --git a/src/main/java/org/openstreetmap/josm/plugins/maproulette/io/upload/EarlyUploadHook.java b/src/main/java/org/openstreetmap/josm/plugins/maproulette/io/upload/EarlyUploadHook.java index deab1b4..f2aa45d 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/maproulette/io/upload/EarlyUploadHook.java +++ b/src/main/java/org/openstreetmap/josm/plugins/maproulette/io/upload/EarlyUploadHook.java @@ -220,10 +220,10 @@ public void modifyChangesetTags(Map tags) { tagBuilder.append(entry.task().id()); try { final var challengeGeneral = ChallengeCache.challenge(entry.task().parentId()).general(); - if (!Utils.isBlank(challengeGeneral.checkinComment())) { + if (!Utils.isStripEmpty(challengeGeneral.checkinComment())) { changesetComments.add(challengeGeneral.checkinComment()); } - if (!Utils.isBlank(challengeGeneral.checkinSource())) { + if (!Utils.isStripEmpty(challengeGeneral.checkinSource())) { sourceComments.add(challengeGeneral.checkinSource()); } } catch (IOException ioException) { diff --git a/src/main/java/org/openstreetmap/josm/plugins/maproulette/util/OsmPreferenceUtils.java b/src/main/java/org/openstreetmap/josm/plugins/maproulette/util/OsmPreferenceUtils.java index f76c384..c8fba86 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/maproulette/util/OsmPreferenceUtils.java +++ b/src/main/java/org/openstreetmap/josm/plugins/maproulette/util/OsmPreferenceUtils.java @@ -48,7 +48,7 @@ static String getMapRouletteApiKey() throws UnauthorizedException { } final var preferenceKey = "maproulette.openstreetmap." + getBaseUrl() + "." + user.getId(); final var possibleApiKey = Config.getPref().get(preferenceKey); - if (!Utils.isBlank(possibleApiKey) && !"Couldn't authenticate you".equals(possibleApiKey)) { + if (!Utils.isStripEmpty(possibleApiKey) && !"Couldn't authenticate you".equals(possibleApiKey)) { return possibleApiKey; } final var osmServerKey = Config.getPref().get("maproulette.openstreetmap" + getBaseUrl() + ".api_key",