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 cb931d4134b Extract public method containsIgnoreCase (#30168)
cb931d4134b is described below
commit cb931d4134b5c173448a315ae5e27b66b9980a56
Author: Raigor <[email protected]>
AuthorDate: Sun Feb 18 16:14:12 2024 +0800
Extract public method containsIgnoreCase (#30168)
---
.../update/DropBroadcastTableRuleExecutor.java | 13 +++----
.../checker/ShardingTableRuleStatementChecker.java | 13 +++----
.../AlterShardingTableReferenceRuleExecutor.java | 10 +++---
.../CreateShardingTableReferenceRuleExecutor.java | 10 +++---
.../update/DropShardingTableReferenceExecutor.java | 9 ++---
.../update/DropShardingTableRuleExecutor.java | 12 +++----
.../distsql/handler/util/CollectionUtils.java | 41 ++++++++++++++++++++++
7 files changed, 67 insertions(+), 41 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 ba88c055cbe..271e73ef0d2 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
@@ -21,9 +21,10 @@ import lombok.Setter;
import
org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration;
import
org.apache.shardingsphere.broadcast.distsql.statement.DropBroadcastTableRuleStatement;
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.engine.update.rdl.rule.spi.database.DatabaseRuleDropExecutor;
+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,14 +53,10 @@ 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 ->
!containsIgnoreCase(currentRules, each)).collect(Collectors.toList());
+ 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));
}
- private boolean containsIgnoreCase(final Collection<String> currentRules,
final String ruleName) {
- return currentRules.stream().anyMatch(each ->
each.equalsIgnoreCase(ruleName));
- }
-
@Override
public boolean hasAnyOneToBeDropped(final DropBroadcastTableRuleStatement
sqlStatement) {
return !Collections.disjoint(rule.getConfiguration().getTables(),
sqlStatement.getTables());
@@ -68,13 +65,13 @@ 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 ->
containsIgnoreCase(sqlStatement.getTables(), each));
+ result.getTables().removeIf(each ->
CollectionUtils.containsIgnoreCase(sqlStatement.getTables(), each));
return result;
}
@Override
public boolean updateCurrentRuleConfiguration(final
DropBroadcastTableRuleStatement sqlStatement, final BroadcastRuleConfiguration
currentRuleConfig) {
- currentRuleConfig.getTables().removeIf(each ->
containsIgnoreCase(sqlStatement.getTables(), each));
+ currentRuleConfig.getTables().removeIf(each ->
CollectionUtils.containsIgnoreCase(sqlStatement.getTables(), each));
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 deed64a6b8c..8b2c4562581 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
@@ -25,12 +25,13 @@ 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;
import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
-import
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -355,19 +356,15 @@ public final class ShardingTableRuleStatementChecker {
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 ->
containsIgnoreCase(duplicate, each)).collect(Collectors.toSet());
+ return collection.stream().filter(each ->
CollectionUtils.containsIgnoreCase(duplicate,
each)).collect(Collectors.toSet());
}
private static Collection<String> getDuplicatedRuleNames(final
Collection<String> require, final Collection<String> current) {
- return require.stream().filter(each -> containsIgnoreCase(current,
each)).collect(Collectors.toSet());
+ return require.stream().filter(each ->
CollectionUtils.containsIgnoreCase(current, each)).collect(Collectors.toSet());
}
private static Set<String> getNotExistsRules(final Collection<String>
require, final Collection<String> current) {
- return require.stream().filter(each -> !containsIgnoreCase(current,
each)).collect(Collectors.toSet());
- }
-
- private static boolean containsIgnoreCase(final Collection<String>
collection, final String str) {
- return collection.stream().anyMatch(each ->
each.equalsIgnoreCase(str));
+ return require.stream().filter(each ->
!CollectionUtils.containsIgnoreCase(current, each)).collect(Collectors.toSet());
}
private static Collection<String> getCurrentShardingTables(final
ShardingRuleConfiguration currentRuleConfig) {
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 d7800fb9e54..07178bfe558 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
@@ -18,11 +18,12 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
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.engine.update.rdl.rule.spi.database.DatabaseRuleAlterExecutor;
+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,7 +92,8 @@ public final class AlterShardingTableReferenceRuleExecutor
implements DatabaseRu
private void checkToBeReferencedShardingTablesExisted(final
AlterShardingTableReferenceRuleStatement sqlStatement) {
Collection<String> existedShardingTables = getCurrentShardingTables();
- Collection<String> notExistedShardingTables =
sqlStatement.getTableNames().stream().filter(each ->
!containsIgnoreCase(existedShardingTables, each)).collect(Collectors.toSet());
+ 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));
}
@@ -102,10 +104,6 @@ public final class AlterShardingTableReferenceRuleExecutor
implements DatabaseRu
return result;
}
- private boolean containsIgnoreCase(final Collection<String> currentRules,
final String ruleName) {
- return currentRules.stream().anyMatch(each ->
each.equalsIgnoreCase(ruleName));
- }
-
private void checkShardingTableReferenceRulesValid(final
AlterShardingTableReferenceRuleStatement sqlStatement) {
Collection<ShardingTableReferenceRuleConfiguration>
toBeAlteredShardingTableReferenceRules =
buildToBeAlteredRuleConfiguration(sqlStatement).getBindingTableGroups();
Collection<String> ruleNames =
toBeAlteredShardingTableReferenceRules.stream().map(ShardingTableReferenceRuleConfiguration::getName).collect(Collectors.toList());
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 bbb799a9076..75b5793568b 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
@@ -18,11 +18,12 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
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.engine.update.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
+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;
@@ -74,7 +75,8 @@ public final class CreateShardingTableReferenceRuleExecutor
implements DatabaseR
private void checkToBeReferencedShardingTablesExisted(final
CreateShardingTableReferenceRuleStatement sqlStatement) {
Collection<String> existedShardingTables = getCurrentLogicTables();
- Collection<String> notExistedShardingTables =
sqlStatement.getTableNames().stream().filter(each ->
!containsIgnoreCase(existedShardingTables, each)).collect(Collectors.toSet());
+ 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));
}
@@ -96,10 +98,6 @@ public final class CreateShardingTableReferenceRuleExecutor
implements DatabaseR
return
rule.getConfiguration().getBindingTableGroups().stream().flatMap(each ->
Arrays.stream(each.getReference().split(","))).map(String::trim).collect(Collectors.toList());
}
- private boolean containsIgnoreCase(final Collection<String> currentRules,
final String ruleName) {
- return currentRules.stream().anyMatch(each ->
each.equalsIgnoreCase(ruleName));
- }
-
@Override
public ShardingRuleConfiguration buildToBeCreatedRuleConfiguration(final
CreateShardingTableReferenceRuleStatement sqlStatement) {
Collection<TableReferenceRuleSegment> segments =
sqlStatement.getRules();
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 eb83797c1ed..60ac3bce764 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
@@ -18,9 +18,10 @@
package org.apache.shardingsphere.sharding.distsql.handler.update;
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.engine.update.rdl.rule.spi.database.DatabaseRuleDropExecutor;
+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;
@@ -57,7 +58,7 @@ public final class DropShardingTableReferenceExecutor
implements DatabaseRuleDro
private void checkToBeDroppedShardingTableReferenceRules(final
DropShardingTableReferenceRuleStatement sqlStatement) {
Collection<String> currentRuleNames =
getCurrentShardingTableReferenceRuleNames();
- Collection<String> notExistedRuleNames =
sqlStatement.getNames().stream().filter(each ->
!containsIgnoreCase(currentRuleNames, each)).collect(Collectors.toList());
+ Collection<String> notExistedRuleNames =
sqlStatement.getNames().stream().filter(each ->
!CollectionUtils.containsIgnoreCase(currentRuleNames,
each)).collect(Collectors.toList());
ShardingSpherePreconditions.checkState(notExistedRuleNames.isEmpty(),
() -> new MissingRequiredRuleException("Sharding table reference",
database.getName(), notExistedRuleNames));
}
@@ -65,10 +66,6 @@ public final class DropShardingTableReferenceExecutor
implements DatabaseRuleDro
return
rule.getConfiguration().getBindingTableGroups().stream().map(ShardingTableReferenceRuleConfiguration::getName).collect(Collectors.toList());
}
- private boolean containsIgnoreCase(final Collection<String> ruleNames,
final String name) {
- return ruleNames.stream().anyMatch(each ->
each.equalsIgnoreCase(name));
- }
-
@Override
public ShardingRuleConfiguration buildToBeDroppedRuleConfiguration(final
DropShardingTableReferenceRuleStatement sqlStatement) {
ShardingRuleConfiguration result = new ShardingRuleConfiguration();
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 59618d349a0..d1898a2c45a 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
@@ -19,10 +19,11 @@ package
org.apache.shardingsphere.sharding.distsql.handler.update;
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.engine.update.rdl.rule.spi.database.DatabaseRuleDropExecutor;
+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;
@@ -59,7 +60,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 ->
!containsIgnoreCase(currentShardingTableNames,
each)).collect(Collectors.toList());
+
getToBeDroppedShardingTableNames(sqlStatement).stream().filter(each ->
!CollectionUtils.containsIgnoreCase(currentShardingTableNames,
each)).collect(Collectors.toList());
ShardingSpherePreconditions.checkState(notExistedTableNames.isEmpty(),
() -> new MissingRequiredRuleException("sharding", database.getName(),
notExistedTableNames));
}
@@ -67,10 +68,6 @@ public final class DropShardingTableRuleExecutor implements
DatabaseRuleDropExec
return sqlStatement.getTableNames().stream().map(each ->
each.getIdentifier().getValue()).collect(Collectors.toList());
}
- private boolean containsIgnoreCase(final Collection<String> collection,
final String str) {
- return collection.stream().anyMatch(each ->
each.equalsIgnoreCase(str));
- }
-
private Collection<String> getCurrentShardingTableNames() {
Collection<String> result = new LinkedList<>();
result.addAll(rule.getConfiguration().getTables().stream().map(ShardingTableRuleConfiguration::getLogicTable).collect(Collectors.toList()));
@@ -80,7 +77,8 @@ public final class DropShardingTableRuleExecutor implements
DatabaseRuleDropExec
private void checkBindingTables(final DropShardingTableRuleStatement
sqlStatement) {
Collection<String> bindingTables = getBindingTables();
- Collection<String> usedTableNames =
getToBeDroppedShardingTableNames(sqlStatement).stream().filter(each ->
containsIgnoreCase(bindingTables, each)).collect(Collectors.toList());
+ Collection<String> usedTableNames =
+
getToBeDroppedShardingTableNames(sqlStatement).stream().filter(each ->
CollectionUtils.containsIgnoreCase(bindingTables,
each)).collect(Collectors.toList());
if (!usedTableNames.isEmpty()) {
throw new RuleInUsedException("Sharding", database.getName(),
usedTableNames, "sharding table reference");
}
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
new file mode 100644
index 00000000000..3b4ca5ef7ce
--- /dev/null
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/util/CollectionUtils.java
@@ -0,0 +1,41 @@
+/*
+ * 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 {
+
+ /**
+ * Get database name.
+ *
+ * @param collection collection
+ * @param element element
+ * @return true if the collection contains the specified element
(case-insensitive)
+ */
+ public static boolean containsIgnoreCase(final Collection<String>
collection, final String element) {
+ return collection.stream().anyMatch(each ->
each.equalsIgnoreCase(element));
+ }
+}