Use .isEmpty() where feasible

See gh-38739
This commit is contained in:
Yanming Zhou
2023-12-19 22:27:26 -08:00
committed by Phillip Webb
parent d3af5cce73
commit ac18e3015c
18 changed files with 31 additions and 31 deletions

View File

@@ -345,7 +345,7 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor {
}
StringBuilder result = new StringBuilder();
for (Object item : list) {
result.append((result.length() != 0) ? "," : "");
result.append((!result.isEmpty()) ? "," : "");
result.append(item);
}
return result.toString();

View File

@@ -173,7 +173,7 @@ public class JSONStringer {
* @throws JSONException if processing of json failed
*/
JSONStringer open(Scope empty, String openBracket) throws JSONException {
if (this.stack.isEmpty() && this.out.length() > 0) {
if (this.stack.isEmpty() && !this.out.isEmpty()) {
throw new JSONException("Nesting problem: multiple top-level roots");
}
beforeValue();
@@ -423,7 +423,7 @@ public class JSONStringer {
*/
@Override
public String toString() {
return this.out.length() == 0 ? null : this.out.toString();
return this.out.isEmpty() ? null : this.out.toString();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@ public final class ItemMetadata implements Comparable<ItemMetadata> {
fullName.append(prefix);
}
if (name != null) {
if (fullName.length() > 0) {
if (!fullName.isEmpty()) {
fullName.append('.');
}
fullName.append(ConfigurationMetadata.toDashedCase(name));

View File

@@ -227,7 +227,7 @@ public abstract class AbstractAotMojo extends AbstractDependencyFilterMojo {
}
boolean hasReportedErrors() {
return this.message.length() > 0;
return !this.message.isEmpty();
}
@Override

View File

@@ -329,7 +329,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
try {
StringBuilder classpath = new StringBuilder();
for (URL ele : getClassPathUrls()) {
if (classpath.length() > 0) {
if (!classpath.isEmpty()) {
classpath.append(File.pathSeparator);
}
classpath.append(new File(ele.toURI()));

View File

@@ -98,7 +98,7 @@ final class CommandLineBuilder {
static String build(List<URL> classpathElements) {
StringBuilder classpath = new StringBuilder();
for (URL element : classpathElements) {
if (classpath.length() > 0) {
if (!classpath.isEmpty()) {
classpath.append(File.pathSeparator);
}
classpath.append(toFile(element));