diff --git a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java index 548344b731f..eb16949b5ac 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 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. @@ -70,27 +70,18 @@ public class CheckClasspathForProhibitedDependencies extends DefaultTask { private boolean prohibited(ModuleVersionIdentifier id) { String group = id.getGroup(); - if (group.equals("javax.batch")) { - return false; - } - if (group.equals("javax.cache")) { - return false; - } - if (group.equals("javax.money")) { - return false; - } - if (group.equals("org.codehaus.groovy")) { - return true; - } - if (group.equals("org.eclipse.jetty.toolchain")) { - return true; + switch (group) { + case "javax.batch", "javax.cache", "javax.money" -> { + return false; + } + case "commons-logging", "org.codehaus.groovy", "org.eclipse.jetty.toolchain", + "org.apache.geronimo.specs" -> { + return true; + } } if (group.startsWith("javax")) { return true; } - if (group.equals("commons-logging")) { - return true; - } if (group.equals("org.slf4j") && id.getName().equals("jcl-over-slf4j")) { return true; } @@ -100,10 +91,7 @@ public class CheckClasspathForProhibitedDependencies extends DefaultTask { if (group.equals("org.apache.geronimo.specs")) { return true; } - if (group.equals("com.sun.activation")) { - return true; - } - return false; + return group.equals("com.sun.activation"); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtensionForkParameterizedTests.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtensionForkParameterizedTests.java index 2a1bc4f47e5..c2ddf1b7708 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtensionForkParameterizedTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtensionForkParameterizedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 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. @@ -37,14 +37,10 @@ class ModifiedClassPathExtensionForkParameterizedTests { @ParameterizedTest @ValueSource(strings = { "one", "two", "three" }) void testIsInvokedOnceForEachArgument(String argument) { - if (argument.equals("one")) { - assertThat(arguments).isEmpty(); - } - else if (argument.equals("two")) { - assertThat(arguments).doesNotContain("two", "three"); - } - else if (argument.equals("three")) { - assertThat(arguments).doesNotContain("three"); + switch (argument) { + case "one" -> assertThat(arguments).isEmpty(); + case "two" -> assertThat(arguments).doesNotContain("two", "three"); + case "three" -> assertThat(arguments).doesNotContain("three"); } arguments.add(argument); }