Skip to content

Commit

Permalink
Use Java 17 switch statements (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacey-sooty authored Oct 6, 2024
1 parent d08557a commit 2342fe1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,10 @@ public class FastDownloadDependencySet implements NativeDependencySet, SourceCon

public void addConfiguration(ArtifactType type, Configuration configuration) {
switch (type) {
case SOURCES:
sourcesConfiguration.extendsFrom(configuration);
break;
case HEADERS:
headerConfiguration.extendsFrom(configuration);
break;
case LINK:
linkConfiguration.extendsFrom(configuration);
break;
case RUNTIME:
runtimeConfiguration.extendsFrom(configuration);
break;

default:
break;
case SOURCES -> sourcesConfiguration.extendsFrom(configuration);
case HEADERS -> headerConfiguration.extendsFrom(configuration);
case LINK -> linkConfiguration.extendsFrom(configuration);
case RUNTIME -> runtimeConfiguration.extendsFrom(configuration);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,36 @@
public class VendorParsingException extends Exception {
public VendorParsingException(String file, VendorParsingError error) {
switch (error) {
case NoMavenUrl:
case NoMavenUrl -> {
System.err.println("The vendordep " + file + " is missing the required maven url.");
break;

case MissingCppDeps:
}
case MissingCppDeps -> {
System.err.println("The vendordep " + file + " is missing the required C++ dependencies key.");
System.err.println("If you would not like to declare any Cpp deps use an empty list.");
break;

case MissingJniDeps:
}
case MissingJniDeps -> {
System.err.println("The vendordep " + file + " is missing the required Jni dependencies key.");
System.err.println("If you would not like to declare any Jni deps use an empty list.");
break;

case MissingJavaDeps:
}
case MissingJavaDeps -> {
System.err.println("The vendordep " + file + " is missing the required Java dependencies key.");
System.err.println("If you would not like to declare any Java deps use an empty list.");
break;

default:
throw new BuildException(
"Unhandled case in VendorParsingException. This is a bug and should be reported",
new Exception());
}
default -> throw new BuildException(
"Unhandled case in VendorParsingException. This is a bug and should be reported",
new Exception());
}
}

// should only be called if we don't have access to a name yet
public VendorParsingException(VendorParsingError error) {
switch (error) {
case MissingName:
case MissingName -> {
System.err.println("One of the vendordep files does not have a name");
break;

default:
throw new BuildException(
"Unhandled case in VendorParsingException. This is a bug and should be reported",
new Exception());
}
default -> throw new BuildException(
"Unhandled case in VendorParsingException. This is a bug and should be reported",
new Exception());
}
}
}

0 comments on commit 2342fe1

Please sign in to comment.