Skip to content

Commit 42fdd54

Browse files
committed
- Use switch instead of if
- Remove unnecessary (ub)boxing
1 parent 7c2413f commit 42fdd54

File tree

6 files changed

+17
-35
lines changed

6 files changed

+17
-35
lines changed

buildSrc/src/main/java/org/springframework/boot/build/antora/AntoraAsciidocAttributes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class AntoraAsciidocAttributes {
5656
public AntoraAsciidocAttributes(Project project, BomExtension dependencyBom,
5757
Map<String, String> dependencyVersions) {
5858
this.version = String.valueOf(project.getVersion());
59-
this.latestVersion = Boolean.valueOf(String.valueOf(project.findProperty("latestVersion")));
59+
this.latestVersion = Boolean.parseBoolean(String.valueOf(project.findProperty("latestVersion")));
6060
this.artifactRelease = ArtifactRelease.forProject(project);
6161
this.libraries = dependencyBom.getLibraries();
6262
this.dependencyVersions = dependencyVersions;

buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,36 +70,24 @@ public void checkForProhibitedDependencies() {
7070

7171
private boolean prohibited(ModuleVersionIdentifier id) {
7272
String group = id.getGroup();
73-
if (group.equals("javax.batch")) {
74-
return false;
75-
}
76-
if (group.equals("javax.cache")) {
77-
return false;
78-
}
79-
if (group.equals("javax.money")) {
80-
return false;
81-
}
82-
if (group.equals("org.codehaus.groovy")) {
83-
return true;
84-
}
85-
if (group.equals("org.eclipse.jetty.toolchain")) {
86-
return true;
73+
switch (group) {
74+
case "javax.batch", "javax.cache", "javax.money" -> {
75+
return false;
76+
}
77+
case "commons-logging", "org.codehaus.groovy", "org.eclipse.jetty.toolchain",
78+
"org.apache.geronimo.specs" -> {
79+
return true;
80+
}
8781
}
8882
if (group.startsWith("javax")) {
8983
return true;
9084
}
91-
if (group.equals("commons-logging")) {
92-
return true;
93-
}
9485
if (group.equals("org.slf4j") && id.getName().equals("jcl-over-slf4j")) {
9586
return true;
9687
}
9788
if (group.startsWith("org.jboss.spec")) {
9889
return true;
9990
}
100-
if (group.equals("org.apache.geronimo.specs")) {
101-
return true;
102-
}
10391
return group.equals("com.sun.activation");
10492
}
10593

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/InfinispanCacheConfiguration.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.IOException;
2020
import java.io.InputStream;
2121
import java.util.List;
22+
import java.util.Objects;
2223

2324
import org.infinispan.configuration.cache.ConfigurationBuilder;
2425
import org.infinispan.manager.DefaultCacheManager;
@@ -81,10 +82,7 @@ private EmbeddedCacheManager createEmbeddedCacheManager(CacheProperties cachePro
8182

8283
private org.infinispan.configuration.cache.Configuration getDefaultCacheConfiguration(
8384
ConfigurationBuilder defaultConfigurationBuilder) {
84-
if (defaultConfigurationBuilder != null) {
85-
return defaultConfigurationBuilder.build();
86-
}
87-
return new ConfigurationBuilder().build();
85+
return Objects.requireNonNullElseGet(defaultConfigurationBuilder, ConfigurationBuilder::new).build();
8886
}
8987

9088
}

spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtensionForkParameterizedTests.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,10 @@ class ModifiedClassPathExtensionForkParameterizedTests {
3737
@ParameterizedTest
3838
@ValueSource(strings = { "one", "two", "three" })
3939
void testIsInvokedOnceForEachArgument(String argument) {
40-
if (argument.equals("one")) {
41-
assertThat(arguments).isEmpty();
42-
}
43-
else if (argument.equals("two")) {
44-
assertThat(arguments).doesNotContain("two", "three");
45-
}
46-
else if (argument.equals("three")) {
47-
assertThat(arguments).doesNotContain("three");
40+
switch (argument) {
41+
case "one" -> assertThat(arguments).isEmpty();
42+
case "two" -> assertThat(arguments).doesNotContain("two", "three");
43+
case "three" -> assertThat(arguments).doesNotContain("three");
4844
}
4945
arguments.add(argument);
5046
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystemProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private PropertyResolver getPropertyResolver() {
219219
if (this.environment instanceof ConfigurableEnvironment configurableEnvironment) {
220220
PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver(
221221
configurableEnvironment.getPropertySources());
222-
resolver.setConversionService(((ConfigurableEnvironment) this.environment).getConversionService());
222+
resolver.setConversionService(configurableEnvironment.getConversionService());
223223
resolver.setIgnoreUnresolvableNestedPlaceholders(true);
224224
return resolver;
225225
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/NestedJarResourceSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protected boolean isMultiRelease() {
128128
}
129129
}
130130
}
131-
return this.multiRelease.booleanValue();
131+
return this.multiRelease;
132132
}
133133

134134
@Override

0 commit comments

Comments
 (0)