Replace 'String.length() == 0' with 'String.isEmpty()'

See gh-8103
pull/7973/merge
Johnny Lim 8 years ago 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) { private Map<String, Object> sanitize(String prefix, Map<String, Object> map) {
for (Map.Entry<String, Object> entry : map.entrySet()) { for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String qualifiedKey = (prefix.length() == 0 ? prefix : prefix + ".") + key; String qualifiedKey = (prefix.isEmpty() ? prefix : prefix + ".") + key;
Object value = entry.getValue(); Object value = entry.getValue();
if (value instanceof Map) { if (value instanceof Map) {
map.put(key, sanitize(qualifiedKey, (Map<String, Object>) value)); map.put(key, sanitize(qualifiedKey, (Map<String, Object>) value));

@ -69,7 +69,7 @@ public abstract class AbstractMvcEndpoint extends WebMvcConfigurerAdapter
@PostConstruct @PostConstruct
private void validate() { private void validate() {
Assert.notNull(this.path, "Path must not be null"); 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"); "Path must start with / or be empty");
} }

@ -770,7 +770,7 @@ public class RabbitProperties {
int hostIndex = input.indexOf("/"); int hostIndex = input.indexOf("/");
if (hostIndex >= 0) { if (hostIndex >= 0) {
this.virtualHost = input.substring(hostIndex + 1); this.virtualHost = input.substring(hostIndex + 1);
if (this.virtualHost.length() == 0) { if (this.virtualHost.isEmpty()) {
this.virtualHost = "/"; this.virtualHost = "/";
} }
input = input.substring(0, hostIndex); input = input.substring(0, hostIndex);

@ -47,7 +47,7 @@ public class H2ConsoleProperties {
@PostConstruct @PostConstruct
private void validate() { private void validate() {
Assert.notNull(this.path, "Path must not be null"); 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"); "Path must start with / or be empty");
} }

@ -44,7 +44,7 @@ public class WebServicesProperties {
@PostConstruct @PostConstruct
private void validate() { private void validate() {
Assert.notNull(this.path, "Path must not be null"); 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"); "Path must start with / or be empty");
} }

@ -121,7 +121,7 @@ final class AsciiBytes {
} }
public AsciiBytes append(String string) { public AsciiBytes append(String string) {
if (string == null || string.length() == 0) { if (string == null || string.isEmpty()) {
return this; return this;
} }
return append(string.getBytes(UTF_8)); return append(string.getBytes(UTF_8));

@ -293,7 +293,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
} }
private String decode(String source) { private String decode(String source) {
if (source.length() == 0 || (source.indexOf('%') < 0)) { if (source.isEmpty() || (source.indexOf('%') < 0)) {
return source; return source;
} }
ByteArrayOutputStream bos = new ByteArrayOutputStream(source.length()); ByteArrayOutputStream bos = new ByteArrayOutputStream(source.length());
@ -347,7 +347,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
} }
public boolean isEmpty() { public boolean isEmpty() {
return this.name.length() == 0; return this.name.isEmpty();
} }
public String getContentType() { public String getContentType() {

@ -120,7 +120,7 @@ class RelaxedConversionService implements ConversionService {
@Override @Override
public T convert(String source) { public T convert(String source) {
if (source.length() == 0) { if (source.isEmpty()) {
// It's an empty enum identifier: reset the enum value to null. // It's an empty enum identifier: reset the enum value to null.
return null; return null;
} }

@ -206,14 +206,14 @@ public class ConfigurationWarningsApplicationContextInitializer
} }
private boolean isProblematicPackage(String scannedPackage) { private boolean isProblematicPackage(String scannedPackage) {
if (scannedPackage == null || scannedPackage.length() == 0) { if (scannedPackage == null || scannedPackage.isEmpty()) {
return true; return true;
} }
return PROBLEM_PACKAGES.contains(scannedPackage); return PROBLEM_PACKAGES.contains(scannedPackage);
} }
private String getDisplayName(String scannedPackage) { private String getDisplayName(String scannedPackage) {
if (scannedPackage == null || scannedPackage.length() == 0) { if (scannedPackage == null || scannedPackage.isEmpty()) {
return "the default package"; return "the default package";
} }
return "'" + scannedPackage + "'"; return "'" + scannedPackage + "'";

Loading…
Cancel
Save