Skip to content

Commit

Permalink
See #23671: Deprecate Utils#isBlank and replace instances of it with …
Browse files Browse the repository at this point in the history
…Utils#isStripEmpty

As noted in r19079, the two functions were identical in behavior.
  • Loading branch information
tsmock committed May 14, 2024
1 parent f4f4426 commit 5cdace3
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static Map<PrimitiveId, IPrimitive> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public static Map<String, Option> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ public void modifyChangesetTags(Map<String, String> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5cdace3

Please sign in to comment.