Skip to content

Commit 32f9e90

Browse files
izeyesnicoll
authored andcommitted
Replace 'String.length() == 0' with 'String.isEmpty()'
See gh-8103
1 parent 79233b0 commit 32f9e90

File tree

9 files changed

+11
-11
lines changed

9 files changed

+11
-11
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private String extractPrefix(ApplicationContext context,
234234
private Map<String, Object> sanitize(String prefix, Map<String, Object> map) {
235235
for (Map.Entry<String, Object> entry : map.entrySet()) {
236236
String key = entry.getKey();
237-
String qualifiedKey = (prefix.length() == 0 ? prefix : prefix + ".") + key;
237+
String qualifiedKey = (prefix.isEmpty() ? prefix : prefix + ".") + key;
238238
Object value = entry.getValue();
239239
if (value instanceof Map) {
240240
map.put(key, sanitize(qualifiedKey, (Map<String, Object>) value));

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractMvcEndpoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public AbstractMvcEndpoint(String path, boolean sensitive, boolean enabled) {
6969
@PostConstruct
7070
private void validate() {
7171
Assert.notNull(this.path, "Path must not be null");
72-
Assert.isTrue(this.path.length() == 0 || this.path.startsWith("/"),
72+
Assert.isTrue(this.path.isEmpty() || this.path.startsWith("/"),
7373
"Path must start with / or be empty");
7474
}
7575

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ private String parseVirtualHost(String input) {
770770
int hostIndex = input.indexOf("/");
771771
if (hostIndex >= 0) {
772772
this.virtualHost = input.substring(hostIndex + 1);
773-
if (this.virtualHost.length() == 0) {
773+
if (this.virtualHost.isEmpty()) {
774774
this.virtualHost = "/";
775775
}
776776
input = input.substring(0, hostIndex);

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class H2ConsoleProperties {
4747
@PostConstruct
4848
private void validate() {
4949
Assert.notNull(this.path, "Path must not be null");
50-
Assert.isTrue(this.path.length() == 0 || this.path.startsWith("/"),
50+
Assert.isTrue(this.path.isEmpty() || this.path.startsWith("/"),
5151
"Path must start with / or be empty");
5252
}
5353

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class WebServicesProperties {
4444
@PostConstruct
4545
private void validate() {
4646
Assert.notNull(this.path, "Path must not be null");
47-
Assert.isTrue(this.path.length() == 0 || this.path.startsWith("/"),
47+
Assert.isTrue(this.path.isEmpty() || this.path.startsWith("/"),
4848
"Path must start with / or be empty");
4949
}
5050

spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public AsciiBytes substring(int beginIndex, int endIndex) {
121121
}
122122

123123
public AsciiBytes append(String string) {
124-
if (string == null || string.length() == 0) {
124+
if (string == null || string.isEmpty()) {
125125
return this;
126126
}
127127
return append(string.getBytes(UTF_8));

spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static class JarEntryName {
293293
}
294294

295295
private String decode(String source) {
296-
if (source.length() == 0 || (source.indexOf('%') < 0)) {
296+
if (source.isEmpty() || (source.indexOf('%') < 0)) {
297297
return source;
298298
}
299299
ByteArrayOutputStream bos = new ByteArrayOutputStream(source.length());
@@ -347,7 +347,7 @@ public String toString() {
347347
}
348348

349349
public boolean isEmpty() {
350-
return this.name.length() == 0;
350+
return this.name.isEmpty();
351351
}
352352

353353
public String getContentType() {

spring-boot/src/main/java/org/springframework/boot/bind/RelaxedConversionService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private class StringToEnum<T extends Enum> implements Converter<String, T> {
120120

121121
@Override
122122
public T convert(String source) {
123-
if (source.length() == 0) {
123+
if (source.isEmpty()) {
124124
// It's an empty enum identifier: reset the enum value to null.
125125
return null;
126126
}

spring-boot/src/main/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,14 @@ private List<String> getProblematicPackages(Set<String> scannedPackages) {
206206
}
207207

208208
private boolean isProblematicPackage(String scannedPackage) {
209-
if (scannedPackage == null || scannedPackage.length() == 0) {
209+
if (scannedPackage == null || scannedPackage.isEmpty()) {
210210
return true;
211211
}
212212
return PROBLEM_PACKAGES.contains(scannedPackage);
213213
}
214214

215215
private String getDisplayName(String scannedPackage) {
216-
if (scannedPackage == null || scannedPackage.length() == 0) {
216+
if (scannedPackage == null || scannedPackage.isEmpty()) {
217217
return "the default package";
218218
}
219219
return "'" + scannedPackage + "'";

0 commit comments

Comments
 (0)