Skip to content

Commit c85050e

Browse files
ngocnhan-tran1996sbrannen
authored andcommitted
Consistently use CharSequence.isEmpty() for emptiness checks
Closes spring-projectsgh-33577
1 parent f321ef9 commit c85050e

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

spring-core/src/main/java/org/springframework/cglib/core/TypeUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static String getPackageName(String className) {
9797
}
9898

9999
public static String upperFirst(String s) {
100-
if (s == null || s.length() == 0) {
100+
if (s == null || s.isEmpty()) {
101101
return s;
102102
}
103103
return Character.toUpperCase(s.charAt(0)) + s.substring(1);

spring-r2dbc/src/main/java/org/springframework/r2dbc/core/binding/BindMarkersFactoryResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -153,7 +153,7 @@ private static String filterBindMarker(CharSequence input) {
153153
builder.append(ch);
154154
}
155155
}
156-
if (builder.length() == 0) {
156+
if (builder.isEmpty()) {
157157
return "";
158158
}
159159
return "_" + builder.toString();

spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ public void append(String path) {
877877
@Override
878878
@Nullable
879879
public PathComponent build() {
880-
if (this.path.length() == 0) {
880+
if (this.path.isEmpty()) {
881881
return null;
882882
}
883883
String sanitized = getSanitizedPath(this.path);

spring-web/src/main/java/org/springframework/web/util/pattern/CaptureVariablePathElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -73,7 +73,7 @@ public boolean matches(int pathIndex, PathPattern.MatchingContext matchingContex
7373
return false;
7474
}
7575
String candidateCapture = matchingContext.pathElementValue(pathIndex);
76-
if (candidateCapture.length() == 0) {
76+
if (candidateCapture.isEmpty()) {
7777
return false;
7878
}
7979

spring-web/src/main/java/org/springframework/web/util/pattern/WildcardPathElement.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -66,15 +66,15 @@ public boolean matches(int pathIndex, MatchingContext matchingContext) {
6666
}
6767
else {
6868
return (matchingContext.isMatchOptionalTrailingSeparator() && // if optional slash is on...
69-
segmentData != null && segmentData.length() > 0 && // and there is at least one character to match the *...
69+
segmentData != null && !segmentData.isEmpty() && // and there is at least one character to match the *...
7070
(pathIndex + 1) == matchingContext.pathLength && // and the next path element is the end of the candidate...
7171
matchingContext.isSeparator(pathIndex)); // and the final element is a separator
7272
}
7373
}
7474
}
7575
else {
7676
// Within a path (e.g. /aa/*/bb) there must be at least one character to match the wildcard
77-
if (segmentData == null || segmentData.length() == 0) {
77+
if (segmentData == null || segmentData.isEmpty()) {
7878
return false;
7979
}
8080
return (this.next != null && this.next.matches(pathIndex, matchingContext));

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/UrlTag.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -323,7 +323,7 @@ protected String createQueryString(List<Param> params, Set<String> usedParams, b
323323
StringBuilder qs = new StringBuilder();
324324
for (Param param : params) {
325325
if (!usedParams.contains(param.getName()) && StringUtils.hasLength(param.getName())) {
326-
if (includeQueryStringDelimiter && qs.length() == 0) {
326+
if (includeQueryStringDelimiter && qs.isEmpty()) {
327327
qs.append('?');
328328
}
329329
else {

0 commit comments

Comments
 (0)