mirror of https://github.com/halo-dev/halo
Update deprecated default string function (#7239)
#### What type of PR is this?
/kind cleanup
#### What this PR does / why we need it:
Replaces deprecated functions (`String defaultString(final String str, final String nullDefault)`) with its recommended alternatives
See 29ccc7665f/src/main/java/org/apache/commons/lang3/StringUtils.java (L1635)
for more.
#### Does this PR introduce a user-facing change?
```release-note
None
```
pull/7257/head
parent
0cdd8d1469
commit
8305822c09
|
@ -5,6 +5,7 @@ import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
|||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
@ -83,7 +84,7 @@ public class Theme extends AbstractExtension {
|
|||
|
||||
@NonNull
|
||||
public String getVersion() {
|
||||
return StringUtils.defaultString(this.version, WILDCARD);
|
||||
return Objects.toString(this.version, WILDCARD);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,14 +97,14 @@ public class Theme extends AbstractExtension {
|
|||
if (StringUtils.isNotBlank(this.requires)) {
|
||||
return this.requires;
|
||||
}
|
||||
return StringUtils.defaultString(this.require, WILDCARD);
|
||||
return Objects.toString(this.require, WILDCARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatible with {@link #website} property.
|
||||
*/
|
||||
public String getHomepage() {
|
||||
return StringUtils.defaultString(this.homepage, this.website);
|
||||
return Objects.toString(this.homepage, this.website);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.apache.commons.lang3.math.NumberUtils;
|
|||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import run.halo.app.extension.ListResult;
|
||||
import run.halo.app.infra.utils.PathUtils;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A utility class for template page url.
|
||||
|
@ -83,7 +84,7 @@ public class PageUrlUtils {
|
|||
return PathUtils.combinePath(segments);
|
||||
}
|
||||
}
|
||||
return StringUtils.defaultString(path, "/");
|
||||
return Objects.toString(path, "/");
|
||||
}
|
||||
|
||||
private static String appendPagePart(String path, long page) {
|
||||
|
|
|
@ -117,6 +117,5 @@ public class SinglePageQuery extends SortableRequest {
|
|||
.description("SinglePages filtered by keyword.")
|
||||
.implementation(String.class)
|
||||
.required(false));
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public record CommentEmailOwner(String email, String avatar, String displayName,
|
|||
Comment.CommentOwner commentOwner = new Comment.CommentOwner();
|
||||
commentOwner.setKind(Comment.CommentOwner.KIND_EMAIL);
|
||||
// email nullable
|
||||
commentOwner.setName(StringUtils.defaultString(email, StringUtils.EMPTY));
|
||||
commentOwner.setName(StringUtils.defaultString(email));
|
||||
|
||||
commentOwner.setDisplayName(displayName);
|
||||
Map<String, String> annotations = new LinkedHashMap<>();
|
||||
|
|
|
@ -2,8 +2,8 @@ package run.halo.app.core.reconciler;
|
|||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import run.halo.app.core.extension.ReverseProxy;
|
||||
import run.halo.app.extension.ExtensionClient;
|
||||
|
@ -99,7 +99,7 @@ public class ReverseProxyReconciler implements Reconciler<Reconciler.Request> {
|
|||
if (labels == null) {
|
||||
return PluginConst.SYSTEM_PLUGIN_NAME;
|
||||
}
|
||||
return StringUtils.defaultString(labels.get(PluginConst.PLUGIN_NAME_LABEL_NAME),
|
||||
return Objects.toString(labels.get(PluginConst.PLUGIN_NAME_LABEL_NAME),
|
||||
PluginConst.SYSTEM_PLUGIN_NAME);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,17 +45,17 @@ public class RequestInfo {
|
|||
String apiVersion, String resource, String name, String subresource, String subName,
|
||||
String[] parts) {
|
||||
this.isResourceRequest = isResourceRequest;
|
||||
this.path = StringUtils.defaultString(path, "");
|
||||
this.namespace = StringUtils.defaultString(namespace, "");
|
||||
this.userspace = StringUtils.defaultString(userspace, "");
|
||||
this.verb = StringUtils.defaultString(verb, "");
|
||||
this.apiPrefix = StringUtils.defaultString(apiPrefix, "");
|
||||
this.apiGroup = StringUtils.defaultString(apiGroup, "");
|
||||
this.apiVersion = StringUtils.defaultString(apiVersion, "");
|
||||
this.resource = StringUtils.defaultString(resource, "");
|
||||
this.subresource = StringUtils.defaultString(subresource, "");
|
||||
this.subName = StringUtils.defaultString(subName, "");
|
||||
this.name = StringUtils.defaultString(name, "");
|
||||
this.path = StringUtils.defaultString(path);
|
||||
this.namespace = StringUtils.defaultString(namespace);
|
||||
this.userspace = StringUtils.defaultString(userspace);
|
||||
this.verb = StringUtils.defaultString(verb);
|
||||
this.apiPrefix = StringUtils.defaultString(apiPrefix);
|
||||
this.apiGroup = StringUtils.defaultString(apiGroup);
|
||||
this.apiVersion = StringUtils.defaultString(apiVersion);
|
||||
this.resource = StringUtils.defaultString(resource);
|
||||
this.subresource = StringUtils.defaultString(subresource);
|
||||
this.subName = StringUtils.defaultString(subName);
|
||||
this.name = StringUtils.defaultString(name);
|
||||
this.parts = Objects.requireNonNullElseGet(parts, () -> new String[] {});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ public class RequestInfoFactory {
|
|||
return requestInfo;
|
||||
}
|
||||
|
||||
requestInfo.apiGroup = StringUtils.defaultString(currentParts[0], "");
|
||||
requestInfo.apiGroup = StringUtils.defaultString(currentParts[0]);
|
||||
currentParts = Arrays.copyOfRange(currentParts, 1, currentParts.length);
|
||||
}
|
||||
requestInfo.isResourceRequest = true;
|
||||
|
|
Loading…
Reference in New Issue