Skip to content

Commit 6efb64a

Browse files
committed
Cleanup java sources
1. use `StandardCharsets.UTF_8` where feasible 2. use `.isEmpty()` where feasible 3. remove unnecessary `static` modifier of inner record or interface type 4. remove unnecessary `final` modifier of private or static method 5. remove unnecessary `toString()`
1 parent 0fe7d78 commit 6efb64a

File tree

50 files changed

+66
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+66
-66
lines changed

buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void checkArchitecture() throws IOException {
8989
if (!violations.isEmpty()) {
9090
StringBuilder report = new StringBuilder();
9191
for (EvaluationResult violation : violations) {
92-
report.append(violation.getFailureReport().toString());
92+
report.append(violation.getFailureReport());
9393
report.append(String.format("%n"));
9494
}
9595
Files.writeString(outputFile.toPath(), report.toString(), StandardOpenOption.CREATE,

buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/AutoConfigurationPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private Provider<AutoConfigurationImports> autoConfigurationImports(Project proj
154154
});
155155
}
156156

157-
private static record AutoConfigurationImports(Path importsFile, List<String> imports) {
157+
private record AutoConfigurationImports(Path importsFile, List<String> imports) {
158158

159159
}
160160

buildSrc/src/main/java/org/springframework/boot/build/bom/BomPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ private void addClassifiedManagedDependencies(Node dependencyManagement) {
221221
.collect(Collectors.toSet());
222222
Node target = dependency;
223223
for (String classifier : classifiers) {
224-
if (classifier.length() > 0) {
224+
if (!classifier.isEmpty()) {
225225
if (target == null) {
226226
target = new Node(null, "dependency");
227227
target.appendNode("groupId", groupId);

buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/MavenMetadataVersionResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private URI normalize(URI uri) {
6969
if ("/".equals(uri.getPath())) {
7070
return uri;
7171
}
72-
return URI.create(uri.toString() + "/");
72+
return URI.create(uri + "/");
7373
}
7474

7575
@Override

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static class TestPathMatcher implements PathMapper {
125125
@Override
126126
public String getRootPath(EndpointId endpointId) {
127127
if (endpointId.toString().endsWith("one")) {
128-
return "1/" + endpointId.toString();
128+
return "1/" + endpointId;
129129
}
130130
return null;
131131
}

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private void assertNoDuplicateOperations(EndpointBean endpointBean, MultiValueMa
234234
String extensionBeanNames = extensions.stream()
235235
.map(ExtensionBean::getBeanName)
236236
.collect(Collectors.joining(", "));
237-
throw new IllegalStateException("Unable to map duplicate endpoint operations: " + duplicates.toString()
237+
throw new IllegalStateException("Unable to map duplicate endpoint operations: " + duplicates
238238
+ " to " + endpointBean.getBeanName()
239239
+ (extensions.isEmpty() ? "" : " (" + extensionBeanNames + ")"));
240240
}

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private Object getContributor(String[] path, int pathOffset) {
127127
private String getName(String[] path, int pathOffset) {
128128
StringBuilder name = new StringBuilder();
129129
while (pathOffset < path.length) {
130-
name.append((name.length() != 0) ? "/" : "");
130+
name.append((!name.isEmpty()) ? "/" : "");
131131
name.append(path[pathOffset]);
132132
pathOffset++;
133133
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ private String createOnBeanNoMatchReason(MatchResult matchResult) {
332332

333333
private void appendMessageForNoMatches(StringBuilder reason, Collection<String> unmatched, String description) {
334334
if (!unmatched.isEmpty()) {
335-
if (reason.length() > 0) {
335+
if (!reason.isEmpty()) {
336336
reason.append(" and ");
337337
}
338338
reason.append("did not find any beans ");
@@ -347,7 +347,7 @@ private String createOnMissingBeanNoMatchReason(MatchResult matchResult) {
347347
appendMessageForMatches(reason, matchResult.getMatchedAnnotations(), "annotated with");
348348
appendMessageForMatches(reason, matchResult.getMatchedTypes(), "of type");
349349
if (!matchResult.getMatchedNames().isEmpty()) {
350-
if (reason.length() > 0) {
350+
if (!reason.isEmpty()) {
351351
reason.append(" and ");
352352
}
353353
reason.append("found beans named ");
@@ -360,7 +360,7 @@ private void appendMessageForMatches(StringBuilder reason, Map<String, Collectio
360360
String description) {
361361
if (!matches.isEmpty()) {
362362
matches.forEach((key, value) -> {
363-
if (reason.length() > 0) {
363+
if (!reason.isEmpty()) {
364364
reason.append(" and ");
365365
}
366366
reason.append("found beans ");

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ protected File getHomeDirectory() {
144144
}
145145

146146
@SafeVarargs
147-
private final File getHomeDirectory(Supplier<String>... pathSuppliers) {
147+
private File getHomeDirectory(Supplier<String>... pathSuppliers) {
148148
for (Supplier<String> pathSupplier : pathSuppliers) {
149149
String path = pathSupplier.get();
150150
if (StringUtils.hasText(path)) {

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.net.URL;
2424
import java.net.URLClassLoader;
2525
import java.net.URLDecoder;
26+
import java.nio.charset.StandardCharsets;
2627
import java.util.ArrayList;
2728
import java.util.Collection;
2829
import java.util.Collections;
@@ -159,7 +160,7 @@ private static List<URL> getUrlsFromManifestClassPathAttribute(URL jarUrl, JarFi
159160
urls.add(referenced);
160161
}
161162
else {
162-
referenced = new URL(jarUrl, URLDecoder.decode(entry, "UTF-8"));
163+
referenced = new URL(jarUrl, URLDecoder.decode(entry, StandardCharsets.UTF_8));
163164
if (new File(referenced.getFile()).exists()) {
164165
urls.add(referenced);
165166
}

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/AssertProviderApplicationContextInvocationHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private Object invokeApplicationContextMethod(Method method, Object[] args) thro
153153

154154
private ApplicationContext getStartedApplicationContext() {
155155
if (this.startupFailure != null) {
156-
throw new IllegalStateException(toString() + " failed to start", this.startupFailure);
156+
throw new IllegalStateException(this + " failed to start", this.startupFailure);
157157
}
158158
return this.applicationContext;
159159
}

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ private RequestEntity<?> createRequestEntityWithRootAppliedUri(RequestEntity<?>
956956
private URI applyRootUriIfNecessary(URI uri) {
957957
UriTemplateHandler uriTemplateHandler = this.restTemplate.getUriTemplateHandler();
958958
if ((uriTemplateHandler instanceof RootUriTemplateHandler rootHandler) && uri.toString().startsWith("/")) {
959-
return URI.create(rootHandler.getRootUri() + uri.toString());
959+
return URI.create(rootHandler.getRootUri() + uri);
960960
}
961961
return uri;
962962
}

spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/AbstractJsonMarshalTesterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void parseMapShouldReturnContent() throws Exception {
169169
assertThat(tester.parse(MAP_JSON)).asMap().containsEntry("a", OBJECT);
170170
}
171171

172-
protected static final ExampleObject createExampleObject(String name, int age) {
172+
protected static ExampleObject createExampleObject(String name, int age) {
173173
ExampleObject exampleObject = new ExampleObject();
174174
exampleObject.setName(name);
175175
exampleObject.setAge(age);

spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/web/SpringBootMockServletContextTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.net.MalformedURLException;
2121
import java.net.URL;
2222
import java.net.URLDecoder;
23+
import java.nio.charset.StandardCharsets;
2324

2425
import jakarta.servlet.ServletContext;
2526
import org.junit.jupiter.api.Test;
@@ -80,7 +81,7 @@ protected String getResourceLocation(String path) {
8081
};
8182
URL resource = context.getResource("/");
8283
assertThat(resource).isNotNull();
83-
File file = new File(URLDecoder.decode(resource.getPath(), "UTF-8"));
84+
File file = new File(URLDecoder.decode(resource.getPath(), StandardCharsets.UTF_8));
8485
assertThat(file).exists().isDirectory();
8586
String[] contents = file.list((dir, name) -> !(".".equals(name) || "..".equals(name)));
8687
assertThat(contents).isNotNull();

spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ List<ContainerConnectionSource<?>> getSources() {
9191
* Relevant details from {@link ContainerConnectionSource} used as a
9292
* MergedContextConfiguration cache key.
9393
*/
94-
private static record CacheKey(String connectionName, Set<Class<?>> connectionDetailsTypes,
95-
Container<?> container) {
94+
private record CacheKey(String connectionName, Set<Class<?>> connectionDetailsTypes,
95+
Container<?> container) {
9696

9797
CacheKey(ContainerConnectionSource<?> source) {
9898
this(source.getConnectionName(), source.getConnectionDetailsTypes(), source.getContainerSupplier().get());

spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/ImportTestcontainersTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ interface ContainerDefinitions {
162162
}
163163

164164
@Retention(RetentionPolicy.RUNTIME)
165-
static @interface ContainerAnnotation {
165+
@interface ContainerAnnotation {
166166

167167
}
168168

spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySourceAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ RedisContainer redisContainer(DynamicPropertyRegistry properties) {
6868
}
6969

7070
@ConfigurationProperties("container")
71-
static record ContainerProperties(int port) {
71+
record ContainerProperties(int port) {
7272
}
7373

7474
static class TestBean {

spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ private String toCommaDelimitedString(List<Object> list) {
345345
}
346346
StringBuilder result = new StringBuilder();
347347
for (Object item : list) {
348-
result.append((result.length() != 0) ? "," : "");
348+
result.append((!result.isEmpty()) ? "," : "");
349349
result.append(item);
350350
}
351351
return result.toString();

spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONStringer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public JSONStringer endObject() throws JSONException {
173173
* @throws JSONException if processing of json failed
174174
*/
175175
JSONStringer open(Scope empty, String openBracket) throws JSONException {
176-
if (this.stack.isEmpty() && this.out.length() > 0) {
176+
if (this.stack.isEmpty() && !this.out.isEmpty()) {
177177
throw new JSONException("Nesting problem: multiple top-level roots");
178178
}
179179
beforeValue();
@@ -423,7 +423,7 @@ else if (context != Scope.NULL) {
423423
*/
424424
@Override
425425
public String toString() {
426-
return this.out.length() == 0 ? null : this.out.toString();
426+
return this.out.isEmpty() ? null : this.out.toString();
427427
}
428428

429429
}

spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private String buildName(String prefix, String name) {
6565
fullName.append(prefix);
6666
}
6767
if (name != null) {
68-
if (fullName.length() > 0) {
68+
if (!fullName.isEmpty()) {
6969
fullName.append('.');
7070
}
7171
fullName.append(ConfigurationMetadata.toDashedCase(name));

spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/TestPrintStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*/
3838
class TestPrintStream extends PrintStream implements AssertProvider<PrintStreamAssert> {
3939

40-
private final Class<? extends Object> testClass;
40+
private final Class<?> testClass;
4141

4242
TestPrintStream(Object testInstance) {
4343
super(new ByteArrayOutputStream());

spring-boot-project/spring-boot-tools/spring-boot-loader-classic/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.net.URL;
2727
import java.net.URLConnection;
2828
import java.net.URLDecoder;
29+
import java.nio.charset.StandardCharsets;
2930
import java.util.ArrayList;
3031
import java.util.Collections;
3132
import java.util.Iterator;
@@ -227,7 +228,7 @@ private InputStream getResource(String config) throws Exception {
227228

228229
private String handleUrl(String path) throws UnsupportedEncodingException {
229230
if (path.startsWith("jar:file:") || path.startsWith("file:")) {
230-
path = URLDecoder.decode(path, "UTF-8");
231+
path = URLDecoder.decode(path, StandardCharsets.UTF_8);
231232
if (path.startsWith("file:")) {
232233
path = path.substring("file:".length());
233234
if (path.startsWith("//")) {

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.net.URLConnection;
2727
import java.net.URLEncoder;
2828
import java.net.URLStreamHandler;
29+
import java.nio.charset.StandardCharsets;
2930
import java.security.Permission;
3031

3132
/**
@@ -318,13 +319,8 @@ private void write(String source, ByteArrayOutputStream outputStream) {
318319
for (int i = 0; i < length; i++) {
319320
int c = source.charAt(i);
320321
if (c > 127) {
321-
try {
322-
String encoded = URLEncoder.encode(String.valueOf((char) c), "UTF-8");
323-
write(encoded, outputStream);
324-
}
325-
catch (UnsupportedEncodingException ex) {
326-
throw new IllegalStateException(ex);
327-
}
322+
String encoded = URLEncoder.encode(String.valueOf((char) c), StandardCharsets.UTF_8);
323+
write(encoded, outputStream);
328324
}
329325
else {
330326
if (c == '%') {

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractAotMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
227227
}
228228

229229
boolean hasReportedErrors() {
230-
return this.message.length() > 0;
230+
return !this.message.isEmpty();
231231
}
232232

233233
@Override

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ private void addClasspath(List<String> args) throws MojoExecutionException {
342342
try {
343343
StringBuilder classpath = new StringBuilder();
344344
for (URL ele : getClassPathUrls()) {
345-
if (classpath.length() > 0) {
345+
if (!classpath.isEmpty()) {
346346
classpath.append(File.pathSeparator);
347347
}
348348
classpath.append(new File(ele.toURI()));

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/CommandLineBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static class ClasspathBuilder {
9898
static String build(List<URL> classpathElements) {
9999
StringBuilder classpath = new StringBuilder();
100100
for (URL element : classpathElements) {
101-
if (classpath.length() > 0) {
101+
if (!classpath.isEmpty()) {
102102
classpath.append(File.pathSeparator);
103103
}
104104
classpath.append(toFile(element));

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private void appendContext(StringBuilder message) {
118118
}
119119
append(context, "started by ", () -> System.getProperty("user.name"));
120120
append(context, "in ", () -> System.getProperty("user.dir"));
121-
if (context.length() > 0) {
121+
if (!context.isEmpty()) {
122122
message.append(" (");
123123
message.append(context);
124124
message.append(")");
@@ -140,7 +140,7 @@ private void append(StringBuilder message, String prefix, Callable<Object> call,
140140
value = defaultValue;
141141
}
142142
if (StringUtils.hasLength(value)) {
143-
message.append((message.length() > 0) ? " " : "");
143+
message.append((!message.isEmpty()) ? " " : "");
144144
message.append(prefix);
145145
message.append(value);
146146
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DataObjectPropertyName.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static String toDashedForm(String name) {
5252
}
5353
else {
5454
ch = (ch != '_') ? ch : '-';
55-
if (Character.isUpperCase(ch) && result.length() > 0 && result.charAt(result.length() - 1) != '-') {
55+
if (Character.isUpperCase(ch) && !result.isEmpty() && result.charAt(result.length() - 1) != '-') {
5656
result.append('-');
5757
}
5858
result.append(Character.toLowerCase(ch));

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private boolean isScalarValue(ConfigurationPropertySource source, ConfigurationP
211211
private String getKeyName(ConfigurationPropertyName name) {
212212
StringBuilder result = new StringBuilder();
213213
for (int i = this.root.getNumberOfElements(); i < name.getNumberOfElements(); i++) {
214-
if (result.length() != 0) {
214+
if (!result.isEmpty()) {
215215
result.append('.');
216216
}
217217
result.append(name.getElement(i, Form.ORIGINAL));

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ private String buildToString() {
543543
StringBuilder result = new StringBuilder(elements * 8);
544544
for (int i = 0; i < elements; i++) {
545545
boolean indexed = isIndexed(i);
546-
if (result.length() > 0 && !indexed) {
546+
if (!result.isEmpty() && !indexed) {
547547
result.append('.');
548548
}
549549
if (indexed) {
@@ -615,7 +615,7 @@ private static Elements elementsOf(CharSequence name, boolean returnNullIfInvali
615615
Assert.isTrue(returnNullIfInvalid, "Name must not be null");
616616
return null;
617617
}
618-
if (name.length() == 0) {
618+
if (name.isEmpty()) {
619619
return Elements.EMPTY;
620620
}
621621
if (name.charAt(0) == '.' || name.charAt(name.length() - 1) == '.') {
@@ -674,7 +674,7 @@ public static ConfigurationPropertyName adapt(CharSequence name, char separator)
674674
static ConfigurationPropertyName adapt(CharSequence name, char separator,
675675
Function<CharSequence, CharSequence> elementValueProcessor) {
676676
Assert.notNull(name, "Name must not be null");
677-
if (name.length() == 0) {
677+
if (name.isEmpty()) {
678678
return EMPTY;
679679
}
680680
Elements elements = new ElementsParser(name, separator).parse(elementValueProcessor);

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private String convertName(ConfigurationPropertyName name) {
5757
private String convertName(ConfigurationPropertyName name, int numberOfElements) {
5858
StringBuilder result = new StringBuilder();
5959
for (int i = 0; i < numberOfElements; i++) {
60-
if (result.length() > 0) {
60+
if (!result.isEmpty()) {
6161
result.append('_');
6262
}
6363
result.append(name.getElement(i, Form.UNIFORM).toUpperCase(Locale.ENGLISH));
@@ -68,7 +68,7 @@ private String convertName(ConfigurationPropertyName name, int numberOfElements)
6868
private String convertLegacyName(ConfigurationPropertyName name) {
6969
StringBuilder result = new StringBuilder();
7070
for (int i = 0; i < name.getNumberOfElements(); i++) {
71-
if (result.length() > 0) {
71+
if (!result.isEmpty()) {
7272
result.append('_');
7373
}
7474
result.append(convertLegacyNameElement(name.getElement(i, Form.ORIGINAL)));

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ else if (current == '\\') {
158158
}
159159
index++;
160160
}
161-
if (build.length() > 0) {
161+
if (!build.isEmpty()) {
162162
list.add(build.toString().trim());
163163
}
164164
return list;

0 commit comments

Comments
 (0)