Skip to content

Commit 2342fe1

Browse files
authored
Use Java 17 switch statements (#221)
1 parent d08557a commit 2342fe1

File tree

2 files changed

+20
-38
lines changed

2 files changed

+20
-38
lines changed

src/main/java/edu/wpi/first/nativeutils/dependencies/FastDownloadDependencySet.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,10 @@ public class FastDownloadDependencySet implements NativeDependencySet, SourceCon
1818

1919
public void addConfiguration(ArtifactType type, Configuration configuration) {
2020
switch (type) {
21-
case SOURCES:
22-
sourcesConfiguration.extendsFrom(configuration);
23-
break;
24-
case HEADERS:
25-
headerConfiguration.extendsFrom(configuration);
26-
break;
27-
case LINK:
28-
linkConfiguration.extendsFrom(configuration);
29-
break;
30-
case RUNTIME:
31-
runtimeConfiguration.extendsFrom(configuration);
32-
break;
33-
34-
default:
35-
break;
21+
case SOURCES -> sourcesConfiguration.extendsFrom(configuration);
22+
case HEADERS -> headerConfiguration.extendsFrom(configuration);
23+
case LINK -> linkConfiguration.extendsFrom(configuration);
24+
case RUNTIME -> runtimeConfiguration.extendsFrom(configuration);
3625
}
3726
}
3827

src/main/java/edu/wpi/first/nativeutils/vendordeps/VendorParsingException.java

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,36 @@
55
public class VendorParsingException extends Exception {
66
public VendorParsingException(String file, VendorParsingError error) {
77
switch (error) {
8-
case NoMavenUrl:
8+
case NoMavenUrl -> {
99
System.err.println("The vendordep " + file + " is missing the required maven url.");
10-
break;
11-
12-
case MissingCppDeps:
10+
}
11+
case MissingCppDeps -> {
1312
System.err.println("The vendordep " + file + " is missing the required C++ dependencies key.");
1413
System.err.println("If you would not like to declare any Cpp deps use an empty list.");
15-
break;
16-
17-
case MissingJniDeps:
14+
}
15+
case MissingJniDeps -> {
1816
System.err.println("The vendordep " + file + " is missing the required Jni dependencies key.");
1917
System.err.println("If you would not like to declare any Jni deps use an empty list.");
20-
break;
21-
22-
case MissingJavaDeps:
18+
}
19+
case MissingJavaDeps -> {
2320
System.err.println("The vendordep " + file + " is missing the required Java dependencies key.");
2421
System.err.println("If you would not like to declare any Java deps use an empty list.");
25-
break;
26-
27-
default:
28-
throw new BuildException(
29-
"Unhandled case in VendorParsingException. This is a bug and should be reported",
30-
new Exception());
22+
}
23+
default -> throw new BuildException(
24+
"Unhandled case in VendorParsingException. This is a bug and should be reported",
25+
new Exception());
3126
}
3227
}
3328

3429
// should only be called if we don't have access to a name yet
3530
public VendorParsingException(VendorParsingError error) {
3631
switch (error) {
37-
case MissingName:
32+
case MissingName -> {
3833
System.err.println("One of the vendordep files does not have a name");
39-
break;
40-
41-
default:
42-
throw new BuildException(
43-
"Unhandled case in VendorParsingException. This is a bug and should be reported",
44-
new Exception());
34+
}
35+
default -> throw new BuildException(
36+
"Unhandled case in VendorParsingException. This is a bug and should be reported",
37+
new Exception());
4538
}
4639
}
4740
}

0 commit comments

Comments
 (0)