Using switch expressions

This commit is contained in:
Sebastian Stenzel
2020-05-11 07:47:15 +02:00
parent 49aead7323
commit d2189d379c
5 changed files with 38 additions and 96 deletions
@@ -121,15 +121,14 @@ public class FxApplication extends Application {
private void loadSelectedStyleSheet(UiTheme desiredTheme) {
UiTheme theme = licenseHolder.isValidLicense() ? desiredTheme : UiTheme.LIGHT;
switch (theme) {
case DARK:
case DARK -> {
Application.setUserAgentStylesheet(getClass().getResource("/css/dark_theme.css").toString());
macFunctions.map(MacFunctions::uiAppearance).ifPresent(JniException.ignore(MacApplicationUiAppearance::setToDarkAqua));
break;
case LIGHT:
default:
}
case LIGHT -> {
Application.setUserAgentStylesheet(getClass().getResource("/css/light_theme.css").toString());
macFunctions.map(MacFunctions::uiAppearance).ifPresent(JniException.ignore(MacApplicationUiAppearance::setToAqua));
break;
}
}
}
@@ -52,19 +52,13 @@ class AppLaunchEventHandler {
private void handleLaunchEvent(boolean hasTrayIcon, AppLaunchEvent event) {
switch (event.getType()) {
case REVEAL_APP:
fxApplicationStarter.get(hasTrayIcon).thenAccept(FxApplication::showMainWindow);
break;
case OPEN_FILE:
fxApplicationStarter.get(hasTrayIcon).thenRun(() -> {
case REVEAL_APP -> fxApplicationStarter.get(hasTrayIcon).thenAccept(FxApplication::showMainWindow);
case OPEN_FILE -> fxApplicationStarter.get(hasTrayIcon).thenRun(() -> {
Platform.runLater(() -> {
event.getPathsToOpen().forEach(this::addVault);
});
});
break;
default:
LOG.warn("Unsupported event type: {}", event.getType());
break;
default -> LOG.warn("Unsupported event type: {}", event.getType());
}
}
@@ -66,7 +66,7 @@ public class VaultListController implements FxController {
}
VaultState reportedState = newValue.getState();
switch (reportedState) {
case LOCKED, NEEDS_MIGRATION, MISSING:
case LOCKED, NEEDS_MIGRATION, MISSING -> {
try {
VaultState determinedState = VaultListManager.determineVaultState(newValue.getPath());
newValue.setState(determinedState);
@@ -75,9 +75,8 @@ public class VaultListController implements FxController {
newValue.setState(VaultState.ERROR);
newValue.setLastKnownException(e);
}
break;
case ERROR, UNLOCKED, PROCESSING:
break; // no-op
}
case ERROR, UNLOCKED, PROCESSING -> {}
}
}