This is an automated email from the ASF dual-hosted git repository.
panjuan 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 84fb070dd61 Refactor RuleNodePath (#26606)
84fb070dd61 is described below
commit 84fb070dd61857c8a8995d933fc273280818ee78
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jun 27 12:15:18 2023 +0800
Refactor RuleNodePath (#26606)
---
.../BroadcastRuleConfigurationEventBuilder.java | 4 +-
.../NewYamlBroadcastRuleConfigurationSwapper.java | 2 +-
...atibleEncryptRuleConfigurationEventBuilder.java | 6 +--
.../EncryptRuleConfigurationEventBuilder.java | 6 +--
...lCompatibleEncryptRuleConfigurationSwapper.java | 8 ++--
.../NewYamlEncryptRuleConfigurationSwapper.java | 8 ++--
.../event/MaskRuleConfigurationEventBuilder.java | 6 +--
.../NewYamlMaskRuleConfigurationSwapper.java | 8 ++--
...riteSplittingRuleConfigurationEventBuilder.java | 6 +--
...ReadwriteSplittingRuleConfigurationSwapper.java | 8 ++--
.../event/ShadowRuleConfigurationEventBuilder.java | 10 ++---
.../NewYamlShadowRuleConfigurationSwapper.java | 16 ++++----
.../ShardingRuleConfigurationEventBuilder.java | 26 ++++++------
.../NewYamlShardingRuleConfigurationSwapper.java | 48 +++++++++++-----------
.../infra/metadata/nodepath/RuleNodePath.java | 26 ++++++------
.../event/SingleRuleConfigurationEventBuilder.java | 4 +-
.../NewYamlSingleRuleConfigurationSwapper.java | 2 +-
17 files changed, 97 insertions(+), 97 deletions(-)
diff --git
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/event/BroadcastRuleConfigurationEventBuilder.java
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/event/BroadcastRuleConfigurationEventBuilder.java
index 16da5247745..14f16ae64e7 100644
---
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/event/BroadcastRuleConfigurationEventBuilder.java
+++
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/event/BroadcastRuleConfigurationEventBuilder.java
@@ -39,10 +39,10 @@ public final class BroadcastRuleConfigurationEventBuilder
implements RuleConfigu
@Override
public Optional<GovernanceEvent> build(final String databaseName, final
DataChangedEvent event) {
- if
(!broadcastRuleNodePath.getRootNodePath().isValidatedPath(event.getKey()) ||
Strings.isNullOrEmpty(event.getValue())) {
+ if (!broadcastRuleNodePath.getRoot().isValidatedPath(event.getKey())
|| Strings.isNullOrEmpty(event.getValue())) {
return Optional.empty();
}
- if
(broadcastRuleNodePath.getNamedRuleItemNodePath(BroadcastNodeConverter.TABLES).getNameByActiveVersion(event.getKey()).isPresent()
&& !Strings.isNullOrEmpty(event.getValue())) {
+ if
(broadcastRuleNodePath.getNamedItem(BroadcastNodeConverter.TABLES).getNameByActiveVersion(event.getKey()).isPresent()
&& !Strings.isNullOrEmpty(event.getValue())) {
return createBroadcastConfigEvent(databaseName, event);
}
return Optional.empty();
diff --git
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/NewYamlBroadcastRuleConfigurationSwapper.java
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/NewYamlBroadcastRuleConfigurationSwapper.java
index 5aaa0c8e03d..a4e5411d1b0 100644
---
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/NewYamlBroadcastRuleConfigurationSwapper.java
+++
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/NewYamlBroadcastRuleConfigurationSwapper.java
@@ -50,7 +50,7 @@ public final class NewYamlBroadcastRuleConfigurationSwapper
implements NewYamlRu
@Override
public BroadcastRuleConfiguration swapToObject(final
Collection<YamlDataNode> dataNodes) {
for (YamlDataNode each : dataNodes) {
- if
(broadcastRuleNodePath.getRootNodePath().isValidatedPath(each.getKey())) {
+ if
(broadcastRuleNodePath.getRoot().isValidatedPath(each.getKey())) {
YamlBroadcastRuleConfiguration yamlBroadcastRuleConfiguration
= YamlEngine.unmarshal(each.getValue(), YamlBroadcastRuleConfiguration.class);
return new
BroadcastRuleConfiguration(yamlBroadcastRuleConfiguration.getTables());
}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/CompatibleEncryptRuleConfigurationEventBuilder.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/CompatibleEncryptRuleConfigurationEventBuilder.java
index bdcb0932939..d977610b4db 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/CompatibleEncryptRuleConfigurationEventBuilder.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/CompatibleEncryptRuleConfigurationEventBuilder.java
@@ -43,14 +43,14 @@ public final class
CompatibleEncryptRuleConfigurationEventBuilder implements Rul
@Override
public Optional<GovernanceEvent> build(final String databaseName, final
DataChangedEvent event) {
- if
(!encryptRuleNodePath.getRootNodePath().isValidatedPath(event.getKey()) ||
Strings.isNullOrEmpty(event.getValue())) {
+ if (!encryptRuleNodePath.getRoot().isValidatedPath(event.getKey()) ||
Strings.isNullOrEmpty(event.getValue())) {
return Optional.empty();
}
- Optional<String> tableName =
encryptRuleNodePath.getNamedRuleItemNodePath(CompatibleEncryptNodeConverter.TABLES).getNameByActiveVersion(event.getKey());
+ Optional<String> tableName =
encryptRuleNodePath.getNamedItem(CompatibleEncryptNodeConverter.TABLES).getNameByActiveVersion(event.getKey());
if (tableName.isPresent() && !Strings.isNullOrEmpty(event.getValue()))
{
return createEncryptConfigEvent(databaseName, tableName.get(),
event);
}
- Optional<String> encryptorName =
encryptRuleNodePath.getNamedRuleItemNodePath(CompatibleEncryptNodeConverter.ENCRYPTORS).getNameByActiveVersion(event.getKey());
+ Optional<String> encryptorName =
encryptRuleNodePath.getNamedItem(CompatibleEncryptNodeConverter.ENCRYPTORS).getNameByActiveVersion(event.getKey());
if (encryptorName.isPresent() &&
!Strings.isNullOrEmpty(event.getValue())) {
return createEncryptorEvent(databaseName, encryptorName.get(),
event);
}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/EncryptRuleConfigurationEventBuilder.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/EncryptRuleConfigurationEventBuilder.java
index 3d45dc9f70c..45365b46d8f 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/EncryptRuleConfigurationEventBuilder.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/event/EncryptRuleConfigurationEventBuilder.java
@@ -41,14 +41,14 @@ public final class EncryptRuleConfigurationEventBuilder
implements RuleConfigura
@Override
public Optional<GovernanceEvent> build(final String databaseName, final
DataChangedEvent event) {
- if
(!encryptRuleNodePath.getRootNodePath().isValidatedPath(event.getKey()) ||
Strings.isNullOrEmpty(event.getValue())) {
+ if (!encryptRuleNodePath.getRoot().isValidatedPath(event.getKey()) ||
Strings.isNullOrEmpty(event.getValue())) {
return Optional.empty();
}
- Optional<String> tableName =
encryptRuleNodePath.getNamedRuleItemNodePath(EncryptNodeConverter.TABLES).getNameByActiveVersion(event.getKey());
+ Optional<String> tableName =
encryptRuleNodePath.getNamedItem(EncryptNodeConverter.TABLES).getNameByActiveVersion(event.getKey());
if (tableName.isPresent() && !Strings.isNullOrEmpty(event.getValue()))
{
return createEncryptConfigEvent(databaseName, tableName.get(),
event);
}
- Optional<String> encryptorName =
encryptRuleNodePath.getNamedRuleItemNodePath(EncryptNodeConverter.ENCRYPTORS).getNameByActiveVersion(event.getKey());
+ Optional<String> encryptorName =
encryptRuleNodePath.getNamedItem(EncryptNodeConverter.ENCRYPTORS).getNameByActiveVersion(event.getKey());
if (encryptorName.isPresent() &&
!Strings.isNullOrEmpty(event.getValue())) {
return createEncryptorEvent(databaseName, encryptorName.get(),
event);
}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlCompatibleEncryptRuleConfigurationSwapper.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlCompatibleEncryptRuleConfigurationSwapper.java
index d8c354a4c8a..4c82be2031f 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlCompatibleEncryptRuleConfigurationSwapper.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlCompatibleEncryptRuleConfigurationSwapper.java
@@ -57,12 +57,12 @@ public final class
NewYamlCompatibleEncryptRuleConfigurationSwapper implements N
public Collection<YamlDataNode> swapToDataNodes(final
CompatibleEncryptRuleConfiguration data) {
Collection<YamlDataNode> result = new LinkedHashSet<>();
for (Entry<String, AlgorithmConfiguration> entry :
data.getEncryptors().entrySet()) {
- result.add(new
YamlDataNode(encryptRuleNodePath.getNamedRuleItemNodePath(CompatibleEncryptNodeConverter.ENCRYPTORS).getPath(entry.getKey()),
+ result.add(new
YamlDataNode(encryptRuleNodePath.getNamedItem(CompatibleEncryptNodeConverter.ENCRYPTORS).getPath(entry.getKey()),
YamlEngine.marshal(algorithmSwapper.swapToYamlConfiguration(entry.getValue()))));
}
for (EncryptTableRuleConfiguration each : data.getTables()) {
result.add(new YamlDataNode(
-
encryptRuleNodePath.getNamedRuleItemNodePath(CompatibleEncryptNodeConverter.TABLES).getPath(each.getName()),
YamlEngine.marshal(tableSwapper.swapToYamlConfiguration(each))));
+
encryptRuleNodePath.getNamedItem(CompatibleEncryptNodeConverter.TABLES).getPath(each.getName()),
YamlEngine.marshal(tableSwapper.swapToYamlConfiguration(each))));
}
return result;
}
@@ -72,9 +72,9 @@ public final class
NewYamlCompatibleEncryptRuleConfigurationSwapper implements N
Collection<EncryptTableRuleConfiguration> tables = new LinkedList<>();
Map<String, AlgorithmConfiguration> encryptors = new HashMap<>();
for (YamlDataNode each : dataNodes) {
-
encryptRuleNodePath.getNamedRuleItemNodePath(CompatibleEncryptNodeConverter.TABLES).getName(each.getKey())
+
encryptRuleNodePath.getNamedItem(CompatibleEncryptNodeConverter.TABLES).getName(each.getKey())
.ifPresent(optional ->
tables.add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlCompatibleEncryptTableRuleConfiguration.class))));
-
encryptRuleNodePath.getNamedRuleItemNodePath(CompatibleEncryptNodeConverter.ENCRYPTORS).getName(each.getKey())
+
encryptRuleNodePath.getNamedItem(CompatibleEncryptNodeConverter.ENCRYPTORS).getName(each.getKey())
.ifPresent(optional -> encryptors.put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
}
return new CompatibleEncryptRuleConfiguration(tables, encryptors);
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlEncryptRuleConfigurationSwapper.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlEncryptRuleConfigurationSwapper.java
index ac008cac618..3e207c3c2f2 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlEncryptRuleConfigurationSwapper.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlEncryptRuleConfigurationSwapper.java
@@ -54,11 +54,11 @@ public final class NewYamlEncryptRuleConfigurationSwapper
implements NewYamlRule
public Collection<YamlDataNode> swapToDataNodes(final
EncryptRuleConfiguration data) {
Collection<YamlDataNode> result = new LinkedHashSet<>();
for (Entry<String, AlgorithmConfiguration> entry :
data.getEncryptors().entrySet()) {
- result.add(new
YamlDataNode(encryptRuleNodePath.getNamedRuleItemNodePath(EncryptNodeConverter.ENCRYPTORS).getPath(entry.getKey()),
+ result.add(new
YamlDataNode(encryptRuleNodePath.getNamedItem(EncryptNodeConverter.ENCRYPTORS).getPath(entry.getKey()),
YamlEngine.marshal(algorithmSwapper.swapToYamlConfiguration(entry.getValue()))));
}
for (EncryptTableRuleConfiguration each : data.getTables()) {
- result.add(new
YamlDataNode(encryptRuleNodePath.getNamedRuleItemNodePath(EncryptNodeConverter.TABLES).getPath(each.getName()),
+ result.add(new
YamlDataNode(encryptRuleNodePath.getNamedItem(EncryptNodeConverter.TABLES).getPath(each.getName()),
YamlEngine.marshal(tableSwapper.swapToYamlConfiguration(each))));
}
return result;
@@ -69,9 +69,9 @@ public final class NewYamlEncryptRuleConfigurationSwapper
implements NewYamlRule
Collection<EncryptTableRuleConfiguration> tables = new LinkedList<>();
Map<String, AlgorithmConfiguration> encryptors = new HashMap<>();
for (YamlDataNode each : dataNodes) {
-
encryptRuleNodePath.getNamedRuleItemNodePath(EncryptNodeConverter.TABLES).getName(each.getKey())
+
encryptRuleNodePath.getNamedItem(EncryptNodeConverter.TABLES).getName(each.getKey())
.ifPresent(optional ->
tables.add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlEncryptTableRuleConfiguration.class))));
-
encryptRuleNodePath.getNamedRuleItemNodePath(EncryptNodeConverter.ENCRYPTORS).getName(each.getKey())
+
encryptRuleNodePath.getNamedItem(EncryptNodeConverter.ENCRYPTORS).getName(each.getKey())
.ifPresent(optional -> encryptors.put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
}
return new EncryptRuleConfiguration(tables, encryptors);
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/MaskRuleConfigurationEventBuilder.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/MaskRuleConfigurationEventBuilder.java
index d3abe6eb603..10d4343d49f 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/MaskRuleConfigurationEventBuilder.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/event/MaskRuleConfigurationEventBuilder.java
@@ -41,14 +41,14 @@ public final class MaskRuleConfigurationEventBuilder
implements RuleConfiguratio
@Override
public Optional<GovernanceEvent> build(final String databaseName, final
DataChangedEvent event) {
- if
(!maskRuleNodePath.getRootNodePath().isValidatedPath(event.getKey()) ||
Strings.isNullOrEmpty(event.getValue())) {
+ if (!maskRuleNodePath.getRoot().isValidatedPath(event.getKey()) ||
Strings.isNullOrEmpty(event.getValue())) {
return Optional.empty();
}
- Optional<String> tableName =
maskRuleNodePath.getNamedRuleItemNodePath(MaskNodeConverter.TABLES).getNameByActiveVersion(event.getKey());
+ Optional<String> tableName =
maskRuleNodePath.getNamedItem(MaskNodeConverter.TABLES).getNameByActiveVersion(event.getKey());
if (tableName.isPresent() && !Strings.isNullOrEmpty(event.getValue()))
{
return createMaskConfigEvent(databaseName, tableName.get(), event);
}
- Optional<String> algorithmName =
maskRuleNodePath.getNamedRuleItemNodePath(MaskNodeConverter.ALGORITHMS).getNameByActiveVersion(event.getKey());
+ Optional<String> algorithmName =
maskRuleNodePath.getNamedItem(MaskNodeConverter.ALGORITHMS).getNameByActiveVersion(event.getKey());
if (algorithmName.isPresent() &&
!Strings.isNullOrEmpty(event.getValue())) {
return createMaskAlgorithmEvent(databaseName, algorithmName.get(),
event);
}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java
index 3a578aeebff..1857564b17b 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java
@@ -53,11 +53,11 @@ public final class NewYamlMaskRuleConfigurationSwapper
implements NewYamlRuleCon
public Collection<YamlDataNode> swapToDataNodes(final
MaskRuleConfiguration data) {
Collection<YamlDataNode> result = new LinkedHashSet<>();
for (Map.Entry<String, AlgorithmConfiguration> entry :
data.getMaskAlgorithms().entrySet()) {
- result.add(new
YamlDataNode(maskRuleNodePath.getNamedRuleItemNodePath(MaskNodeConverter.ALGORITHMS).getPath(entry.getKey()),
+ result.add(new
YamlDataNode(maskRuleNodePath.getNamedItem(MaskNodeConverter.ALGORITHMS).getPath(entry.getKey()),
YamlEngine.marshal(algorithmSwapper.swapToYamlConfiguration(entry.getValue()))));
}
for (MaskTableRuleConfiguration each : data.getTables()) {
- result.add(new
YamlDataNode(maskRuleNodePath.getNamedRuleItemNodePath(MaskNodeConverter.TABLES).getPath(each.getName()),
YamlEngine.marshal(tableSwapper.swapToYamlConfiguration(each))));
+ result.add(new
YamlDataNode(maskRuleNodePath.getNamedItem(MaskNodeConverter.TABLES).getPath(each.getName()),
YamlEngine.marshal(tableSwapper.swapToYamlConfiguration(each))));
}
return result;
}
@@ -67,9 +67,9 @@ public final class NewYamlMaskRuleConfigurationSwapper
implements NewYamlRuleCon
Collection<MaskTableRuleConfiguration> tables = new LinkedList<>();
Map<String, AlgorithmConfiguration> algorithms = new LinkedHashMap<>();
for (YamlDataNode each : dataNodes) {
-
maskRuleNodePath.getNamedRuleItemNodePath(MaskNodeConverter.TABLES).getName(each.getKey())
+
maskRuleNodePath.getNamedItem(MaskNodeConverter.TABLES).getName(each.getKey())
.ifPresent(optional ->
tables.add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlMaskTableRuleConfiguration.class))));
-
maskRuleNodePath.getNamedRuleItemNodePath(MaskNodeConverter.ALGORITHMS).getName(each.getKey())
+
maskRuleNodePath.getNamedItem(MaskNodeConverter.ALGORITHMS).getName(each.getKey())
.ifPresent(optional -> algorithms.put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
}
return new MaskRuleConfiguration(tables, algorithms);
diff --git
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/ReadwriteSplittingRuleConfigurationEventBuilder.java
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/ReadwriteSplittingRuleConfigurationEventBuilder.java
index 31dd2ee5ace..f24d2c4817a 100644
---
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/ReadwriteSplittingRuleConfigurationEventBuilder.java
+++
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/event/ReadwriteSplittingRuleConfigurationEventBuilder.java
@@ -41,14 +41,14 @@ public final class
ReadwriteSplittingRuleConfigurationEventBuilder implements Ru
@Override
public Optional<GovernanceEvent> build(final String databaseName, final
DataChangedEvent event) {
- if
(!readwriteSplittingRuleNodePath.getRootNodePath().isValidatedPath(event.getKey())
|| Strings.isNullOrEmpty(event.getValue())) {
+ if
(!readwriteSplittingRuleNodePath.getRoot().isValidatedPath(event.getKey()) ||
Strings.isNullOrEmpty(event.getValue())) {
return Optional.empty();
}
- Optional<String> groupName =
readwriteSplittingRuleNodePath.getNamedRuleItemNodePath(ReadwriteSplittingNodeConverter.DATA_SOURCES).getNameByActiveVersion(event.getKey());
+ Optional<String> groupName =
readwriteSplittingRuleNodePath.getNamedItem(ReadwriteSplittingNodeConverter.DATA_SOURCES).getNameByActiveVersion(event.getKey());
if (groupName.isPresent() && !Strings.isNullOrEmpty(event.getValue()))
{
return createReadwriteSplittingConfigEvent(databaseName,
groupName.get(), event);
}
- Optional<String> loadBalancerName =
readwriteSplittingRuleNodePath.getNamedRuleItemNodePath(ReadwriteSplittingNodeConverter.LOAD_BALANCERS).getNameByActiveVersion(event.getKey());
+ Optional<String> loadBalancerName =
readwriteSplittingRuleNodePath.getNamedItem(ReadwriteSplittingNodeConverter.LOAD_BALANCERS).getNameByActiveVersion(event.getKey());
if (loadBalancerName.isPresent() &&
!Strings.isNullOrEmpty(event.getValue())) {
return createLoadBalanceEvent(databaseName,
loadBalancerName.get(), event);
}
diff --git
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java
index f71f246a4ce..552786bda0a 100644
---
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java
+++
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java
@@ -52,11 +52,11 @@ public final class
NewYamlReadwriteSplittingRuleConfigurationSwapper implements
public Collection<YamlDataNode> swapToDataNodes(final
ReadwriteSplittingRuleConfiguration data) {
Collection<YamlDataNode> result = new LinkedHashSet<>();
for (Map.Entry<String, AlgorithmConfiguration> entry :
data.getLoadBalancers().entrySet()) {
- result.add(new
YamlDataNode(readwriteSplittingRuleNodePath.getNamedRuleItemNodePath(ReadwriteSplittingNodeConverter.LOAD_BALANCERS).getPath(entry.getKey()),
+ result.add(new
YamlDataNode(readwriteSplittingRuleNodePath.getNamedItem(ReadwriteSplittingNodeConverter.LOAD_BALANCERS).getPath(entry.getKey()),
YamlEngine.marshal(algorithmSwapper.swapToYamlConfiguration(entry.getValue()))));
}
for (ReadwriteSplittingDataSourceRuleConfiguration each :
data.getDataSources()) {
- result.add(new
YamlDataNode(readwriteSplittingRuleNodePath.getNamedRuleItemNodePath(ReadwriteSplittingNodeConverter.DATA_SOURCES).getPath(each.getName()),
+ result.add(new
YamlDataNode(readwriteSplittingRuleNodePath.getNamedItem(ReadwriteSplittingNodeConverter.DATA_SOURCES).getPath(each.getName()),
YamlEngine.marshal(swapToYamlConfiguration(each))));
}
return result;
@@ -76,9 +76,9 @@ public final class
NewYamlReadwriteSplittingRuleConfigurationSwapper implements
Collection<ReadwriteSplittingDataSourceRuleConfiguration> dataSources
= new LinkedList<>();
Map<String, AlgorithmConfiguration> loadBalancerMap = new
LinkedHashMap<>();
for (YamlDataNode each : dataNodes) {
-
readwriteSplittingRuleNodePath.getNamedRuleItemNodePath(ReadwriteSplittingNodeConverter.DATA_SOURCES).getName(each.getKey())
+
readwriteSplittingRuleNodePath.getNamedItem(ReadwriteSplittingNodeConverter.DATA_SOURCES).getName(each.getKey())
.ifPresent(optional ->
dataSources.add(swapDataSource(optional, YamlEngine.unmarshal(each.getValue(),
YamlReadwriteSplittingDataSourceRuleConfiguration.class))));
-
readwriteSplittingRuleNodePath.getNamedRuleItemNodePath(ReadwriteSplittingNodeConverter.LOAD_BALANCERS).getName(each.getKey())
+
readwriteSplittingRuleNodePath.getNamedItem(ReadwriteSplittingNodeConverter.LOAD_BALANCERS).getName(each.getKey())
.ifPresent(optional -> loadBalancerMap.put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
}
return new ReadwriteSplittingRuleConfiguration(dataSources,
loadBalancerMap);
diff --git
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleConfigurationEventBuilder.java
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleConfigurationEventBuilder.java
index 4b482e43154..64a9ebca28b 100644
---
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleConfigurationEventBuilder.java
+++
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/event/ShadowRuleConfigurationEventBuilder.java
@@ -46,22 +46,22 @@ public final class ShadowRuleConfigurationEventBuilder
implements RuleConfigurat
@Override
public Optional<GovernanceEvent> build(final String databaseName, final
DataChangedEvent event) {
- if
(!shadowRuleNodePath.getRootNodePath().isValidatedPath(event.getKey()) ||
Strings.isNullOrEmpty(event.getValue())) {
+ if (!shadowRuleNodePath.getRoot().isValidatedPath(event.getKey()) ||
Strings.isNullOrEmpty(event.getValue())) {
return Optional.empty();
}
- Optional<String> dataSourceName =
shadowRuleNodePath.getNamedRuleItemNodePath(ShadowNodeConverter.DATA_SOURCES).getNameByActiveVersion(event.getKey());
+ Optional<String> dataSourceName =
shadowRuleNodePath.getNamedItem(ShadowNodeConverter.DATA_SOURCES).getNameByActiveVersion(event.getKey());
if (dataSourceName.isPresent() &&
!Strings.isNullOrEmpty(event.getValue())) {
return createShadowConfigEvent(databaseName, dataSourceName.get(),
event);
}
- Optional<String> tableName =
shadowRuleNodePath.getNamedRuleItemNodePath(ShadowNodeConverter.TABLES).getNameByActiveVersion(event.getKey());
+ Optional<String> tableName =
shadowRuleNodePath.getNamedItem(ShadowNodeConverter.TABLES).getNameByActiveVersion(event.getKey());
if (tableName.isPresent() && !Strings.isNullOrEmpty(event.getValue()))
{
return createShadowTableConfigEvent(databaseName, tableName.get(),
event);
}
- Optional<String> algorithmName =
shadowRuleNodePath.getNamedRuleItemNodePath(ShadowNodeConverter.ALGORITHMS).getNameByActiveVersion(event.getKey());
+ Optional<String> algorithmName =
shadowRuleNodePath.getNamedItem(ShadowNodeConverter.ALGORITHMS).getNameByActiveVersion(event.getKey());
if (algorithmName.isPresent() &&
!Strings.isNullOrEmpty(event.getValue())) {
return createShadowAlgorithmEvent(databaseName,
algorithmName.get(), event);
}
- if
(shadowRuleNodePath.getUniqueRuleItemNodePaths(ShadowNodeConverter.DEFAULT_ALGORITHM).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
+ if
(shadowRuleNodePath.getUniqueItem(ShadowNodeConverter.DEFAULT_ALGORITHM).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
return createDefaultShadowAlgorithmNameEvent(databaseName, event);
}
return Optional.empty();
diff --git
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/NewYamlShadowRuleConfigurationSwapper.java
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/NewYamlShadowRuleConfigurationSwapper.java
index 8f4064a8fcb..446b36c8774 100644
---
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/NewYamlShadowRuleConfigurationSwapper.java
+++
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/NewYamlShadowRuleConfigurationSwapper.java
@@ -54,18 +54,18 @@ public final class NewYamlShadowRuleConfigurationSwapper
implements NewYamlRuleC
public Collection<YamlDataNode> swapToDataNodes(final
ShadowRuleConfiguration data) {
Collection<YamlDataNode> result = new LinkedHashSet<>();
for (Entry<String, AlgorithmConfiguration> entry :
data.getShadowAlgorithms().entrySet()) {
- result.add(new
YamlDataNode(shadowRuleNodePath.getNamedRuleItemNodePath(ShadowNodeConverter.ALGORITHMS).getPath(entry.getKey()),
+ result.add(new
YamlDataNode(shadowRuleNodePath.getNamedItem(ShadowNodeConverter.ALGORITHMS).getPath(entry.getKey()),
YamlEngine.marshal(algorithmSwapper.swapToYamlConfiguration(entry.getValue()))));
}
if (!Strings.isNullOrEmpty(data.getDefaultShadowAlgorithmName())) {
- result.add(new
YamlDataNode(shadowRuleNodePath.getUniqueRuleItemNodePaths(ShadowNodeConverter.DEFAULT_ALGORITHM).getPath(),
data.getDefaultShadowAlgorithmName()));
+ result.add(new
YamlDataNode(shadowRuleNodePath.getUniqueItem(ShadowNodeConverter.DEFAULT_ALGORITHM).getPath(),
data.getDefaultShadowAlgorithmName()));
}
for (ShadowDataSourceConfiguration each : data.getDataSources()) {
- result.add(new
YamlDataNode(shadowRuleNodePath.getNamedRuleItemNodePath(ShadowNodeConverter.DATA_SOURCES).getPath(each.getName()),
+ result.add(new
YamlDataNode(shadowRuleNodePath.getNamedItem(ShadowNodeConverter.DATA_SOURCES).getPath(each.getName()),
YamlEngine.marshal(swapToDataSourceYamlConfiguration(each))));
}
for (Entry<String, ShadowTableConfiguration> entry :
data.getTables().entrySet()) {
- result.add(new
YamlDataNode(shadowRuleNodePath.getNamedRuleItemNodePath(ShadowNodeConverter.TABLES).getPath(entry.getKey()),
+ result.add(new
YamlDataNode(shadowRuleNodePath.getNamedItem(ShadowNodeConverter.TABLES).getPath(entry.getKey()),
YamlEngine.marshal(tableSwapper.swapToYamlConfiguration(entry.getValue()))));
}
return result;
@@ -82,13 +82,13 @@ public final class NewYamlShadowRuleConfigurationSwapper
implements NewYamlRuleC
public ShadowRuleConfiguration swapToObject(final Collection<YamlDataNode>
dataNodes) {
ShadowRuleConfiguration result = new ShadowRuleConfiguration();
for (YamlDataNode each : dataNodes) {
-
shadowRuleNodePath.getNamedRuleItemNodePath(ShadowNodeConverter.DATA_SOURCES).getName(each.getKey())
+
shadowRuleNodePath.getNamedItem(ShadowNodeConverter.DATA_SOURCES).getName(each.getKey())
.ifPresent(optional ->
result.getDataSources().add(swapDataSource(optional,
YamlEngine.unmarshal(each.getValue(),
YamlShadowDataSourceConfiguration.class))));
-
shadowRuleNodePath.getNamedRuleItemNodePath(ShadowNodeConverter.TABLES).getName(each.getKey())
+
shadowRuleNodePath.getNamedItem(ShadowNodeConverter.TABLES).getName(each.getKey())
.ifPresent(optional -> result.getTables().put(optional,
tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShadowTableConfiguration.class))));
-
shadowRuleNodePath.getNamedRuleItemNodePath(ShadowNodeConverter.ALGORITHMS).getName(each.getKey())
+
shadowRuleNodePath.getNamedItem(ShadowNodeConverter.ALGORITHMS).getName(each.getKey())
.ifPresent(optional ->
result.getShadowAlgorithms().put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
- if
(shadowRuleNodePath.getUniqueRuleItemNodePaths(ShadowNodeConverter.DEFAULT_ALGORITHM).isValidatedPath(each.getKey()))
{
+ if
(shadowRuleNodePath.getUniqueItem(ShadowNodeConverter.DEFAULT_ALGORITHM).isValidatedPath(each.getKey()))
{
result.setDefaultShadowAlgorithmName(each.getValue());
}
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/ShardingRuleConfigurationEventBuilder.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/ShardingRuleConfigurationEventBuilder.java
index 12e78b78782..64efd26cf21 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/ShardingRuleConfigurationEventBuilder.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/event/ShardingRuleConfigurationEventBuilder.java
@@ -66,49 +66,49 @@ public final class ShardingRuleConfigurationEventBuilder
implements RuleConfigur
@Override
public Optional<GovernanceEvent> build(final String databaseName, final
DataChangedEvent event) {
- if
(!shardingRuleNodePath.getRootNodePath().isValidatedPath(event.getKey()) ||
Strings.isNullOrEmpty(event.getValue())) {
+ if (!shardingRuleNodePath.getRoot().isValidatedPath(event.getKey()) ||
Strings.isNullOrEmpty(event.getValue())) {
return Optional.empty();
}
- Optional<String> tableName =
shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.TABLES).getNameByActiveVersion(event.getKey());
+ Optional<String> tableName =
shardingRuleNodePath.getNamedItem(ShardingNodeConverter.TABLES).getNameByActiveVersion(event.getKey());
if (tableName.isPresent() && !Strings.isNullOrEmpty(event.getValue()))
{
return createShardingTableConfigEvent(databaseName,
tableName.get(), event);
}
- Optional<String> autoTableName =
shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.AUTO_TABLES).getNameByActiveVersion(event.getKey());
+ Optional<String> autoTableName =
shardingRuleNodePath.getNamedItem(ShardingNodeConverter.AUTO_TABLES).getNameByActiveVersion(event.getKey());
if (autoTableName.isPresent() &&
!Strings.isNullOrEmpty(event.getValue())) {
return createShardingAutoTableConfigEvent(databaseName,
autoTableName.get(), event);
}
- Optional<String> bindingTableName =
shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.BINDING_TABLES).getNameByActiveVersion(event.getKey());
+ Optional<String> bindingTableName =
shardingRuleNodePath.getNamedItem(ShardingNodeConverter.BINDING_TABLES).getNameByActiveVersion(event.getKey());
if (bindingTableName.isPresent() &&
!Strings.isNullOrEmpty(event.getValue())) {
return createShardingTableReferenceConfigEvent(databaseName,
bindingTableName.get(), event);
}
- if
(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_DATABASE_STRATEGY).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
+ if
(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_DATABASE_STRATEGY).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
return createDefaultDatabaseStrategyConfigEvent(databaseName,
event);
}
- if
(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_TABLE_STRATEGY).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
+ if
(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_TABLE_STRATEGY).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
return createDefaultTableStrategyConfigEvent(databaseName, event);
}
- if
(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_KEY_GENERATE_STRATEGY).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
+ if
(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_KEY_GENERATE_STRATEGY).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
return createDefaultKeyGenerateStrategyConfigEvent(databaseName,
event);
}
- if
(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_AUDIT_STRATEGY).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
+ if
(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_AUDIT_STRATEGY).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
return
createDefaultShardingAuditorStrategyConfigEvent(databaseName, event);
}
- if
(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_SHARDING_COLUMN).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
+ if
(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_SHARDING_COLUMN).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
return createDefaultShardingColumnEvent(databaseName, event);
}
- Optional<String> algorithmName =
shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.ALGORITHMS).getNameByActiveVersion(event.getKey());
+ Optional<String> algorithmName =
shardingRuleNodePath.getNamedItem(ShardingNodeConverter.ALGORITHMS).getNameByActiveVersion(event.getKey());
if (algorithmName.isPresent() &&
!Strings.isNullOrEmpty(event.getValue())) {
return createShardingAlgorithmEvent(databaseName,
algorithmName.get(), event);
}
- Optional<String> keyGeneratorName =
shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.KEY_GENERATORS).getNameByActiveVersion(event.getKey());
+ Optional<String> keyGeneratorName =
shardingRuleNodePath.getNamedItem(ShardingNodeConverter.KEY_GENERATORS).getNameByActiveVersion(event.getKey());
if (keyGeneratorName.isPresent() &&
!Strings.isNullOrEmpty(event.getValue())) {
return createKeyGeneratorEvent(databaseName,
keyGeneratorName.get(), event);
}
- Optional<String> auditorName =
shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.AUDITORS).getNameByActiveVersion(event.getKey());
+ Optional<String> auditorName =
shardingRuleNodePath.getNamedItem(ShardingNodeConverter.AUDITORS).getNameByActiveVersion(event.getKey());
if (auditorName.isPresent() &&
!Strings.isNullOrEmpty(event.getValue())) {
return createAuditorEvent(databaseName, auditorName.get(), event);
}
- if
(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.SHARDING_CACHE).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
+ if
(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.SHARDING_CACHE).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
return createShardingCacheEvent(databaseName, event);
}
return Optional.empty();
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapper.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapper.java
index 397886a564a..b9e9bc824dc 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapper.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapper.java
@@ -77,10 +77,10 @@ public final class NewYamlShardingRuleConfigurationSwapper
implements NewYamlRul
swapStrategies(data, result);
swapTableRules(data, result);
if (null != data.getDefaultShardingColumn()) {
- result.add(new
YamlDataNode(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_SHARDING_COLUMN).getPath(),
data.getDefaultShardingColumn()));
+ result.add(new
YamlDataNode(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_SHARDING_COLUMN).getPath(),
data.getDefaultShardingColumn()));
}
if (null != data.getShardingCache()) {
- result.add(new
YamlDataNode(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.SHARDING_CACHE).getPath(),
+ result.add(new
YamlDataNode(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.SHARDING_CACHE).getPath(),
YamlEngine.marshal(shardingCacheYamlSwapper.swapToYamlConfiguration(data.getShardingCache()))));
}
return result;
@@ -88,49 +88,49 @@ public final class NewYamlShardingRuleConfigurationSwapper
implements NewYamlRul
private void swapAlgorithms(final ShardingRuleConfiguration data, final
Collection<YamlDataNode> result) {
for (Entry<String, AlgorithmConfiguration> each :
data.getShardingAlgorithms().entrySet()) {
- result.add(new
YamlDataNode(shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.ALGORITHMS).getPath(each.getKey()),
+ result.add(new
YamlDataNode(shardingRuleNodePath.getNamedItem(ShardingNodeConverter.ALGORITHMS).getPath(each.getKey()),
YamlEngine.marshal(algorithmSwapper.swapToYamlConfiguration(each.getValue()))));
}
for (Entry<String, AlgorithmConfiguration> each :
data.getKeyGenerators().entrySet()) {
- result.add(new
YamlDataNode(shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.KEY_GENERATORS).getPath(each.getKey()),
+ result.add(new
YamlDataNode(shardingRuleNodePath.getNamedItem(ShardingNodeConverter.KEY_GENERATORS).getPath(each.getKey()),
YamlEngine.marshal(algorithmSwapper.swapToYamlConfiguration(each.getValue()))));
}
for (Entry<String, AlgorithmConfiguration> each :
data.getAuditors().entrySet()) {
- result.add(new
YamlDataNode(shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.AUDITORS).getPath(each.getKey()),
+ result.add(new
YamlDataNode(shardingRuleNodePath.getNamedItem(ShardingNodeConverter.AUDITORS).getPath(each.getKey()),
YamlEngine.marshal(algorithmSwapper.swapToYamlConfiguration(each.getValue()))));
}
}
private void swapStrategies(final ShardingRuleConfiguration data, final
Collection<YamlDataNode> result) {
if (null != data.getDefaultDatabaseShardingStrategy()) {
- result.add(new
YamlDataNode(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_DATABASE_STRATEGY).getPath(),
+ result.add(new
YamlDataNode(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_DATABASE_STRATEGY).getPath(),
YamlEngine.marshal(shardingStrategySwapper.swapToYamlConfiguration(data.getDefaultDatabaseShardingStrategy()))));
}
if (null != data.getDefaultTableShardingStrategy()) {
- result.add(new
YamlDataNode(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_TABLE_STRATEGY).getPath(),
+ result.add(new
YamlDataNode(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_TABLE_STRATEGY).getPath(),
YamlEngine.marshal(shardingStrategySwapper.swapToYamlConfiguration(data.getDefaultTableShardingStrategy()))));
}
if (null != data.getDefaultKeyGenerateStrategy()) {
- result.add(new
YamlDataNode(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_KEY_GENERATE_STRATEGY).getPath(),
+ result.add(new
YamlDataNode(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_KEY_GENERATE_STRATEGY).getPath(),
YamlEngine.marshal(keyGenerateStrategySwapper.swapToYamlConfiguration(data.getDefaultKeyGenerateStrategy()))));
}
if (null != data.getDefaultAuditStrategy()) {
- result.add(new
YamlDataNode(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_AUDIT_STRATEGY).getPath(),
+ result.add(new
YamlDataNode(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_AUDIT_STRATEGY).getPath(),
YamlEngine.marshal(auditStrategySwapper.swapToYamlConfiguration(data.getDefaultAuditStrategy()))));
}
}
private void swapTableRules(final ShardingRuleConfiguration data, final
Collection<YamlDataNode> result) {
for (ShardingTableRuleConfiguration each : data.getTables()) {
- result.add(new
YamlDataNode(shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.TABLES).getPath(each.getLogicTable()),
+ result.add(new
YamlDataNode(shardingRuleNodePath.getNamedItem(ShardingNodeConverter.TABLES).getPath(each.getLogicTable()),
YamlEngine.marshal(tableSwapper.swapToYamlConfiguration(each))));
}
for (ShardingAutoTableRuleConfiguration each : data.getAutoTables()) {
- result.add(new
YamlDataNode(shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.AUTO_TABLES).getPath(each.getLogicTable()),
+ result.add(new
YamlDataNode(shardingRuleNodePath.getNamedItem(ShardingNodeConverter.AUTO_TABLES).getPath(each.getLogicTable()),
YamlEngine.marshal(autoTableYamlSwapper.swapToYamlConfiguration(each))));
}
for (ShardingTableReferenceRuleConfiguration each :
data.getBindingTableGroups()) {
- result.add(new
YamlDataNode(shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.BINDING_TABLES).getPath(each.getName()),
+ result.add(new
YamlDataNode(shardingRuleNodePath.getNamedItem(ShardingNodeConverter.BINDING_TABLES).getPath(each.getName()),
YamlShardingTableReferenceRuleConfigurationConverter.convertToYamlString(each)));
}
}
@@ -139,29 +139,29 @@ public final class
NewYamlShardingRuleConfigurationSwapper implements NewYamlRul
public ShardingRuleConfiguration swapToObject(final
Collection<YamlDataNode> dataNodes) {
ShardingRuleConfiguration result = new ShardingRuleConfiguration();
for (YamlDataNode each : dataNodes) {
-
shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.TABLES).getName(each.getKey())
+
shardingRuleNodePath.getNamedItem(ShardingNodeConverter.TABLES).getName(each.getKey())
.ifPresent(optional ->
result.getTables().add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlTableRuleConfiguration.class))));
-
shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.AUTO_TABLES).getName(each.getKey())
+
shardingRuleNodePath.getNamedItem(ShardingNodeConverter.AUTO_TABLES).getName(each.getKey())
.ifPresent(optional ->
result.getAutoTables().add(autoTableYamlSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShardingAutoTableRuleConfiguration.class))));
-
shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.BINDING_TABLES).getName(each.getKey())
+
shardingRuleNodePath.getNamedItem(ShardingNodeConverter.BINDING_TABLES).getName(each.getKey())
.ifPresent(optional ->
result.getBindingTableGroups().add(YamlShardingTableReferenceRuleConfigurationConverter.convertToObject(each.getValue())));
-
shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.ALGORITHMS).getName(each.getKey())
+
shardingRuleNodePath.getNamedItem(ShardingNodeConverter.ALGORITHMS).getName(each.getKey())
.ifPresent(optional ->
result.getShardingAlgorithms().put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
-
shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.KEY_GENERATORS).getName(each.getKey())
+
shardingRuleNodePath.getNamedItem(ShardingNodeConverter.KEY_GENERATORS).getName(each.getKey())
.ifPresent(optional ->
result.getKeyGenerators().put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
-
shardingRuleNodePath.getNamedRuleItemNodePath(ShardingNodeConverter.AUDITORS).getName(each.getKey())
+
shardingRuleNodePath.getNamedItem(ShardingNodeConverter.AUDITORS).getName(each.getKey())
.ifPresent(optional -> result.getAuditors().put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
- if
(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_DATABASE_STRATEGY).isValidatedPath(each.getKey()))
{
+ if
(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_DATABASE_STRATEGY).isValidatedPath(each.getKey()))
{
result.setDefaultDatabaseShardingStrategy(shardingStrategySwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShardingStrategyConfiguration.class)));
- } else if
(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_TABLE_STRATEGY).isValidatedPath(each.getKey()))
{
+ } else if
(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_TABLE_STRATEGY).isValidatedPath(each.getKey()))
{
result.setDefaultTableShardingStrategy(shardingStrategySwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShardingStrategyConfiguration.class)));
- } else if
(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_KEY_GENERATE_STRATEGY).isValidatedPath(each.getKey()))
{
+ } else if
(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_KEY_GENERATE_STRATEGY).isValidatedPath(each.getKey()))
{
result.setDefaultKeyGenerateStrategy(keyGenerateStrategySwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlKeyGenerateStrategyConfiguration.class)));
- } else if
(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_AUDIT_STRATEGY).isValidatedPath(each.getKey()))
{
+ } else if
(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_AUDIT_STRATEGY).isValidatedPath(each.getKey()))
{
result.setDefaultAuditStrategy(auditStrategySwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShardingAuditStrategyConfiguration.class)));
- } else if
(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.DEFAULT_SHARDING_COLUMN).isValidatedPath(each.getKey()))
{
+ } else if
(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.DEFAULT_SHARDING_COLUMN).isValidatedPath(each.getKey()))
{
result.setDefaultShardingColumn(each.getValue());
- } else if
(shardingRuleNodePath.getUniqueRuleItemNodePaths(ShardingNodeConverter.SHARDING_CACHE).isValidatedPath(each.getKey()))
{
+ } else if
(shardingRuleNodePath.getUniqueItem(ShardingNodeConverter.SHARDING_CACHE).isValidatedPath(each.getKey()))
{
result.setShardingCache(shardingCacheYamlSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShardingCacheConfiguration.class)));
}
}
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/RuleNodePath.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/RuleNodePath.java
index 7eaaf9c0ae8..5dfb6e71a16 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/RuleNodePath.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/RuleNodePath.java
@@ -32,22 +32,22 @@ import java.util.Map;
public final class RuleNodePath {
@Getter
- private final RuleRootNodePath rootNodePath;
+ private final RuleRootNodePath root;
- private final Map<String, NamedRuleItemNodePath> namedRuleItemNodePaths;
+ private final Map<String, NamedRuleItemNodePath> namedItems;
- private final Map<String, UniqueRuleItemNodePath> uniqueRuleItemNodePaths;
+ private final Map<String, UniqueRuleItemNodePath> uniqueItems;
public RuleNodePath(final String ruleType, final Collection<String>
namedRuleItemNodePathTypes, final Collection<String>
uniqueRuleItemNodePathTypes) {
- rootNodePath = new RuleRootNodePath(ruleType);
- namedRuleItemNodePaths =
getNamedRuleItemNodePathMap(namedRuleItemNodePathTypes);
- uniqueRuleItemNodePaths =
getUniqueRuleItemNodePathMap(uniqueRuleItemNodePathTypes);
+ root = new RuleRootNodePath(ruleType);
+ namedItems = getNamedRuleItemNodePathMap(namedRuleItemNodePathTypes);
+ uniqueItems =
getUniqueRuleItemNodePathMap(uniqueRuleItemNodePathTypes);
}
private Map<String, NamedRuleItemNodePath>
getNamedRuleItemNodePathMap(final Collection<String>
namedRuleItemNodePathTypes) {
Map<String, NamedRuleItemNodePath> result = new
HashMap<>(namedRuleItemNodePathTypes.size(), 1F);
for (String each : namedRuleItemNodePathTypes) {
- result.put(each, new NamedRuleItemNodePath(rootNodePath, each));
+ result.put(each, new NamedRuleItemNodePath(root, each));
}
return result;
}
@@ -57,9 +57,9 @@ public final class RuleNodePath {
for (String each : uniqueRuleItemNodePathTypes) {
if (each.contains(".")) {
String[] values = each.split("\\.");
- result.put(values[1], new UniqueRuleItemNodePath(rootNodePath,
values[0], values[1]));
+ result.put(values[1], new UniqueRuleItemNodePath(root,
values[0], values[1]));
} else {
- result.put(each, new UniqueRuleItemNodePath(rootNodePath,
each));
+ result.put(each, new UniqueRuleItemNodePath(root, each));
}
}
return result;
@@ -71,8 +71,8 @@ public final class RuleNodePath {
* @param itemType item type
* @return named rule item node path
*/
- public NamedRuleItemNodePath getNamedRuleItemNodePath(final String
itemType) {
- return namedRuleItemNodePaths.get(itemType);
+ public NamedRuleItemNodePath getNamedItem(final String itemType) {
+ return namedItems.get(itemType);
}
/**
@@ -81,7 +81,7 @@ public final class RuleNodePath {
* @param itemType item type
* @return unique rule item node path
*/
- public UniqueRuleItemNodePath getUniqueRuleItemNodePaths(final String
itemType) {
- return uniqueRuleItemNodePaths.get(itemType);
+ public UniqueRuleItemNodePath getUniqueItem(final String itemType) {
+ return uniqueItems.get(itemType);
}
}
diff --git
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleConfigurationEventBuilder.java
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleConfigurationEventBuilder.java
index bfa0767ae39..6694e5c195c 100644
---
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleConfigurationEventBuilder.java
+++
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/event/SingleRuleConfigurationEventBuilder.java
@@ -39,10 +39,10 @@ public final class SingleRuleConfigurationEventBuilder
implements RuleConfigurat
@Override
public Optional<GovernanceEvent> build(final String databaseName, final
DataChangedEvent event) {
- if
(!singleRuleNodePath.getUniqueRuleItemNodePaths(SingleNodeConverter.TABLES).isValidatedPath(event.getKey())
|| Strings.isNullOrEmpty(event.getValue())) {
+ if
(!singleRuleNodePath.getUniqueItem(SingleNodeConverter.TABLES).isValidatedPath(event.getKey())
|| Strings.isNullOrEmpty(event.getValue())) {
return Optional.empty();
}
- if
(singleRuleNodePath.getUniqueRuleItemNodePaths(SingleNodeConverter.TABLES).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
+ if
(singleRuleNodePath.getUniqueItem(SingleNodeConverter.TABLES).isActiveVersionPath(event.getKey())
&& !Strings.isNullOrEmpty(event.getValue())) {
return createSingleConfigEvent(databaseName, event);
}
return Optional.empty();
diff --git
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
index 485a072e267..5b6cab364b9 100644
---
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
+++
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
@@ -52,7 +52,7 @@ public final class NewYamlSingleRuleConfigurationSwapper
implements NewYamlRuleC
@Override
public SingleRuleConfiguration swapToObject(final Collection<YamlDataNode>
dataNodes) {
for (YamlDataNode each : dataNodes) {
- if
(singleRuleNodePath.getUniqueRuleItemNodePaths(SingleNodeConverter.TABLES).isValidatedPath(each.getKey()))
{
+ if
(singleRuleNodePath.getUniqueItem(SingleNodeConverter.TABLES).isValidatedPath(each.getKey()))
{
return swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlSingleRuleConfiguration.class));
}
}