You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2023/05/21 13:22:22 UTC
[shardingsphere] branch master updated: Fix sonar issues of Convert this Set to an EnumSet (#25827)
This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 93690f2086d Fix sonar issues of Convert this Set to an EnumSet (#25827)
93690f2086d is described below
commit 93690f2086d2405a17030d968894de33ad1db414
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun May 21 21:22:04 2023 +0800
Fix sonar issues of Convert this Set to an EnumSet (#25827)
---
.../packet/command/PostgreSQLCommandPacketType.java | 11 +++++------
.../sql/parser/sql/common/enums/DirectionType.java | 11 ++++-------
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
index 04ba4e85af9..2ece3534bd4 100644
--- a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
@@ -23,8 +23,7 @@ import org.apache.shardingsphere.db.protocol.packet.CommandPacketType;
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;
/**
@@ -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;
@@ -85,6 +84,6 @@ public enum PostgreSQLCommandPacketType implements CommandPacketType, PostgreSQL
* @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);
}
}
diff --git a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/enums/DirectionType.java b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/enums/DirectionType.java
index 522dd9ce09a..6bc1c68a3ac 100644
--- a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/enums/DirectionType.java
+++ b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/enums/DirectionType.java
@@ -20,10 +20,8 @@ package org.apache.shardingsphere.sql.parser.sql.common.enums;
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.
@@ -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;