From 854116ecaacf2cd5e9132390e33376e432ad980f Mon Sep 17 00:00:00 2001 From: ahatius Date: Mon, 4 Dec 2023 19:31:34 +0100 Subject: [PATCH] Use if instead of switch --- .../signal/manager/internal/ManagerImpl.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/src/main/java/org/asamk/signal/manager/internal/ManagerImpl.java b/lib/src/main/java/org/asamk/signal/manager/internal/ManagerImpl.java index cfa54cde..1a23ec30 100644 --- a/lib/src/main/java/org/asamk/signal/manager/internal/ManagerImpl.java +++ b/lib/src/main/java/org/asamk/signal/manager/internal/ManagerImpl.java @@ -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