mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Use 'switch' instead of 'if'
See gh-40985
This commit is contained in:
parent
9ddb7b0238
commit
2c5934dab2
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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) {
|
private boolean prohibited(ModuleVersionIdentifier id) {
|
||||||
String group = id.getGroup();
|
String group = id.getGroup();
|
||||||
if (group.equals("javax.batch")) {
|
switch (group) {
|
||||||
return false;
|
case "javax.batch", "javax.cache", "javax.money" -> {
|
||||||
}
|
return false;
|
||||||
if (group.equals("javax.cache")) {
|
}
|
||||||
return false;
|
case "commons-logging", "org.codehaus.groovy", "org.eclipse.jetty.toolchain",
|
||||||
}
|
"org.apache.geronimo.specs" -> {
|
||||||
if (group.equals("javax.money")) {
|
return true;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
if (group.equals("org.codehaus.groovy")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (group.equals("org.eclipse.jetty.toolchain")) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (group.startsWith("javax")) {
|
if (group.startsWith("javax")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (group.equals("commons-logging")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (group.equals("org.slf4j") && id.getName().equals("jcl-over-slf4j")) {
|
if (group.equals("org.slf4j") && id.getName().equals("jcl-over-slf4j")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -100,10 +91,7 @@ public class CheckClasspathForProhibitedDependencies extends DefaultTask {
|
|||||||
if (group.equals("org.apache.geronimo.specs")) {
|
if (group.equals("org.apache.geronimo.specs")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (group.equals("com.sun.activation")) {
|
return group.equals("com.sun.activation");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -37,14 +37,10 @@ class ModifiedClassPathExtensionForkParameterizedTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(strings = { "one", "two", "three" })
|
@ValueSource(strings = { "one", "two", "three" })
|
||||||
void testIsInvokedOnceForEachArgument(String argument) {
|
void testIsInvokedOnceForEachArgument(String argument) {
|
||||||
if (argument.equals("one")) {
|
switch (argument) {
|
||||||
assertThat(arguments).isEmpty();
|
case "one" -> assertThat(arguments).isEmpty();
|
||||||
}
|
case "two" -> assertThat(arguments).doesNotContain("two", "three");
|
||||||
else if (argument.equals("two")) {
|
case "three" -> assertThat(arguments).doesNotContain("three");
|
||||||
assertThat(arguments).doesNotContain("two", "three");
|
|
||||||
}
|
|
||||||
else if (argument.equals("three")) {
|
|
||||||
assertThat(arguments).doesNotContain("three");
|
|
||||||
}
|
}
|
||||||
arguments.add(argument);
|
arguments.add(argument);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user