This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 55532b28f57 Replace stream().forEach() to forEach() (#16842)
55532b28f57 is described below
commit 55532b28f5739878c08d63671fef0d10d052d7b0
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Apr 15 10:53:56 2022 +0800
Replace stream().forEach() to forEach() (#16842)
---
.../YamlExampleConfigurationSupportedValue.java | 37 +++++++++++-----------
.../config/YamlExampleConfigurationValidator.java | 10 +++---
.../ClusterContextManagerCoordinator.java | 2 +-
...aseDiscoveryRuleConfigurationImportChecker.java | 2 +-
.../resource/UnusedDataSourceQueryResultSet.java | 4 +--
5 files changed, 27 insertions(+), 28 deletions(-)
diff --git
a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationSupportedValue.java
b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationSupportedValue.java
index e2336c45b80..44620792f68 100644
---
a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationSupportedValue.java
+++
b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationSupportedValue.java
@@ -17,40 +17,39 @@
package org.apache.shardingsphere.example.generator.core.yaml.config;
-import java.util.Set;
-
import com.google.common.collect.Sets;
-
-import lombok.AllArgsConstructor;
import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+import java.util.Set;
/**
* Configuration values supported by yaml sample.
*/
+@RequiredArgsConstructor
@Getter
-@AllArgsConstructor
public enum YamlExampleConfigurationSupportedValue {
-
+
PRODUCTS("products", Sets.newHashSet("jdbc", "proxy")),
-
+
MODES("modes", Sets.newHashSet("memory", "proxy", "cluster-zookeeper",
"cluster-etcd", "standalone-file")),
-
+
TRANSACTIONS("transactions", Sets.newHashSet("local")),
-
+
FEATURES("features", Sets.newHashSet("shadow", "sharding",
"readwrite-splitting", "encrypt", "db-discovery")),
-
+
FRAMEWORKS("frameworks", Sets.newHashSet("jdbc",
"spring-boot-starter-jdbc", "spring-boot-starter-jpa",
"spring-boot-starter-mybatis", "spring-namespace-jdbc", "spring-namespace-jpa",
"spring-namespace-mybatis"));
-
- private String configItem;
-
- private Set<String> supportedValues;
-
+
+ private final String configItem;
+
+ private final Set<String> supportedValues;
+
public static YamlExampleConfigurationSupportedValue of(String configItem)
{
- for (YamlExampleConfigurationSupportedValue exampleSupportedValues :
values()) {
- if (exampleSupportedValues.getConfigItem().equals(configItem)) {
- return exampleSupportedValues;
+ for (YamlExampleConfigurationSupportedValue each : values()) {
+ if (each.getConfigItem().equals(configItem)) {
+ return each;
}
}
- return null;
+ throw new IllegalArgumentException(configItem);
}
}
diff --git
a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationValidator.java
b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationValidator.java
index c917723f732..13aebccdc4f 100644
---
a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationValidator.java
+++
b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/yaml/config/YamlExampleConfigurationValidator.java
@@ -17,15 +17,15 @@
package org.apache.shardingsphere.example.generator.core.yaml.config;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
/**
* Example configuration validator.
*/
@@ -51,7 +51,7 @@ public final class YamlExampleConfigurationValidator {
configurationMap.forEach((configItem, configValues) -> {
YamlExampleConfigurationSupportedValue supportedValueEnum =
YamlExampleConfigurationSupportedValue.of(configItem);
Set<String> supportedValues =
supportedValueEnum.getSupportedValues();
- configValues.stream().forEach(v ->
Preconditions.checkArgument(supportedValues.contains(v),
getConfigValueErrorMessage(configItem, supportedValues, v)));
+ configValues.forEach(v ->
Preconditions.checkArgument(supportedValues.contains(v),
getConfigValueErrorMessage(configItem, supportedValues, v)));
});
}
diff --git
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
index 60826ec441c..7c57d4db795 100644
---
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
+++
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
@@ -327,6 +327,6 @@ public final class ClusterContextManagerCoordinator {
Map<String, StorageNodeDataSource> storageNodes =
registryCenter.getStorageNodeStatusService().loadStorageNodes();
Map<String, StorageNodeDataSource> disableDataSources =
storageNodes.entrySet().stream().filter(entry ->
StorageNodeStatus.DISABLED.name().toLowerCase().equals(entry.getValue().getStatus())).collect(Collectors.toMap(Map.Entry::getKey,
Map.Entry::getValue));
- disableDataSources.entrySet().stream().forEach(entry ->
rule.updateStatus(new DataSourceNameDisabledEvent(new
QualifiedSchema(entry.getKey()), true)));
+ disableDataSources.forEach((key, value) -> rule.updateStatus(new
DataSourceNameDisabledEvent(new QualifiedSchema(key), true)));
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
index 1a1e791ce4f..773bc7902ac 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/checker/DatabaseDiscoveryRuleConfigurationImportChecker.java
@@ -71,7 +71,7 @@ public final class
DatabaseDiscoveryRuleConfigurationImportChecker {
Collection<String> invalidInput =
currentRuleConfig.getDiscoveryTypes().values().stream().map(TypedSPIConfiguration::getType)
.filter(each ->
!TypedSPIRegistry.findRegisteredService(DatabaseDiscoveryType.class, each, new
Properties()).isPresent()).collect(Collectors.toList());
DistSQLException.predictionThrow(invalidInput.isEmpty(), () -> new
InvalidAlgorithmConfigurationException(DB_DISCOVERY.toLowerCase(),
invalidInput));
- currentRuleConfig.getDataSources().stream().forEach(each -> {
+ currentRuleConfig.getDataSources().forEach(each -> {
if
(!currentRuleConfig.getDiscoveryTypes().containsKey(each.getDiscoveryTypeName()))
{
invalidInput.add(each.getDiscoveryTypeName());
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/resource/UnusedDataSourceQueryResultSet.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/resource/UnusedDataSourceQueryResultSet.java
index a38793cd648..d7e5e74ce19 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/resource/UnusedDataSourceQueryResultSet.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/resource/UnusedDataSourceQueryResultSet.java
@@ -88,11 +88,11 @@ public final class UnusedDataSourceQueryResultSet
implements DistSQLResultSet {
for (ShardingSphereRule each : ruleMetaData.getRules()) {
if (each instanceof DataSourceContainedRule) {
Set<String> inUsedResourceNames =
getInUsedResourceNames((DataSourceContainedRule) each);
- inUsedResourceNames.stream().forEach(eachResource ->
result.put(eachResource, each.getType()));
+ inUsedResourceNames.forEach(eachResource ->
result.put(eachResource, each.getType()));
}
if (each instanceof DataNodeContainedRule) {
Set<String> inUsedResourceNames =
getInUsedResourceNames((DataNodeContainedRule) each);
- inUsedResourceNames.stream().forEach(eachResource ->
result.put(eachResource, each.getType()));
+ inUsedResourceNames.forEach(eachResource ->
result.put(eachResource, each.getType()));
}
}
return result;