Replace switch with if

This commit is contained in:
ahatius 2023-12-04 20:08:24 +01:00 committed by GitHub
parent 1adfd3d6cd
commit de9836d0de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,19 +25,20 @@ public class PinHelper {
String pin, MasterKey masterKey String pin, MasterKey masterKey
) throws IOException { ) throws IOException {
final var backupResponse = secureValueRecoveryV2.setPin(pin, masterKey).execute(); final var backupResponse = secureValueRecoveryV2.setPin(pin, masterKey).execute();
switch (backupResponse) {
case SecureValueRecovery.BackupResponse.Success success -> { if (backupResponse == SecureValueRecovery.BackupResponse.Success) {
} } else if (backupResponse == SecureValueRecovery.BackupResponse.ServerRejected) {
case SecureValueRecovery.BackupResponse.ServerRejected serverRejected -> logger.warn("Backup svr2 failed: ServerRejected");
logger.warn("Backup svr2 failed: ServerRejected"); } else if (backupResponse == SecureValueRecovery.BackupResponse.EnclaveNotFound) {
case SecureValueRecovery.BackupResponse.EnclaveNotFound enclaveNotFound -> logger.warn("Backup svr2 failed: EnclaveNotFound");
logger.warn("Backup svr2 failed: EnclaveNotFound"); } else if (backupResponse == SecureValueRecovery.BackupResponse.ExposeFailure) {
case SecureValueRecovery.BackupResponse.ExposeFailure exposeFailure -> logger.warn("Backup svr2 failed: ExposeFailure");
logger.warn("Backup svr2 failed: ExposeFailure"); } else if (backupResponse == SecureValueRecovery.BackupResponse.ApplicationError) {
case SecureValueRecovery.BackupResponse.ApplicationError error -> throw new IOException(error.getException());
throw new IOException(error.getException()); } else if (backupResponse == SecureValueRecovery.BackupResponse.NetworkError) {
case SecureValueRecovery.BackupResponse.NetworkError error -> throw error.getException(); throw new RuntimeException("network error");
case null, default -> throw new AssertionError("Unexpected response"); } else {
throw new AssertionError("Unexpected response");
} }
} }