Skip to content

Commit

Permalink
Remove usages of StringUtils (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored May 28, 2024
1 parent 6be1d26 commit 15e6cd5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/main/java/hudson/plugins/sidebar_link/LinkAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/hudson/plugins/sidebar_link/LinkProtection.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
Expand Down

0 comments on commit 15e6cd5

Please sign in to comment.