From: AsamK Date: Sun, 23 Apr 2023 17:55:23 +0000 (+0200) Subject: Use modern switch syntax X-Git-Tag: v0.11.10~7 X-Git-Url: https://git.nmode.ca/signal-cli/commitdiff_plain/f7f882e834f33702e4cc36d9a20e0a89ed76dec8 Use modern switch syntax --- diff --git a/lib/src/main/java/org/asamk/signal/manager/helper/IncomingMessageHandler.java b/lib/src/main/java/org/asamk/signal/manager/helper/IncomingMessageHandler.java index 4e171326..18e454e0 100644 --- a/lib/src/main/java/org/asamk/signal/manager/helper/IncomingMessageHandler.java +++ b/lib/src/main/java/org/asamk/signal/manager/helper/IncomingMessageHandler.java @@ -542,10 +542,8 @@ public final class IncomingMessageHandler { } if (syncMessage.getFetchType().isPresent()) { switch (syncMessage.getFetchType().get()) { - case LOCAL_PROFILE: - actions.add(new RetrieveProfileAction(account.getSelfRecipientId())); - case STORAGE_MANIFEST: - actions.add(RetrieveStorageDataAction.create()); + case LOCAL_PROFILE -> actions.add(new RetrieveProfileAction(account.getSelfRecipientId())); + case STORAGE_MANIFEST -> actions.add(RetrieveStorageDataAction.create()); } } if (syncMessage.getKeys().isPresent()) { @@ -709,7 +707,7 @@ public final class IncomingMessageHandler { if (group == null || group instanceof GroupInfoV1) { var groupV1 = (GroupInfoV1) group; switch (groupInfo.getType()) { - case UPDATE: { + case UPDATE -> { if (groupV1 == null) { groupV1 = new GroupInfoV1(groupId); } @@ -732,25 +730,23 @@ public final class IncomingMessageHandler { } account.getGroupStore().updateGroup(groupV1); - break; } - case DELIVER: + case DELIVER -> { if (groupV1 == null && !isSync) { actions.add(new SendGroupInfoRequestAction(source.recipientId(), groupId)); } - break; - case QUIT: { + } + case QUIT -> { if (groupV1 != null) { groupV1.removeMember(source.recipientId()); account.getGroupStore().updateGroup(groupV1); } - break; } - case REQUEST_INFO: + case REQUEST_INFO -> { if (groupV1 != null && !isSync) { actions.add(new SendGroupInfoAction(source.recipientId(), groupV1.getGroupId())); } - break; + } } } else { // Received a group v1 message for a v2 group diff --git a/lib/src/main/java/org/asamk/signal/manager/helper/UnidentifiedAccessHelper.java b/lib/src/main/java/org/asamk/signal/manager/helper/UnidentifiedAccessHelper.java index b89ed2b7..0f0da15c 100644 --- a/lib/src/main/java/org/asamk/signal/manager/helper/UnidentifiedAccessHelper.java +++ b/lib/src/main/java/org/asamk/signal/manager/helper/UnidentifiedAccessHelper.java @@ -166,18 +166,11 @@ public class UnidentifiedAccessHelper { private static byte[] getTargetUnidentifiedAccessKey( final Profile targetProfile, final ProfileKey theirProfileKey ) { - switch (targetProfile.getUnidentifiedAccessMode()) { - case ENABLED: - if (theirProfileKey == null) { - return null; - } - - return UnidentifiedAccess.deriveAccessKeyFrom(theirProfileKey); - case UNRESTRICTED: - return createUnrestrictedUnidentifiedAccess(); - default: - return null; - } + return switch (targetProfile.getUnidentifiedAccessMode()) { + case ENABLED -> theirProfileKey == null ? null : UnidentifiedAccess.deriveAccessKeyFrom(theirProfileKey); + case UNRESTRICTED -> createUnrestrictedUnidentifiedAccess(); + default -> null; + }; } private static byte[] createUnrestrictedUnidentifiedAccess() {