Consistently use CharSequence.isEmpty() for emptiness checks
Closes gh-33577
This commit is contained in:
parent
f321ef9ec2
commit
c85050eb43
|
@ -97,7 +97,7 @@ public class TypeUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String upperFirst(String s) {
|
public static String upperFirst(String s) {
|
||||||
if (s == null || s.length() == 0) {
|
if (s == null || s.isEmpty()) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
return Character.toUpperCase(s.charAt(0)) + s.substring(1);
|
return Character.toUpperCase(s.charAt(0)) + s.substring(1);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -153,7 +153,7 @@ public final class BindMarkersFactoryResolver {
|
||||||
builder.append(ch);
|
builder.append(ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (builder.length() == 0) {
|
if (builder.isEmpty()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return "_" + builder.toString();
|
return "_" + builder.toString();
|
||||||
|
|
|
@ -877,7 +877,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public PathComponent build() {
|
public PathComponent build() {
|
||||||
if (this.path.length() == 0) {
|
if (this.path.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String sanitized = getSanitizedPath(this.path);
|
String sanitized = getSanitizedPath(this.path);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -73,7 +73,7 @@ class CaptureVariablePathElement extends PathElement {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String candidateCapture = matchingContext.pathElementValue(pathIndex);
|
String candidateCapture = matchingContext.pathElementValue(pathIndex);
|
||||||
if (candidateCapture.length() == 0) {
|
if (candidateCapture.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -66,7 +66,7 @@ class WildcardPathElement extends PathElement {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (matchingContext.isMatchOptionalTrailingSeparator() && // if optional slash is on...
|
return (matchingContext.isMatchOptionalTrailingSeparator() && // if optional slash is on...
|
||||||
segmentData != null && segmentData.length() > 0 && // and there is at least one character to match the *...
|
segmentData != null && !segmentData.isEmpty() && // and there is at least one character to match the *...
|
||||||
(pathIndex + 1) == matchingContext.pathLength && // and the next path element is the end of the candidate...
|
(pathIndex + 1) == matchingContext.pathLength && // and the next path element is the end of the candidate...
|
||||||
matchingContext.isSeparator(pathIndex)); // and the final element is a separator
|
matchingContext.isSeparator(pathIndex)); // and the final element is a separator
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ class WildcardPathElement extends PathElement {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Within a path (e.g. /aa/*/bb) there must be at least one character to match the wildcard
|
// Within a path (e.g. /aa/*/bb) there must be at least one character to match the wildcard
|
||||||
if (segmentData == null || segmentData.length() == 0) {
|
if (segmentData == null || segmentData.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (this.next != null && this.next.matches(pathIndex, matchingContext));
|
return (this.next != null && this.next.matches(pathIndex, matchingContext));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -323,7 +323,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
|
||||||
StringBuilder qs = new StringBuilder();
|
StringBuilder qs = new StringBuilder();
|
||||||
for (Param param : params) {
|
for (Param param : params) {
|
||||||
if (!usedParams.contains(param.getName()) && StringUtils.hasLength(param.getName())) {
|
if (!usedParams.contains(param.getName()) && StringUtils.hasLength(param.getName())) {
|
||||||
if (includeQueryStringDelimiter && qs.length() == 0) {
|
if (includeQueryStringDelimiter && qs.isEmpty()) {
|
||||||
qs.append('?');
|
qs.append('?');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue