This is an automated email from the ASF dual-hosted git repository.

zhaojinchao 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 6978452df73 Use CaseInsensitiveSet instead of containsIgnoreCase 
(#30180)
6978452df73 is described below

commit 6978452df73eb91402f0a6638bbdc1850498684b
Author: Raigor <[email protected]>
AuthorDate: Sun Feb 18 20:45:37 2024 +0800

    Use CaseInsensitiveSet instead of containsIgnoreCase (#30180)
---
 .../update/DropBroadcastTableRuleExecutor.java     | 14 ++++----
 .../checker/ShardingTableRuleStatementChecker.java | 22 ++++++------
 .../AlterShardingTableReferenceRuleExecutor.java   | 13 ++++---
 .../CreateShardingTableReferenceRuleExecutor.java  | 14 ++++----
 .../update/DropShardingTableReferenceExecutor.java |  6 ++--
 .../update/DropShardingTableRuleExecutor.java      | 13 +++----
 .../distsql/handler/util/CollectionUtils.java      | 41 ----------------------
 7 files changed, 39 insertions(+), 84 deletions(-)

diff --git 
a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutor.java
 
b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutor.java
index 271e73ef0d2..4d1ccfadbbe 100644
--- 
a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutor.java
+++ 
b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutor.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.broadcast.distsql.handler.update;
 
+import com.cedarsoftware.util.CaseInsensitiveSet;
 import lombok.Setter;
 import 
org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration;
 import 
org.apache.shardingsphere.broadcast.distsql.statement.DropBroadcastTableRuleStatement;
@@ -24,7 +25,6 @@ import org.apache.shardingsphere.broadcast.rule.BroadcastRule;
 import 
org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
 import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
-import org.apache.shardingsphere.distsql.handler.util.CollectionUtils;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 
@@ -52,9 +52,9 @@ public final class DropBroadcastTableRuleExecutor implements 
DatabaseRuleDropExe
     }
     
     private void checkBroadcastTableRuleExist(final 
DropBroadcastTableRuleStatement sqlStatement) {
-        Collection<String> currentRules = rule.getConfiguration().getTables();
-        Collection<String> notExistRules = 
sqlStatement.getTables().stream().filter(each -> 
!CollectionUtils.containsIgnoreCase(currentRules, 
each)).collect(Collectors.toList());
-        ShardingSpherePreconditions.checkState(notExistRules.isEmpty(), () -> 
new MissingRequiredRuleException("Broadcast", database.getName(), 
notExistRules));
+        Collection<String> currentRules = new 
CaseInsensitiveSet<>(rule.getConfiguration().getTables());
+        Collection<String> notExistedRules = 
sqlStatement.getTables().stream().filter(each -> 
!currentRules.contains(each)).collect(Collectors.toList());
+        ShardingSpherePreconditions.checkState(notExistedRules.isEmpty(), () 
-> new MissingRequiredRuleException("Broadcast", database.getName(), 
notExistedRules));
     }
     
     @Override
@@ -65,13 +65,15 @@ public final class DropBroadcastTableRuleExecutor 
implements DatabaseRuleDropExe
     @Override
     public BroadcastRuleConfiguration buildToBeAlteredRuleConfiguration(final 
DropBroadcastTableRuleStatement sqlStatement) {
         BroadcastRuleConfiguration result = new BroadcastRuleConfiguration(new 
HashSet<>(rule.getConfiguration().getTables()));
-        result.getTables().removeIf(each -> 
CollectionUtils.containsIgnoreCase(sqlStatement.getTables(), each));
+        Collection<String> toBeDroppedTableNames = new 
CaseInsensitiveSet<>(sqlStatement.getTables());
+        result.getTables().removeIf(toBeDroppedTableNames::contains);
         return result;
     }
     
     @Override
     public boolean updateCurrentRuleConfiguration(final 
DropBroadcastTableRuleStatement sqlStatement, final BroadcastRuleConfiguration 
currentRuleConfig) {
-        currentRuleConfig.getTables().removeIf(each -> 
CollectionUtils.containsIgnoreCase(sqlStatement.getTables(), each));
+        Collection<String> toBeDroppedTableNames = new 
CaseInsensitiveSet<>(sqlStatement.getTables());
+        
currentRuleConfig.getTables().removeIf(toBeDroppedTableNames::contains);
         return currentRuleConfig.isEmpty();
     }
     
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
index 6a738c2ba86..cac58cfaeb7 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.sharding.distsql.handler.checker;
 
+import com.cedarsoftware.util.CaseInsensitiveSet;
 import com.google.common.base.Splitter;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
@@ -25,7 +26,6 @@ import 
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleExc
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
 import 
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
-import org.apache.shardingsphere.distsql.handler.util.CollectionUtils;
 import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
 import org.apache.shardingsphere.infra.datanode.DataNode;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
@@ -348,27 +348,27 @@ public final class ShardingTableRuleStatementChecker {
                 
ShardingSpherePreconditions.checkState(duplicatedRuleNames.isEmpty(), () -> new 
DuplicateRuleException("sharding", databaseName, duplicatedRuleNames));
             }
         } else {
-            Collection<String> notExistsRules = 
getNotExistsRules(requiredTables, currentShardingTables);
-            ShardingSpherePreconditions.checkState(notExistsRules.isEmpty(), 
() -> new MissingRequiredRuleException("sharding", databaseName, 
notExistsRules));
+            Collection<String> notExistedRules = 
getNotExistedRules(requiredTables, currentShardingTables);
+            ShardingSpherePreconditions.checkState(notExistedRules.isEmpty(), 
() -> new MissingRequiredRuleException("sharding", databaseName, 
notExistedRules));
         }
     }
     
     private static Collection<String> getDuplicatedRuleNames(final 
Collection<String> collection) {
-        Collection<String> duplicate = 
collection.stream().collect(Collectors.groupingBy(String::toLowerCase, 
Collectors.counting())).entrySet().stream()
-                .filter(each -> each.getValue() > 
1).map(Entry::getKey).collect(Collectors.toSet());
-        return collection.stream().filter(each -> 
CollectionUtils.containsIgnoreCase(duplicate, 
each)).collect(Collectors.toSet());
+        Collection<String> duplicatedNames = 
collection.stream().collect(Collectors.groupingBy(String::toLowerCase, 
Collectors.counting())).entrySet().stream()
+                .filter(each -> each.getValue() > 
1).map(Entry::getKey).collect(Collectors.toCollection(CaseInsensitiveSet::new));
+        return 
collection.stream().filter(duplicatedNames::contains).collect(Collectors.toSet());
     }
     
