mirror of
https://github.com/apple/pkl.git
synced 2026-03-17 23:03:54 +01:00
Leverage basic Java 17 features (#451)
- Refactor code to use the following basic Java 17 features: - pattern matching for instanceof - @Serial annotation - switch expressions - enhanced switch statements - StringBuilder.isEmpty() - Replace two switch statements with simpler if statements. - Rename a few local variables.
This commit is contained in:
@@ -454,37 +454,36 @@ public final class ExecutorOptions {
|
||||
}
|
||||
|
||||
ExecutorSpiOptions toSpiOptions() {
|
||||
switch (spiOptionsVersion) {
|
||||
case -1:
|
||||
case 2:
|
||||
return new ExecutorSpiOptions2(
|
||||
allowedModules,
|
||||
allowedResources,
|
||||
environmentVariables,
|
||||
externalProperties,
|
||||
modulePath,
|
||||
rootDir,
|
||||
timeout,
|
||||
outputFormat,
|
||||
moduleCacheDir,
|
||||
projectDir,
|
||||
certificateFiles,
|
||||
certificateUris,
|
||||
testPort);
|
||||
case 1: // for testing only
|
||||
return new ExecutorSpiOptions(
|
||||
allowedModules,
|
||||
allowedResources,
|
||||
environmentVariables,
|
||||
externalProperties,
|
||||
modulePath,
|
||||
rootDir,
|
||||
timeout,
|
||||
outputFormat,
|
||||
moduleCacheDir,
|
||||
projectDir);
|
||||
default:
|
||||
throw new AssertionError("Unknown ExecutorSpiOptions version: " + spiOptionsVersion);
|
||||
}
|
||||
return switch (spiOptionsVersion) {
|
||||
case -1, 2 ->
|
||||
new ExecutorSpiOptions2(
|
||||
allowedModules,
|
||||
allowedResources,
|
||||
environmentVariables,
|
||||
externalProperties,
|
||||
modulePath,
|
||||
rootDir,
|
||||
timeout,
|
||||
outputFormat,
|
||||
moduleCacheDir,
|
||||
projectDir,
|
||||
certificateFiles,
|
||||
certificateUris,
|
||||
testPort);
|
||||
case 1 -> // for testing only
|
||||
new ExecutorSpiOptions(
|
||||
allowedModules,
|
||||
allowedResources,
|
||||
environmentVariables,
|
||||
externalProperties,
|
||||
modulePath,
|
||||
rootDir,
|
||||
timeout,
|
||||
outputFormat,
|
||||
moduleCacheDir,
|
||||
projectDir);
|
||||
default ->
|
||||
throw new AssertionError("Unknown ExecutorSpiOptions version: " + spiOptionsVersion);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,9 +198,7 @@ final class Version implements Comparable<Version> {
|
||||
@Override
|
||||
public boolean equals(/* @Nullable */ Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Version)) return false;
|
||||
|
||||
var other = (Version) obj;
|
||||
if (!(obj instanceof Version other)) return false;
|
||||
return major == other.major
|
||||
&& minor == other.minor
|
||||
&& patch == other.patch
|
||||
|
||||
Reference in New Issue
Block a user