Use if instead of switch

This commit is contained in:
ahatius 2023-12-04 19:31:34 +01:00 committed by GitHub
parent 5414a18081
commit 854116ecaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1284,15 +1284,18 @@ public class ManagerImpl implements Manager {
public boolean trustIdentityVerified(
RecipientIdentifier.Single recipient, IdentityVerificationCode verificationCode
) throws UnregisteredRecipientException {
return switch (verificationCode) {
case IdentityVerificationCode.Fingerprint fingerprint -> trustIdentity(recipient,
if (verificationCode == IdentityVerificationCode.Fingerprint) {
return trustIdentity(recipient,
r -> context.getIdentityHelper().trustIdentityVerified(r, fingerprint.fingerprint()));
case IdentityVerificationCode.SafetyNumber safetyNumber -> trustIdentity(recipient,
} else if (verificationCode == IdentityVerificationCode.SafetyNumber) {
return trustIdentity(recipient,
r -> context.getIdentityHelper().trustIdentityVerifiedSafetyNumber(r, safetyNumber.safetyNumber()));
case IdentityVerificationCode.ScannableSafetyNumber safetyNumber -> trustIdentity(recipient,
} else if (verificationCode == IdentityVerificationCode.ScannableSafetyNumber) {
return trustIdentity(recipient,
r -> context.getIdentityHelper().trustIdentityVerifiedSafetyNumber(r, safetyNumber.safetyNumber()));
case null, default -> throw new AssertionError("Invalid verification code type");
};
} else {
throw new AssertionError("Invalid verification code type")
}
}
@Override