From 15e6cd56d9234b9cf0d8ae8869c3afb9b40b6261 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 28 May 2024 08:54:07 -0700 Subject: [PATCH] Remove usages of `StringUtils` (#74) --- src/main/java/hudson/plugins/sidebar_link/LinkAction.java | 3 +-- .../java/hudson/plugins/sidebar_link/LinkProtection.java | 5 ++--- .../java/hudson/plugins/sidebar_link/SidebarLinkPlugin.java | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/hudson/plugins/sidebar_link/LinkAction.java b/src/main/java/hudson/plugins/sidebar_link/LinkAction.java index 2082e07a..066a874a 100644 --- a/src/main/java/hudson/plugins/sidebar_link/LinkAction.java +++ b/src/main/java/hudson/plugins/sidebar_link/LinkAction.java @@ -29,7 +29,6 @@ import hudson.model.Action; import hudson.util.FormValidation; -import io.jenkins.cli.shaded.org.apache.commons.lang.StringUtils; import javax.annotation.CheckForNull; import org.kohsuke.accmod.Restricted; @@ -68,7 +67,7 @@ public LinkAction(String urlName, String displayName, String iconFileName) throw this.url = urlName; this.text = displayName; - this.icon = StringUtils.defaultIfBlank(iconFileName, DEFAULT_ICON_NAME); + this.icon = (iconFileName == null || iconFileName.isBlank()) ? DEFAULT_ICON_NAME : iconFileName; LOGGER.info(String.format("Created link '%s': url='%s', icon='%s'", this.text, this.url, this.icon)); } diff --git a/src/main/java/hudson/plugins/sidebar_link/LinkProtection.java b/src/main/java/hudson/plugins/sidebar_link/LinkProtection.java index 87654ccf..c3157929 100644 --- a/src/main/java/hudson/plugins/sidebar_link/LinkProtection.java +++ b/src/main/java/hudson/plugins/sidebar_link/LinkProtection.java @@ -33,7 +33,6 @@ import javax.annotation.CheckForNull; import javax.annotation.CheckReturnValue; import javax.annotation.Nonnull; -import org.apache.commons.lang.StringUtils; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -65,13 +64,13 @@ class LinkProtection { @Nonnull public static String getAllowedUriSchemes() { - return StringUtils.join(ALLOWED_URI_SCHEMES, ','); + return String.join(",", ALLOWED_URI_SCHEMES); } @CheckReturnValue @Nonnull public static FormValidation verifyUrl(@CheckForNull String urlString) { - if (StringUtils.isBlank(urlString)) { + if (urlString == null || urlString.isBlank()) { return FormValidation.warning("The provided URL is blank or empty"); } diff --git a/src/main/java/hudson/plugins/sidebar_link/SidebarLinkPlugin.java b/src/main/java/hudson/plugins/sidebar_link/SidebarLinkPlugin.java index 129d2f57..379983d2 100644 --- a/src/main/java/hudson/plugins/sidebar_link/SidebarLinkPlugin.java +++ b/src/main/java/hudson/plugins/sidebar_link/SidebarLinkPlugin.java @@ -33,7 +33,6 @@ import net.sf.json.JSONObject; import org.apache.commons.fileupload.FileItem; -import org.apache.commons.lang.StringUtils; import org.jenkinsci.Symbol; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -136,7 +135,7 @@ public FormValidation doCheckLinkUrl(@QueryParameter String value) { @Restricted(NoExternalUse.class) public FormValidation doCheckLinkText(@QueryParameter String value) { - if (StringUtils.isBlank(value)) { + if (value == null || value.isBlank()) { return FormValidation.error("The provided text is blank or empty"); } return FormValidation.ok(); @@ -145,7 +144,7 @@ public FormValidation doCheckLinkText(@QueryParameter String value) { @Restricted(NoExternalUse.class) public FormValidation doCheckLinkIcon(@QueryParameter String value) { // use default icon when value is not provided - if (StringUtils.isBlank(value)) { + if (value == null || value.isBlank()) { return FormValidation.warning("The provided icon is blank or empty. " + "Default will be used: " + LinkAction.DEFAULT_ICON_NAME); }