diff --git a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/PluginXmlParser.java b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/PluginXmlParser.java index fddd516374..35e163b82d 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/PluginXmlParser.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/PluginXmlParser.java @@ -60,7 +60,7 @@ class PluginXmlParser { private String textAt(String path, Node source) throws XPathExpressionException { String text = this.xpath.evaluate(path + "/text()", source); - return (text.length() == 0) ? null : text; + return text.isEmpty() ? null : text; } private List parseMojos(Node plugin) throws XPathExpressionException { @@ -81,12 +81,12 @@ class PluginXmlParser { Map userProperties = new HashMap<>(); for (Node parameterConfigurationNode : nodesAt("configuration/*", mojoNode)) { String userProperty = parameterConfigurationNode.getTextContent(); - if (userProperty != null && userProperty.length() > 0) { + if (userProperty != null && !userProperty.isEmpty()) { userProperties.put(parameterConfigurationNode.getNodeName(), userProperty.replace("${", "`").replace("}", "`")); } Node defaultValueAttribute = parameterConfigurationNode.getAttributes().getNamedItem("default-value"); - if (defaultValueAttribute != null && defaultValueAttribute.getTextContent().length() > 0) { + if (defaultValueAttribute != null && !defaultValueAttribute.getTextContent().isEmpty()) { defaultValues.put(parameterConfigurationNode.getNodeName(), defaultValueAttribute.getTextContent()); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/TotalProgressBar.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/TotalProgressBar.java index 6d828437b8..b478efd33d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/TotalProgressBar.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/TotalProgressBar.java @@ -63,7 +63,7 @@ public class TotalProgressBar implements Consumer { public TotalProgressBar(String prefix, char progressChar, boolean bookend, PrintStream out) { this.progressChar = progressChar; this.bookend = bookend; - if (prefix != null && prefix.length() > 0) { + if (prefix != null && !prefix.isEmpty()) { out.print(prefix); out.print(" "); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java index 21039f7af1..844c5c460a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -154,7 +154,7 @@ class TypeUtils { if (((TypeElement) this.types.asElement(type)).getQualifiedName().contentEquals(Collection.class.getName())) { DeclaredType declaredType = (DeclaredType) type; // raw type, just "Collection" - if (declaredType.getTypeArguments().size() == 0) { + if (declaredType.getTypeArguments().isEmpty()) { return this.types.getDeclaredType(this.env.getElementUtils().getTypeElement(Object.class.getName())); } // return type argument to Collection<...> diff --git a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/Context.java b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/Context.java index 9b6edf3b45..d072d120aa 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/Context.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/Context.java @@ -62,7 +62,7 @@ class Context { return null; } String relativePath = sourcePath.substring(workingPath.length() + 1); - return (relativePath.length() > 0) ? relativePath : null; + return !relativePath.isEmpty() ? relativePath : null; } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiPropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiPropertySource.java index 4c0cce7d18..1553ead56d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiPropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiPropertySource.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -162,7 +162,7 @@ public class AnsiPropertySource extends PropertySource { return false; } } - return postfix.length() > 0; + return !postfix.isEmpty(); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-integration/src/test/java/smoketest/integration/producer/ProducerApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-integration/src/test/java/smoketest/integration/producer/ProducerApplication.java index 3dc4a689c2..162f9075ec 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-integration/src/test/java/smoketest/integration/producer/ProducerApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-integration/src/test/java/smoketest/integration/producer/ProducerApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -40,7 +40,7 @@ public class ProducerApplication implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { this.serviceProperties.getInputDir().mkdirs(); - if (args.getNonOptionArgs().size() > 0) { + if (!args.getNonOptionArgs().isEmpty()) { FileOutputStream stream = new FileOutputStream( new File(this.serviceProperties.getInputDir(), "data" + System.currentTimeMillis() + ".txt")); for (String arg : args.getNonOptionArgs()) { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/producer/ProducerApplication.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/producer/ProducerApplication.java index 7cee22afb6..f33e25bedb 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/producer/ProducerApplication.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/producer/ProducerApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -40,7 +40,7 @@ public class ProducerApplication implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { this.serviceProperties.getInputDir().mkdirs(); - if (args.getNonOptionArgs().size() > 0) { + if (!args.getNonOptionArgs().isEmpty()) { FileOutputStream stream = new FileOutputStream( new File(this.serviceProperties.getInputDir(), "data" + System.currentTimeMillis() + ".txt")); for (String arg : args.getNonOptionArgs()) {