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
) throws IOException {
final var backupResponse = secureValueRecoveryV2.setPin(pin, masterKey).execute();
switch (backupResponse) {
case SecureValueRecovery.BackupResponse.Success success -> {
}
case SecureValueRecovery.BackupResponse.ServerRejected serverRejected ->
if (backupResponse == SecureValueRecovery.BackupResponse.Success) {
} else if (backupResponse == SecureValueRecovery.BackupResponse.ServerRejected) {
logger.warn("Backup svr2 failed: ServerRejected");
case SecureValueRecovery.BackupResponse.EnclaveNotFound enclaveNotFound ->
} else if (backupResponse == SecureValueRecovery.BackupResponse.EnclaveNotFound) {
logger.warn("Backup svr2 failed: EnclaveNotFound");
case SecureValueRecovery.BackupResponse.ExposeFailure exposeFailure ->
} else if (backupResponse == SecureValueRecovery.BackupResponse.ExposeFailure) {
logger.warn("Backup svr2 failed: ExposeFailure");
case SecureValueRecovery.BackupResponse.ApplicationError error ->
} else if (backupResponse == SecureValueRecovery.BackupResponse.ApplicationError) {
throw new IOException(error.getException());
case SecureValueRecovery.BackupResponse.NetworkError error -> throw error.getException();
case null, default -> throw new AssertionError("Unexpected response");
} else if (backupResponse == SecureValueRecovery.BackupResponse.NetworkError) {
throw new RuntimeException("network error");
} else {
throw new AssertionError("Unexpected response");
}
}