Use if instead of switch

This commit is contained in:
ahatius 2023-12-04 19:58:17 +01:00 committed by GitHub
parent 365b8ed120
commit d4321971e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -166,15 +166,13 @@ public class GroupStore {
} }
public GroupInfo getGroup(final Connection connection, final GroupId groupId) throws SQLException { public GroupInfo getGroup(final Connection connection, final GroupId groupId) throws SQLException {
switch (groupId) { if (groupId instanceof GroupIdV1) {
case GroupIdV1 groupIdV1 -> {
final var group = getGroup(connection, groupIdV1); final var group = getGroup(connection, groupIdV1);
if (group != null) { if (group != null) {
return group; return group;
} }
return getGroupV2ByV1Id(connection, groupIdV1); return getGroupV2ByV1Id(connection, groupIdV1);
} } else if (groupId instanceOf GroupIdV2) {
case GroupIdV2 groupIdV2 -> {
final var group = getGroup(connection, groupIdV2); final var group = getGroup(connection, groupIdV2);
if (group != null) { if (group != null) {
return group; return group;
@ -182,7 +180,6 @@ public class GroupStore {
return getGroupV1ByV2Id(connection, groupIdV2); return getGroupV1ByV2Id(connection, groupIdV2);
} }
} }
}
public GroupInfoV1 getOrCreateGroupV1(GroupIdV1 groupId) { public GroupInfoV1 getOrCreateGroupV1(GroupIdV1 groupId) {
try (final var connection = database.getConnection()) { try (final var connection = database.getConnection()) {