Replace 'String.length() == 0' with 'String.isEmpty()'
See gh-8103
This commit is contained in:
committed by
Stephane Nicoll
parent
79233b019e
commit
32f9e90de5
@@ -234,7 +234,7 @@ public class ConfigurationPropertiesReportEndpoint
|
||||
private Map<String, Object> sanitize(String prefix, Map<String, Object> map) {
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String qualifiedKey = (prefix.length() == 0 ? prefix : prefix + ".") + key;
|
||||
String qualifiedKey = (prefix.isEmpty() ? prefix : prefix + ".") + key;
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof Map) {
|
||||
map.put(key, sanitize(qualifiedKey, (Map<String, Object>) value));
|
||||
|
||||
@@ -69,7 +69,7 @@ public abstract class AbstractMvcEndpoint extends WebMvcConfigurerAdapter
|
||||
@PostConstruct
|
||||
private void validate() {
|
||||
Assert.notNull(this.path, "Path must not be null");
|
||||
Assert.isTrue(this.path.length() == 0 || this.path.startsWith("/"),
|
||||
Assert.isTrue(this.path.isEmpty() || this.path.startsWith("/"),
|
||||
"Path must start with / or be empty");
|
||||
}
|
||||
|
||||
|
||||
@@ -770,7 +770,7 @@ public class RabbitProperties {
|
||||
int hostIndex = input.indexOf("/");
|
||||
if (hostIndex >= 0) {
|
||||
this.virtualHost = input.substring(hostIndex + 1);
|
||||
if (this.virtualHost.length() == 0) {
|
||||
if (this.virtualHost.isEmpty()) {
|
||||
this.virtualHost = "/";
|
||||
}
|
||||
input = input.substring(0, hostIndex);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class H2ConsoleProperties {
|
||||
@PostConstruct
|
||||
private void validate() {
|
||||
Assert.notNull(this.path, "Path must not be null");
|
||||
Assert.isTrue(this.path.length() == 0 || this.path.startsWith("/"),
|
||||
Assert.isTrue(this.path.isEmpty() || this.path.startsWith("/"),
|
||||
"Path must start with / or be empty");
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class WebServicesProperties {
|
||||
@PostConstruct
|
||||
private void validate() {
|
||||
Assert.notNull(this.path, "Path must not be null");
|
||||
Assert.isTrue(this.path.length() == 0 || this.path.startsWith("/"),
|
||||
Assert.isTrue(this.path.isEmpty() || this.path.startsWith("/"),
|
||||
"Path must start with / or be empty");
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ final class AsciiBytes {
|
||||
}
|
||||
|
||||
public AsciiBytes append(String string) {
|
||||
if (string == null || string.length() == 0) {
|
||||
if (string == null || string.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
return append(string.getBytes(UTF_8));
|
||||
|
||||
@@ -293,7 +293,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
}
|
||||
|
||||
private String decode(String source) {
|
||||
if (source.length() == 0 || (source.indexOf('%') < 0)) {
|
||||
if (source.isEmpty() || (source.indexOf('%') < 0)) {
|
||||
return source;
|
||||
}
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(source.length());
|
||||
@@ -347,7 +347,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.name.length() == 0;
|
||||
return this.name.isEmpty();
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
|
||||
@@ -120,7 +120,7 @@ class RelaxedConversionService implements ConversionService {
|
||||
|
||||
@Override
|
||||
public T convert(String source) {
|
||||
if (source.length() == 0) {
|
||||
if (source.isEmpty()) {
|
||||
// It's an empty enum identifier: reset the enum value to null.
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -206,14 +206,14 @@ public class ConfigurationWarningsApplicationContextInitializer
|
||||
}
|
||||
|
||||
private boolean isProblematicPackage(String scannedPackage) {
|
||||
if (scannedPackage == null || scannedPackage.length() == 0) {
|
||||
if (scannedPackage == null || scannedPackage.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
return PROBLEM_PACKAGES.contains(scannedPackage);
|
||||
}
|
||||
|
||||
private String getDisplayName(String scannedPackage) {
|
||||
if (scannedPackage == null || scannedPackage.length() == 0) {
|
||||
if (scannedPackage == null || scannedPackage.isEmpty()) {
|
||||
return "the default package";
|
||||
}
|
||||
return "'" + scannedPackage + "'";
|
||||
|
||||
Reference in New Issue
Block a user