Replace switch with if

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

View file

@ -209,8 +209,8 @@ public class GroupHelper {
var group = getGroupForUpdating(groupId); var group = getGroupForUpdating(groupId);
final var avatarBytes = readAvatarBytes(avatarFile); final var avatarBytes = readAvatarBytes(avatarFile);
switch (group) { if(group instanceof GroupInfoV2) {
case GroupInfoV2 gv2 -> { GroupInfoV2 gv2 = (GroupInfoV2) group;
try { try {
return updateGroupV2(gv2, return updateGroupV2(gv2,
name, name,
@ -248,9 +248,8 @@ public class GroupHelper {
expirationTimer, expirationTimer,
isAnnouncementGroup); isAnnouncementGroup);
} }
} } else if (group instanceof GroupInfoV1) {
GroupInfoV1 gv1 = (GroupInfoV1) group;
case GroupInfoV1 gv1 -> {
final var result = updateGroupV1(gv1, name, members, avatarBytes); final var result = updateGroupV1(gv1, name, members, avatarBytes);
if (expirationTimer != null) { if (expirationTimer != null) {
setExpirationTimer(gv1, expirationTimer); setExpirationTimer(gv1, expirationTimer);
@ -258,7 +257,6 @@ public class GroupHelper {
return result; return result;
} }
} }
}
public void updateGroupProfileKey(GroupIdV2 groupId) throws GroupNotFoundException, NotAGroupMemberException, IOException { public void updateGroupProfileKey(GroupIdV2 groupId) throws GroupNotFoundException, NotAGroupMemberException, IOException {
var group = getGroupForUpdating(groupId); var group = getGroupForUpdating(groupId);