This is an automated email from the ASF dual-hosted git repository.
sunnianjun 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 18810eb24fe Refactor RepositoryTupleSwapper's impl (#31064)
18810eb24fe is described below
commit 18810eb24fe30152ebd5bb904d8a21c9987264a0
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Apr 29 23:49:43 2024 +0800
Refactor RepositoryTupleSwapper's impl (#31064)
---
.../swapper/EncryptRuleConfigurationRepositoryTupleSwapper.java | 2 +-
.../yaml/swapper/MaskRuleConfigurationRepositoryTupleSwapper.java | 8 ++++----
...ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper.java | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationRepositoryTupleSwapper.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationRepositoryTupleSwapper.java
index 6d04bcdbabe..7f6d85dedaa 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationRepositoryTupleSwapper.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationRepositoryTupleSwapper.java
@@ -65,6 +65,7 @@ public final class
EncryptRuleConfigurationRepositoryTupleSwapper implements Rep
if (validTuples.isEmpty()) {
return Optional.empty();
}
+ YamlEncryptRuleConfiguration yamlRuleConfig = new
YamlEncryptRuleConfiguration();
Map<String, YamlEncryptTableRuleConfiguration> tables = new
LinkedHashMap<>();
Map<String, YamlAlgorithmConfiguration> encryptors = new
LinkedHashMap<>();
for (RepositoryTuple each : validTuples) {
@@ -73,7 +74,6 @@ public final class
EncryptRuleConfigurationRepositoryTupleSwapper implements Rep
encryptRuleNodePath.getNamedItem(EncryptRuleNodePathProvider.ENCRYPTORS).getName(each.getKey())
.ifPresent(optional -> encryptors.put(optional,
YamlEngine.unmarshal(each.getValue(), YamlAlgorithmConfiguration.class)));
}
- YamlEncryptRuleConfiguration yamlRuleConfig = new
YamlEncryptRuleConfiguration();
yamlRuleConfig.setTables(tables);
yamlRuleConfig.setEncryptors(encryptors);
return Optional.of(ruleConfigSwapper.swapToObject(yamlRuleConfig));
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/MaskRuleConfigurationRepositoryTupleSwapper.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/MaskRuleConfigurationRepositoryTupleSwapper.java
index fe15f8bf0bf..50395b4fb26 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/MaskRuleConfigurationRepositoryTupleSwapper.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/MaskRuleConfigurationRepositoryTupleSwapper.java
@@ -50,12 +50,12 @@ public final class
MaskRuleConfigurationRepositoryTupleSwapper implements Reposi
public Collection<RepositoryTuple> swapToRepositoryTuples(final
MaskRuleConfiguration data) {
Collection<RepositoryTuple> result = new LinkedList<>();
YamlMaskRuleConfiguration yamlRuleConfig =
ruleConfigSwapper.swapToYamlConfiguration(data);
- for (Entry<String, YamlAlgorithmConfiguration> entry :
yamlRuleConfig.getMaskAlgorithms().entrySet()) {
- result.add(new
RepositoryTuple(maskRuleNodePath.getNamedItem(MaskRuleNodePathProvider.MASK_ALGORITHMS).getPath(entry.getKey()),
YamlEngine.marshal(entry.getValue())));
- }
for (YamlMaskTableRuleConfiguration each :
yamlRuleConfig.getTables().values()) {
result.add(new
RepositoryTuple(maskRuleNodePath.getNamedItem(MaskRuleNodePathProvider.TABLES).getPath(each.getName()),
YamlEngine.marshal(each)));
}
+ for (Entry<String, YamlAlgorithmConfiguration> entry :
yamlRuleConfig.getMaskAlgorithms().entrySet()) {
+ result.add(new
RepositoryTuple(maskRuleNodePath.getNamedItem(MaskRuleNodePathProvider.MASK_ALGORITHMS).getPath(entry.getKey()),
YamlEngine.marshal(entry.getValue())));
+ }
return result;
}
@@ -65,6 +65,7 @@ public final class
MaskRuleConfigurationRepositoryTupleSwapper implements Reposi
if (validTuples.isEmpty()) {
return Optional.empty();
}
+ YamlMaskRuleConfiguration yamlRuleConfig = new
YamlMaskRuleConfiguration();
Map<String, YamlMaskTableRuleConfiguration> tables = new
LinkedHashMap<>();
Map<String, YamlAlgorithmConfiguration> maskAlgorithms = new
LinkedHashMap<>();
for (RepositoryTuple each : validTuples) {
@@ -73,7 +74,6 @@ public final class
MaskRuleConfigurationRepositoryTupleSwapper implements Reposi
maskRuleNodePath.getNamedItem(MaskRuleNodePathProvider.MASK_ALGORITHMS).getName(each.getKey())
.ifPresent(optional -> maskAlgorithms.put(optional,
YamlEngine.unmarshal(each.getValue(), YamlAlgorithmConfiguration.class)));
}
- YamlMaskRuleConfiguration yamlRuleConfig = new
YamlMaskRuleConfiguration();
yamlRuleConfig.setTables(tables);
yamlRuleConfig.setMaskAlgorithms(maskAlgorithms);
return Optional.of(ruleConfigSwapper.swapToObject(yamlRuleConfig));
diff --git
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper.java
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper.java
index c4178d5b95b..4c5003b7990 100644
---
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper.java
+++
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper.java
@@ -67,6 +67,7 @@ public final class
ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper imp
if (validRepositoryTuples.isEmpty()) {
return Optional.empty();
}
+ YamlReadwriteSplittingRuleConfiguration yamlRuleConfig = new
YamlReadwriteSplittingRuleConfiguration();
Map<String, YamlReadwriteSplittingDataSourceGroupRuleConfiguration>
dataSourceGroups = new LinkedHashMap<>();
Map<String, YamlAlgorithmConfiguration> loadBalancers = new
LinkedHashMap<>();
for (RepositoryTuple each : validRepositoryTuples) {
@@ -75,7 +76,6 @@ public final class
ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper imp
readwriteSplittingRuleNodePath.getNamedItem(ReadwriteSplittingRuleNodePathProvider.LOAD_BALANCERS).getName(each.getKey())
.ifPresent(optional -> loadBalancers.put(optional,
YamlEngine.unmarshal(each.getValue(), YamlAlgorithmConfiguration.class)));
}
- YamlReadwriteSplittingRuleConfiguration yamlRuleConfig = new
YamlReadwriteSplittingRuleConfiguration();
yamlRuleConfig.setDataSourceGroups(dataSourceGroups);
yamlRuleConfig.setLoadBalancers(loadBalancers);
return Optional.of(ruleConfigSwapper.swapToObject(yamlRuleConfig));