Skip to content

Commit

Permalink
Fix sonar issues of Convert this Set to an EnumSet (apache#25827)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored May 21, 2023
1 parent 68b32f7 commit 93690f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
import org.apache.shardingsphere.db.protocol.postgresql.exception.PostgreSQLProtocolException;
import org.apache.shardingsphere.db.protocol.postgresql.packet.identifier.PostgreSQLIdentifierTag;

import java.util.Arrays;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Set;

/**
Expand Down Expand Up @@ -56,9 +55,9 @@ public enum PostgreSQLCommandPacketType implements CommandPacketType, PostgreSQL

TERMINATE('X');

private static final Set<PostgreSQLCommandPacketType> EXTENDED_PROTOCOL_PACKET_TYPE = new HashSet<>(Arrays.asList(PostgreSQLCommandPacketType.PARSE_COMMAND,
PostgreSQLCommandPacketType.BIND_COMMAND, PostgreSQLCommandPacketType.DESCRIBE_COMMAND, PostgreSQLCommandPacketType.EXECUTE_COMMAND, PostgreSQLCommandPacketType.SYNC_COMMAND,
PostgreSQLCommandPacketType.CLOSE_COMMAND, PostgreSQLCommandPacketType.FLUSH_COMMAND));
private static final Set<PostgreSQLCommandPacketType> EXTENDED_PROTOCOL_PACKET_TYPES = EnumSet.of(PostgreSQLCommandPacketType.PARSE_COMMAND,
PostgreSQLCommandPacketType.BIND_COMMAND, PostgreSQLCommandPacketType.DESCRIBE_COMMAND, PostgreSQLCommandPacketType.EXECUTE_COMMAND,
PostgreSQLCommandPacketType.SYNC_COMMAND, PostgreSQLCommandPacketType.CLOSE_COMMAND, PostgreSQLCommandPacketType.FLUSH_COMMAND);

private final char value;

Expand All @@ -85,6 +84,6 @@ public static PostgreSQLCommandPacketType valueOf(final int value) {
* @return is extended protocol packet type
*/
public static boolean isExtendedProtocolPacketType(final CommandPacketType commandPacketType) {
return EXTENDED_PROTOCOL_PACKET_TYPE.contains(commandPacketType);
return EXTENDED_PROTOCOL_PACKET_TYPES.contains(commandPacketType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.EnumSet;

/**
* Direction type enum.
Expand Down Expand Up @@ -60,12 +58,11 @@ public enum DirectionType {

BACKWARD_ALL("BACKWARD ALL");

private static final Set<DirectionType> ALL_DIRECTION_TYPES = new HashSet<>(Arrays.asList(ALL, FORWARD_ALL, BACKWARD_ALL));
private static final Collection<DirectionType> ALL_DIRECTION_TYPES = EnumSet.of(ALL, FORWARD_ALL, BACKWARD_ALL);

private static final Collection<DirectionType> FORWARD_COUNT_DIRECTION_TYPES =
new HashSet<>(Arrays.asList(DirectionType.NEXT, DirectionType.COUNT, DirectionType.FORWARD, DirectionType.FORWARD_COUNT));
private static final Collection<DirectionType> FORWARD_COUNT_DIRECTION_TYPES = EnumSet.of(DirectionType.NEXT, DirectionType.COUNT, DirectionType.FORWARD, DirectionType.FORWARD_COUNT);

private static final Collection<DirectionType> BACKWARD_COUNT_DIRECTION_TYPES = new HashSet<>(Arrays.asList(DirectionType.PRIOR, DirectionType.BACKWARD, DirectionType.BACKWARD_COUNT));
private static final Collection<DirectionType> BACKWARD_COUNT_DIRECTION_TYPES = EnumSet.of(DirectionType.PRIOR, DirectionType.BACKWARD, DirectionType.BACKWARD_COUNT);

private final String name;

Expand Down

0 comments on commit 93690f2

Please sign in to comment.