-    private static Collection<String> getDuplicatedRuleNames(final 
Collection<String> require, final Collection<String> current) {
-        return require.stream().filter(each -> 
CollectionUtils.containsIgnoreCase(current, each)).collect(Collectors.toSet());
+    private static Collection<String> getDuplicatedRuleNames(final 
Collection<String> requiredRuleNames, final Collection<String> 
currentRuleNames) {
+        return 
requiredRuleNames.stream().filter(currentRuleNames::contains).collect(Collectors.toSet());
     }
     
-    private static Set<String> getNotExistsRules(final Collection<String> 
require, final Collection<String> current) {
-        return require.stream().filter(each -> 
!CollectionUtils.containsIgnoreCase(current, each)).collect(Collectors.toSet());
+    private static Set<String> getNotExistedRules(final Collection<String> 
requiredRuleNames, final Collection<String> currentRuleNames) {
+        return requiredRuleNames.stream().filter(each -> 
!currentRuleNames.contains(each)).collect(Collectors.toSet());
     }
     
     private static Collection<String> getCurrentShardingTables(final 
ShardingRuleConfiguration currentRuleConfig) {
-        Collection<String> result = new LinkedList<>();
+        Collection<String> result = new CaseInsensitiveSet<>();
         
result.addAll(currentRuleConfig.getTables().stream().map(ShardingTableRuleConfiguration::getLogicTable).collect(Collectors.toSet()));
         
result.addAll(currentRuleConfig.getAutoTables().stream().map(ShardingAutoTableRuleConfiguration::getLogicTable).collect(Collectors.toSet()));
         return result;
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableReferenceRuleExecutor.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableReferenceRuleExecutor.java
index 07178bfe558..e6ce5ce153b 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableReferenceRuleExecutor.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableReferenceRuleExecutor.java
@@ -17,13 +17,13 @@
 
 package org.apache.shardingsphere.sharding.distsql.handler.update;
 
+import com.cedarsoftware.util.CaseInsensitiveSet;
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
 import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
-import org.apache.shardingsphere.distsql.handler.util.CollectionUtils;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -91,14 +91,13 @@ public final class AlterShardingTableReferenceRuleExecutor 
implements DatabaseRu
     }
     
     private void checkToBeReferencedShardingTablesExisted(final 
AlterShardingTableReferenceRuleStatement sqlStatement) {
-        Collection<String> existedShardingTables = getCurrentShardingTables();
-        Collection<String> notExistedShardingTables =
-                sqlStatement.getTableNames().stream().filter(each -> 
!CollectionUtils.containsIgnoreCase(existedShardingTables, 
each)).collect(Collectors.toSet());
-        
ShardingSpherePreconditions.checkState(notExistedShardingTables.isEmpty(), () 
-> new MissingRequiredRuleException("Sharding", database.getName(), 
notExistedShardingTables));
+        Collection<String> currentShardingTableNames = 
getCurrentShardingTableNames();
+        Collection<String> notExistedTableNames = 
sqlStatement.getTableNames().stream().filter(each -> 
!currentShardingTableNames.contains(each)).collect(Collectors.toSet());
+        ShardingSpherePreconditions.checkState(notExistedTableNames.isEmpty(), 
() -> new MissingRequiredRuleException("Sharding", database.getName(), 
notExistedTableNames));
     }
     
-    private Collection<String> getCurrentShardingTables() {
-        Collection<String> result = new HashSet<>();
+    private Collection<String> getCurrentShardingTableNames() {
+        Collection<String> result = new CaseInsensitiveSet<>();
         
result.addAll(rule.getConfiguration().getTables().stream().map(ShardingTableRuleConfiguration::getLogicTable).collect(Collectors.toSet()));
         
result.addAll(rule.getConfiguration().getAutoTables().stream().map(ShardingAutoTableRuleConfiguration::getLogicTable).collect(Collectors.toSet()));
         return result;
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableReferenceRuleExecutor.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableReferenceRuleExecutor.java
index 75b5793568b..0f3e977627a 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableReferenceRuleExecutor.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableReferenceRuleExecutor.java
@@ -17,13 +17,13 @@
 
 package org.apache.shardingsphere.sharding.distsql.handler.update;
 
+import com.cedarsoftware.util.CaseInsensitiveSet;
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
 import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
-import org.apache.shardingsphere.distsql.handler.util.CollectionUtils;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -38,7 +38,6 @@ import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.stream.Collectors;
 
 /**
@@ -74,14 +73,13 @@ public final class CreateShardingTableReferenceRuleExecutor 
implements DatabaseR
     }
     
     private void checkToBeReferencedShardingTablesExisted(final 
CreateShardingTableReferenceRuleStatement sqlStatement) {
-        Collection<String> existedShardingTables = getCurrentLogicTables();
-        Collection<String> notExistedShardingTables =
-                sqlStatement.getTableNames().stream().filter(each -> 
!CollectionUtils.containsIgnoreCase(existedShardingTables, 
each)).collect(Collectors.toSet());
-        
ShardingSpherePreconditions.checkState(notExistedShardingTables.isEmpty(), () 
-> new MissingRequiredRuleException("Sharding", database.getName(), 
notExistedShardingTables));
+        Collection<String> currentShardingTableNames = 
getCurrentShardingTableNames();
+        Collection<String> notExistedTableNames = 
sqlStatement.getTableNames().stream().filter(each -> 
!currentShardingTableNames.contains(each)).collect(Collectors.toSet());
+        ShardingSpherePreconditions.checkState(notExistedTableNames.isEmpty(), 
() -> new MissingRequiredRuleException("Sharding", database.getName(), 
notExistedTableNames));
     }
     
-    private Collection<String> getCurrentLogicTables() {
-        Collection<String> result = new HashSet<>();
+    private Collection<String> getCurrentShardingTableNames() {
+        Collection<String> result = new CaseInsensitiveSet<>();
         
result.addAll(rule.getConfiguration().getTables().stream().map(ShardingTableRuleConfiguration::getLogicTable).collect(Collectors.toSet()));
         
result.addAll(rule.getConfiguration().getAutoTables().stream().map(ShardingAutoTableRuleConfiguration::getLogicTable).collect(Collectors.toSet()));
         return result;
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableReferenceExecutor.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableReferenceExecutor.java
index 60ac3bce764..38d538563f2 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableReferenceExecutor.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableReferenceExecutor.java
@@ -17,11 +17,11 @@
 
 package org.apache.shardingsphere.sharding.distsql.handler.update;
 
+import com.cedarsoftware.util.CaseInsensitiveSet;
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
 import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
-import org.apache.shardingsphere.distsql.handler.util.CollectionUtils;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -58,12 +58,12 @@ public final class DropShardingTableReferenceExecutor 
implements DatabaseRuleDro
     
     private void checkToBeDroppedShardingTableReferenceRules(final 
DropShardingTableReferenceRuleStatement sqlStatement) {
         Collection<String> currentRuleNames = 
getCurrentShardingTableReferenceRuleNames();
-        Collection<String> notExistedRuleNames = 
sqlStatement.getNames().stream().filter(each -> 
!CollectionUtils.containsIgnoreCase(currentRuleNames, 
each)).collect(Collectors.toList());
+        Collection<String> notExistedRuleNames = 
sqlStatement.getNames().stream().filter(each -> 
!currentRuleNames.contains(each)).collect(Collectors.toList());
         ShardingSpherePreconditions.checkState(notExistedRuleNames.isEmpty(), 
() -> new MissingRequiredRuleException("Sharding table reference", 
database.getName(), notExistedRuleNames));
     }
     
     private Collection<String> getCurrentShardingTableReferenceRuleNames() {
-        return 
rule.getConfiguration().getBindingTableGroups().stream().map(ShardingTableReferenceRuleConfiguration::getName).collect(Collectors.toList());
+        return 
rule.getConfiguration().getBindingTableGroups().stream().map(ShardingTableReferenceRuleConfiguration::getName).collect(Collectors.toCollection(CaseInsensitiveSet::new));
     }
     
     @Override
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleExecutor.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleExecutor.java
index d1898a2c45a..7ff355dd28f 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleExecutor.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleExecutor.java
@@ -17,13 +17,13 @@
 
 package org.apache.shardingsphere.sharding.distsql.handler.update;
 
+import com.cedarsoftware.util.CaseInsensitiveSet;
 import com.google.common.base.Splitter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.engine.update.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.RuleInUsedException;
 import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
-import org.apache.shardingsphere.distsql.handler.util.CollectionUtils;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -34,7 +34,6 @@ import org.apache.shardingsphere.sharding.rule.ShardingRule;
 
 import java.util.Collection;
 import java.util.Collections;
-import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.stream.Collectors;
 
@@ -59,8 +58,7 @@ public final class DropShardingTableRuleExecutor implements 
DatabaseRuleDropExec
     
     private void checkToBeDroppedShardingTableNames(final 
DropShardingTableRuleStatement sqlStatement) {
         Collection<String> currentShardingTableNames = 
getCurrentShardingTableNames();
-        Collection<String> notExistedTableNames =
-                
getToBeDroppedShardingTableNames(sqlStatement).stream().filter(each -> 
!CollectionUtils.containsIgnoreCase(currentShardingTableNames, 
each)).collect(Collectors.toList());
+        Collection<String> notExistedTableNames = 
getToBeDroppedShardingTableNames(sqlStatement).stream().filter(each -> 
!currentShardingTableNames.contains(each)).collect(Collectors.toList());
         ShardingSpherePreconditions.checkState(notExistedTableNames.isEmpty(), 
() -> new MissingRequiredRuleException("sharding", database.getName(), 
notExistedTableNames));
     }
     
@@ -69,7 +67,7 @@ public final class DropShardingTableRuleExecutor implements 
DatabaseRuleDropExec
     }
     
     private Collection<String> getCurrentShardingTableNames() {
-        Collection<String> result = new LinkedList<>();
+        Collection<String> result = new CaseInsensitiveSet<>();
         
result.addAll(rule.getConfiguration().getTables().stream().map(ShardingTableRuleConfiguration::getLogicTable).collect(Collectors.toList()));
         
result.addAll(rule.getConfiguration().getAutoTables().stream().map(ShardingAutoTableRuleConfiguration::getLogicTable).collect(Collectors.toList()));
         return result;
@@ -77,15 +75,14 @@ public final class DropShardingTableRuleExecutor implements 
DatabaseRuleDropExec
     
     private void checkBindingTables(final DropShardingTableRuleStatement 
sqlStatement) {
         Collection<String> bindingTables = getBindingTables();
-        Collection<String> usedTableNames =
-                
getToBeDroppedShardingTableNames(sqlStatement).stream().filter(each -> 
CollectionUtils.containsIgnoreCase(bindingTables, 
each)).collect(Collectors.toList());
+        Collection<String> usedTableNames = 
getToBeDroppedShardingTableNames(sqlStatement).stream().filter(bindingTables::contains).collect(Collectors.toList());
         if (!usedTableNames.isEmpty()) {
             throw new RuleInUsedException("Sharding", database.getName(), 
usedTableNames, "sharding table reference");
         }
     }
     
     private Collection<String> getBindingTables() {
-        Collection<String> result = new LinkedHashSet<>();
+        Collection<String> result = new CaseInsensitiveSet<>();
         rule.getConfiguration().getBindingTableGroups().forEach(each -> 
result.addAll(Splitter.on(",").splitToList(each.getReference())));
         return result;
     }
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/util/CollectionUtils.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/util/CollectionUtils.java
deleted file mode 100644
index ae0701804bc..00000000000
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/util/CollectionUtils.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.distsql.handler.util;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-import java.util.Collection;
-
-/**
- * Collection utility class.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class CollectionUtils {
-    
-    /**
-     * Judge whether the collection contains the specified element 
(case-insensitive).
-     * 
-     * @param collection collection
-     * @param element element
-     * @return true if the collection contains the specified element
-     */
-    public static boolean containsIgnoreCase(final Collection<String> 
collection, final String element) {
-        return collection.stream().anyMatch(each -> 
each.equalsIgnoreCase(element));
-    }
-}

Reply via email to