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 8cface84d7d Add RepositoryTupleSwapper framework (#31108)
8cface84d7d is described below

commit 8cface84d7d9595ec42eb163859e19d2800faeb6
Author: Liang Zhang <[email protected]>
AuthorDate: Sat May 4 16:53:51 2024 +0800

    Add RepositoryTupleSwapper framework (#31108)
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
    
    * Add RepositoryTupleSwapper framework
---
 .../changed/BroadcastTableChangedProcessor.java    |   5 +-
 .../config/YamlBroadcastRuleConfiguration.java     |   5 +
 ...astRuleConfigurationRepositoryTupleSwapper.java |  37 ----
 .../yaml/config/YamlEncryptRuleConfiguration.java  |   6 +
 ...yptRuleConfigurationRepositoryTupleSwapper.java |  49 -----
 ...uleConfigurationRepositoryTupleSwapperTest.java |  86 --------
 .../yaml/config/YamlMaskRuleConfiguration.java     |   6 +
 ...askRuleConfigurationRepositoryTupleSwapper.java |  48 -----
 ...uleConfigurationRepositoryTupleSwapperTest.java |  81 --------
 .../YamlReadwriteSplittingRuleConfiguration.java   |   8 +-
 ...ingRuleConfigurationRepositoryTupleSwapper.java |  49 -----
 .../yaml/config/YamlShadowRuleConfiguration.java   |  10 +-
 ...dowRuleConfigurationRepositoryTupleSwapper.java |  64 ------
 .../yaml/config/YamlShardingRuleConfiguration.java |  19 ++
 ...ngTableRegistryCenterTupleKeyNameGenerator.java |  25 +--
 ...ingRuleConfigurationRepositoryTupleSwapper.java | 133 ------------
 .../rule/annotation/RepositoryTupleEntity.java     |  30 +--
 .../pojo/rule/annotation/RepositoryTupleField.java |  40 ++--
 .../RepositoryTupleKeyNameGenerator.java           |  45 +++--
 .../pojo/rule/annotation/RepositoryTupleType.java  |  35 ++--
 .../config/YamlAuthorityRuleConfiguration.java     |   4 +
 ...ityRuleConfigurationRepositoryTupleSwapper.java |  22 --
 .../config/YamlGlobalClockRuleConfiguration.java   |   4 +
 ...ockRuleConfigurationRepositoryTupleSwapper.java |  22 --
 .../yaml/config/YamlLoggingRuleConfiguration.java  |   4 +
 ...ingRuleConfigurationRepositoryTupleSwapper.java |  22 --
 .../config/RepositoryTupleSwapperEngine.java       |   8 +-
 .../database/rule/DatabaseRulePersistService.java  |  16 +-
 .../config/global/GlobalRulePersistService.java    |   6 +-
 .../config/pojo/YamlSingleRuleConfiguration.java   |   5 +
 ...gleRuleConfigurationRepositoryTupleSwapper.java |  26 ---
 .../config/YamlSQLFederationRuleConfiguration.java |   4 +
 ...ionRuleConfigurationRepositoryTupleSwapper.java |  22 --
 .../config/YamlSQLParserRuleConfiguration.java     |   4 +
 ...serRuleConfigurationRepositoryTupleSwapper.java |  22 --
 .../config/YamlSQLTranslatorRuleConfiguration.java |   4 +
 ...torRuleConfigurationRepositoryTupleSwapper.java |  22 --
 .../yaml/config/YamlTrafficRuleConfiguration.java  |   4 +
 ...ficRuleConfigurationRepositoryTupleSwapper.java |  22 --
 .../config/YamlTransactionRuleConfiguration.java   |   4 +
 ...ionRuleConfigurationRepositoryTupleSwapper.java |  22 --
 .../engine/AutoRepositoryTupleSwapperEngine.java   | 224 +++++++++++++++++++++
 .../mode/spi/RepositoryTupleSwapper.java           |  20 --
 .../test/it/yaml/RepositoryTupleSwapperIT.java     |   9 +-
 44 files changed, 417 insertions(+), 886 deletions(-)

diff --git 
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/changed/BroadcastTableChangedProcessor.java
 
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/changed/BroadcastTableChangedProcessor.java
index 42e902189e5..0da2838fd2f 100644
--- 
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/changed/BroadcastTableChangedProcessor.java
+++ 
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/rule/changed/BroadcastTableChangedProcessor.java
@@ -20,13 +20,13 @@ package org.apache.shardingsphere.broadcast.rule.changed;
 import 
org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration;
 import 
org.apache.shardingsphere.broadcast.metadata.nodepath.BroadcastRuleNodePathProvider;
 import org.apache.shardingsphere.broadcast.rule.BroadcastRule;
-import 
org.apache.shardingsphere.broadcast.yaml.config.YamlBroadcastRuleConfiguration;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.rule.event.rule.alter.AlterRuleItemEvent;
 import org.apache.shardingsphere.infra.rule.event.rule.drop.DropRuleItemEvent;
 import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
 import 
org.apache.shardingsphere.mode.spi.RuleItemConfigurationChangedProcessor;
 
+import java.util.LinkedHashSet;
 import java.util.LinkedList;
 
 /**
@@ -34,9 +34,10 @@ import java.util.LinkedList;
  */
 public final class BroadcastTableChangedProcessor implements 
RuleItemConfigurationChangedProcessor<BroadcastRuleConfiguration, 
BroadcastRuleConfiguration> {
     
+    @SuppressWarnings("unchecked")
     @Override
     public BroadcastRuleConfiguration swapRuleItemConfiguration(final 
AlterRuleItemEvent event, final String yamlContent) {
-        return new 
BroadcastRuleConfiguration(YamlEngine.unmarshal(yamlContent, 
YamlBroadcastRuleConfiguration.class).getTables());
+        return new 
BroadcastRuleConfiguration(YamlEngine.unmarshal(yamlContent, 
LinkedHashSet.class));
     }
     
     @Override
diff --git 
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/config/YamlBroadcastRuleConfiguration.java
 
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/config/YamlBroadcastRuleConfiguration.java
index 8ec198e20be..bef67d0a8b1 100644
--- 
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/config/YamlBroadcastRuleConfiguration.java
+++ 
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/config/YamlBroadcastRuleConfiguration.java
@@ -20,8 +20,11 @@ package org.apache.shardingsphere.broadcast.yaml.config;
 import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration;
+import 
org.apache.shardingsphere.broadcast.metadata.nodepath.BroadcastRuleNodePathProvider;
 import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleField;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 
 import java.util.Collection;
 import java.util.LinkedList;
@@ -29,10 +32,12 @@ import java.util.LinkedList;
 /**
  * Broadcast rule configuration for YAML.
  */
+@RepositoryTupleEntity
 @Getter
 @Setter
 public final class YamlBroadcastRuleConfiguration implements 
YamlRuleConfiguration {
     
+    @RepositoryTupleField(value = BroadcastRuleNodePathProvider.TABLES, order 
= 0)
     private Collection<String> tables = new LinkedList<>();
     
     @Override
diff --git 
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/BroadcastRuleConfigurationRepositoryTupleSwapper.java
 
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/BroadcastRuleConfigurationRepositoryTupleSwapper.java
index a09d208348b..b79732a666e 100644
--- 
a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/BroadcastRuleConfigurationRepositoryTupleSwapper.java
+++ 
b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/BroadcastRuleConfigurationRepositoryTupleSwapper.java
@@ -18,51 +18,14 @@
 package org.apache.shardingsphere.broadcast.yaml.swapper;
 
 import org.apache.shardingsphere.broadcast.constant.BroadcastOrder;
-import 
org.apache.shardingsphere.broadcast.metadata.nodepath.BroadcastRuleNodePathProvider;
 import 
org.apache.shardingsphere.broadcast.yaml.config.YamlBroadcastRuleConfiguration;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
-import org.apache.shardingsphere.mode.path.rule.RuleNodePath;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
 /**
  * Broadcast rule configuration repository tuple swapper.
  */
 public final class BroadcastRuleConfigurationRepositoryTupleSwapper implements 
RepositoryTupleSwapper<YamlBroadcastRuleConfiguration> {
     
-    private final RuleNodePath ruleNodePath = new 
BroadcastRuleNodePathProvider().getRuleNodePath();
-    
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlBroadcastRuleConfiguration yamlRuleConfig) {
-        Collection<RepositoryTuple> result = new LinkedList<>();
-        if (!yamlRuleConfig.getTables().isEmpty()) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getUniqueItem(BroadcastRuleNodePathProvider.TABLES).getPath(),
 YamlEngine.marshal(yamlRuleConfig.getTables())));
-        }
-        return result;
-    }
-    
-    @SuppressWarnings("unchecked")
-    @Override
-    public Optional<YamlBroadcastRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        Collection<RepositoryTuple> validTuples = 
repositoryTuples.stream().filter(each -> 
ruleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList());
-        if (validTuples.isEmpty()) {
-            return Optional.empty();
-        }
-        YamlBroadcastRuleConfiguration result = new 
YamlBroadcastRuleConfiguration();
-        for (RepositoryTuple each : validTuples) {
-            if 
(ruleNodePath.getUniqueItem(BroadcastRuleNodePathProvider.TABLES).isValidatedPath(each.getKey()))
 {
-                
result.getTables().addAll(YamlEngine.unmarshal(each.getValue(), 
LinkedHashSet.class));
-            }
-        }
-        return Optional.of(result);
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "broadcast";
diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/config/YamlEncryptRuleConfiguration.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/config/YamlEncryptRuleConfiguration.java
index 1672155bee7..32d313b1277 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/config/YamlEncryptRuleConfiguration.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/config/YamlEncryptRuleConfiguration.java
@@ -20,9 +20,12 @@ package org.apache.shardingsphere.encrypt.yaml.config;
 import lombok.Getter;
 import lombok.Setter;
 import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
+import 
org.apache.shardingsphere.encrypt.metadata.nodepath.EncryptRuleNodePathProvider;
 import 
org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptTableRuleConfiguration;
 import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleField;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -30,12 +33,15 @@ import java.util.Map;
 /**
  * Encrypt rule configuration for YAML.
  */
+@RepositoryTupleEntity
 @Getter
 @Setter
 public final class YamlEncryptRuleConfiguration implements 
YamlRuleConfiguration {
     
+    @RepositoryTupleField(value = EncryptRuleNodePathProvider.TABLES, order = 
100)
     private Map<String, YamlEncryptTableRuleConfiguration> tables = new 
LinkedHashMap<>();
     
+    @RepositoryTupleField(value = EncryptRuleNodePathProvider.ENCRYPTORS, 
order = 0)
     private Map<String, YamlAlgorithmConfiguration> encryptors = new 
LinkedHashMap<>();
     
     @Override
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 e3b97985e67..44230f85b14 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
@@ -18,63 +18,14 @@
 package org.apache.shardingsphere.encrypt.yaml.swapper;
 
 import org.apache.shardingsphere.encrypt.constant.EncryptOrder;
-import 
org.apache.shardingsphere.encrypt.metadata.nodepath.EncryptRuleNodePathProvider;
 import 
org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration;
-import 
org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptTableRuleConfiguration;
-import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
-import org.apache.shardingsphere.mode.path.rule.RuleNodePath;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
 /**
  * Encrypt rule configuration repository tuple swapper.
  */
 public final class EncryptRuleConfigurationRepositoryTupleSwapper implements 
RepositoryTupleSwapper<YamlEncryptRuleConfiguration> {
     
-    private final RuleNodePath ruleNodePath = new 
EncryptRuleNodePathProvider().getRuleNodePath();
-    
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlEncryptRuleConfiguration yamlRuleConfig) {
-        Collection<RepositoryTuple> result = new LinkedList<>();
-        for (Entry<String, YamlAlgorithmConfiguration> entry : 
yamlRuleConfig.getEncryptors().entrySet()) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(EncryptRuleNodePathProvider.ENCRYPTORS).getPath(entry.getKey()),
 YamlEngine.marshal(entry.getValue())));
-        }
-        for (Entry<String, YamlEncryptTableRuleConfiguration> entry : 
yamlRuleConfig.getTables().entrySet()) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(EncryptRuleNodePathProvider.TABLES).getPath(entry.getKey()),
 YamlEngine.marshal(entry.getValue())));
-        }
-        return result;
-    }
-    
-    @Override
-    public Optional<YamlEncryptRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        List<RepositoryTuple> validTuples = 
repositoryTuples.stream().filter(each -> 
ruleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList());
-        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) {
-            
ruleNodePath.getNamedItem(EncryptRuleNodePathProvider.TABLES).getName(each.getKey())
-                    .ifPresent(optional -> tables.put(optional, 
YamlEngine.unmarshal(each.getValue(), 
YamlEncryptTableRuleConfiguration.class)));
-            
ruleNodePath.getNamedItem(EncryptRuleNodePathProvider.ENCRYPTORS).getName(each.getKey())
-                    .ifPresent(optional -> encryptors.put(optional, 
YamlEngine.unmarshal(each.getValue(), YamlAlgorithmConfiguration.class)));
-        }
-        yamlRuleConfig.setTables(tables);
-        yamlRuleConfig.setEncryptors(encryptors);
-        return Optional.of(yamlRuleConfig);
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "encrypt";
diff --git 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationRepositoryTupleSwapperTest.java
 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationRepositoryTupleSwapperTest.java
deleted file mode 100644
index bdaba845b3a..00000000000
--- 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationRepositoryTupleSwapperTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.encrypt.yaml.swapper;
-
-import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
-import 
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnItemRuleConfiguration;
-import 
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
-import 
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
-import 
org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration;
-import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
-import 
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Optional;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class EncryptRuleConfigurationRepositoryTupleSwapperTest {
-    
-    private final EncryptRuleConfigurationRepositoryTupleSwapper swapper = new 
EncryptRuleConfigurationRepositoryTupleSwapper();
-    
-    @Test
-    void assertSwapToRepositoryTuplesWithEmptyRule() {
-        assertTrue(swapper.swapToRepositoryTuples(new 
YamlEncryptRuleConfiguration()).isEmpty());
-    }
-    
-    @Test
-    void assertSwapToRepositoryTuples() {
-        Collection<RepositoryTuple> actual = swapper.swapToRepositoryTuples(
-                (YamlEncryptRuleConfiguration) new 
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfiguration(createMaximumEncryptRule()));
-        assertThat(actual.size(), is(2));
-        Iterator<RepositoryTuple> iterator = actual.iterator();
-        assertThat(iterator.next().getKey(), is("encryptors/FOO"));
-        assertThat(iterator.next().getKey(), is("tables/foo"));
-    }
-    
-    private EncryptRuleConfiguration createMaximumEncryptRule() {
-        Collection<EncryptTableRuleConfiguration> tables = 
Collections.singleton(
-                new EncryptTableRuleConfiguration("foo", 
Collections.singleton(new EncryptColumnRuleConfiguration("foo_column", new 
EncryptColumnItemRuleConfiguration("FIXTURE", "FOO")))));
-        return new EncryptRuleConfiguration(tables, 
Collections.singletonMap("FOO", new AlgorithmConfiguration("FOO", new 
Properties())));
-    }
-    
-    @Test
-    void assertSwapToObject() {
-        Collection<RepositoryTuple> repositoryTuples = Arrays.asList(new 
RepositoryTuple("/metadata/foo_db/rules/encrypt/tables/foo/versions/0", 
"columns:\n"
-                + "  foo_column:\n"
-                + "    cipher:\n"
-                + "      encryptorName: FOO\n"
-                + "      name: FIXTURE\n"
-                + "    name: foo_column\n"
-                + "name: foo\n"), new 
RepositoryTuple("/metadata/foo_db/rules/encrypt/encryptors/FOO/versions/0", 
"type: FOO\n"));
-        Optional<YamlEncryptRuleConfiguration> actual = 
swapper.swapToObject(repositoryTuples);
-        assertTrue(actual.isPresent());
-        assertThat(actual.get().getTables().size(), is(1));
-        assertThat(actual.get().getTables().get("foo").getColumns().size(), 
is(1));
-        
assertThat(actual.get().getTables().get("foo").getColumns().get("foo_column").getName(),
 is("foo_column"));
-        
assertThat(actual.get().getTables().get("foo").getColumns().get("foo_column").getCipher().getName(),
 is("FIXTURE"));
-        
assertThat(actual.get().getTables().get("foo").getColumns().get("foo_column").getCipher().getEncryptorName(),
 is("FOO"));
-        assertThat(actual.get().getEncryptors().size(), is(1));
-        assertThat(actual.get().getEncryptors().get("FOO").getType(), 
is("FOO"));
-        
assertTrue(actual.get().getEncryptors().get("FOO").getProps().isEmpty());
-    }
-}
diff --git 
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/config/YamlMaskRuleConfiguration.java
 
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/config/YamlMaskRuleConfiguration.java
index b65808aa13a..89e70dcc9f6 100644
--- 
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/config/YamlMaskRuleConfiguration.java
+++ 
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/config/YamlMaskRuleConfiguration.java
@@ -21,7 +21,10 @@ import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleField;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
+import 
org.apache.shardingsphere.mask.metadata.nodepath.MaskRuleNodePathProvider;
 import 
org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskTableRuleConfiguration;
 
 import java.util.LinkedHashMap;
@@ -30,12 +33,15 @@ import java.util.Map;
 /**
  * Mask rule configuration for YAML.
  */
+@RepositoryTupleEntity
 @Getter
 @Setter
 public final class YamlMaskRuleConfiguration implements YamlRuleConfiguration {
     
+    @RepositoryTupleField(value = MaskRuleNodePathProvider.TABLES, order = 100)
     private Map<String, YamlMaskTableRuleConfiguration> tables = new 
LinkedHashMap<>();
     
+    @RepositoryTupleField(value = MaskRuleNodePathProvider.MASK_ALGORITHMS, 
order = 0)
     private Map<String, YamlAlgorithmConfiguration> maskAlgorithms = new 
LinkedHashMap<>();
     
     @Override
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 c8dbc74ad21..a4707c9385d 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
@@ -17,63 +17,15 @@
 
 package org.apache.shardingsphere.mask.yaml.swapper;
 
-import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import org.apache.shardingsphere.mask.constant.MaskOrder;
-import 
org.apache.shardingsphere.mask.metadata.nodepath.MaskRuleNodePathProvider;
 import org.apache.shardingsphere.mask.yaml.config.YamlMaskRuleConfiguration;
-import 
org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskTableRuleConfiguration;
-import org.apache.shardingsphere.mode.path.rule.RuleNodePath;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
 /**
  * Mask rule configuration repository tuple swapper.
  */
 public final class MaskRuleConfigurationRepositoryTupleSwapper implements 
RepositoryTupleSwapper<YamlMaskRuleConfiguration> {
     
-    private final RuleNodePath ruleNodePath = new 
MaskRuleNodePathProvider().getRuleNodePath();
-    
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlMaskRuleConfiguration yamlRuleConfig) {
-        Collection<RepositoryTuple> result = new LinkedList<>();
-        for (Entry<String, YamlAlgorithmConfiguration> entry : 
yamlRuleConfig.getMaskAlgorithms().entrySet()) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(MaskRuleNodePathProvider.MASK_ALGORITHMS).getPath(entry.getKey()),
 YamlEngine.marshal(entry.getValue())));
-        }
-        for (Entry<String, YamlMaskTableRuleConfiguration> entry : 
yamlRuleConfig.getTables().entrySet()) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(MaskRuleNodePathProvider.TABLES).getPath(entry.getKey()),
 YamlEngine.marshal(entry.getValue())));
-        }
-        return result;
-    }
-    
-    @Override
-    public Optional<YamlMaskRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        Collection<RepositoryTuple> validTuples = 
repositoryTuples.stream().filter(each -> 
ruleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList());
-        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) {
-            
ruleNodePath.getNamedItem(MaskRuleNodePathProvider.TABLES).getName(each.getKey())
-                    .ifPresent(optional -> tables.put(optional, 
YamlEngine.unmarshal(each.getValue(), YamlMaskTableRuleConfiguration.class)));
-            
ruleNodePath.getNamedItem(MaskRuleNodePathProvider.MASK_ALGORITHMS).getName(each.getKey())
-                    .ifPresent(optional -> maskAlgorithms.put(optional, 
YamlEngine.unmarshal(each.getValue(), YamlAlgorithmConfiguration.class)));
-        }
-        yamlRuleConfig.setTables(tables);
-        yamlRuleConfig.setMaskAlgorithms(maskAlgorithms);
-        return Optional.of(yamlRuleConfig);
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "mask";
diff --git 
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/MaskRuleConfigurationRepositoryTupleSwapperTest.java
 
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/MaskRuleConfigurationRepositoryTupleSwapperTest.java
deleted file mode 100644
index c2454026034..00000000000
--- 
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/MaskRuleConfigurationRepositoryTupleSwapperTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.mask.yaml.swapper;
-
-import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
-import 
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
-import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
-import 
org.apache.shardingsphere.mask.api.config.rule.MaskColumnRuleConfiguration;
-import 
org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
-import org.apache.shardingsphere.mask.yaml.config.YamlMaskRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Optional;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class MaskRuleConfigurationRepositoryTupleSwapperTest {
-    
-    @Test
-    void assertSwapToRepositoryTuplesWithEmptyRule() {
-        assertTrue(new 
MaskRuleConfigurationRepositoryTupleSwapper().swapToRepositoryTuples(new 
YamlMaskRuleConfiguration()).isEmpty());
-    }
-    
-    @Test
-    void assertSwapToRepositoryTuples() {
-        YamlMaskRuleConfiguration yamlRuleConfig = (YamlMaskRuleConfiguration) 
new 
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfiguration(createMaximumMaskRule());
-        Collection<RepositoryTuple> actual = new 
MaskRuleConfigurationRepositoryTupleSwapper().swapToRepositoryTuples(yamlRuleConfig);
-        assertThat(actual.size(), is(2));
-        Iterator<RepositoryTuple> iterator = actual.iterator();
-        assertThat(iterator.next().getKey(), is("mask_algorithms/FIXTURE"));
-        assertThat(iterator.next().getKey(), is("tables/foo"));
-    }
-    
-    private MaskRuleConfiguration createMaximumMaskRule() {
-        Collection<MaskTableRuleConfiguration> tables = Collections.singleton(
-                new MaskTableRuleConfiguration("foo", 
Collections.singleton(new MaskColumnRuleConfiguration("foo_column", 
"FIXTURE"))));
-        return new MaskRuleConfiguration(tables, 
Collections.singletonMap("FIXTURE", new AlgorithmConfiguration("FIXTURE", new 
Properties())));
-    }
-    
-    @Test
-    void assertSwapToObject() {
-        Collection<RepositoryTuple> repositoryTuples = Arrays.asList(new 
RepositoryTuple("/metadata/foo_db/rules/mask/tables/foo/versions/0", 
"columns:\n"
-                + "  foo_column:\n"
-                + "    logicColumn: foo_column\n"
-                + "    maskAlgorithm: FIXTURE\n"
-                + "name: foo\n"),
-                new 
RepositoryTuple("/metadata/foo_db/rules/mask/mask_algorithms/FIXTURE/versions/0",
 "type: FIXTURE\n"));
-        Optional<YamlMaskRuleConfiguration> actual = new 
MaskRuleConfigurationRepositoryTupleSwapper().swapToObject(repositoryTuples);
-        assertTrue(actual.isPresent());
-        assertThat(actual.get().getTables().size(), is(1));
-        assertThat(actual.get().getTables().get("foo").getColumns().size(), 
is(1));
-        
assertThat(actual.get().getTables().get("foo").getColumns().get("foo_column").getLogicColumn(),
 is("foo_column"));
-        
assertThat(actual.get().getTables().get("foo").getColumns().get("foo_column").getMaskAlgorithm(),
 is("FIXTURE"));
-        assertThat(actual.get().getMaskAlgorithms().size(), is(1));
-        assertThat(actual.get().getMaskAlgorithms().get("FIXTURE").getType(), 
is("FIXTURE"));
-        
assertTrue(actual.get().getMaskAlgorithms().get("FIXTURE").getProps().isEmpty());
-    }
-}
diff --git 
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/config/YamlReadwriteSplittingRuleConfiguration.java
 
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/config/YamlReadwriteSplittingRuleConfiguration.java
index 6fb6ef9ab88..2c3b9ac9c80 100644
--- 
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/config/YamlReadwriteSplittingRuleConfiguration.java
+++ 
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/config/YamlReadwriteSplittingRuleConfiguration.java
@@ -19,9 +19,12 @@ package 
org.apache.shardingsphere.readwritesplitting.yaml.config;
 
 import lombok.Getter;
 import lombok.Setter;
-import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleField;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 import 
org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
+import 
org.apache.shardingsphere.readwritesplitting.metadata.nodepath.ReadwriteSplittingRuleNodePathProvider;
 import 
org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceGroupRuleConfiguration;
 
 import java.util.LinkedHashMap;
@@ -30,12 +33,15 @@ import java.util.Map;
 /**
  * Readwrite-splitting rule configuration for YAML.
  */
+@RepositoryTupleEntity
 @Getter
 @Setter
 public final class YamlReadwriteSplittingRuleConfiguration implements 
YamlRuleConfiguration {
     
+    @RepositoryTupleField(value = 
ReadwriteSplittingRuleNodePathProvider.DATA_SOURCES, order = 100)
     private Map<String, 
YamlReadwriteSplittingDataSourceGroupRuleConfiguration> dataSourceGroups = new 
LinkedHashMap<>();
     
+    @RepositoryTupleField(value = 
ReadwriteSplittingRuleNodePathProvider.LOAD_BALANCERS, order = 0)
     private Map<String, YamlAlgorithmConfiguration> loadBalancers = new 
LinkedHashMap<>();
     
     @Override
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 0fd1be4ce55..db9be9a2455 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
@@ -17,64 +17,15 @@
 
 package org.apache.shardingsphere.readwritesplitting.yaml.swapper;
 
-import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
-import org.apache.shardingsphere.mode.path.rule.RuleNodePath;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 import 
org.apache.shardingsphere.readwritesplitting.constant.ReadwriteSplittingOrder;
-import 
org.apache.shardingsphere.readwritesplitting.metadata.nodepath.ReadwriteSplittingRuleNodePathProvider;
 import 
org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
-import 
org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceGroupRuleConfiguration;
-
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.stream.Collectors;
 
 /**
  * Readwrite-splitting rule configuration repository tuple swapper.
  */
 public final class ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper 
implements RepositoryTupleSwapper<YamlReadwriteSplittingRuleConfiguration> {
     
-    private final RuleNodePath ruleNodePath = new 
ReadwriteSplittingRuleNodePathProvider().getRuleNodePath();
-    
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlReadwriteSplittingRuleConfiguration yamlRuleConfig) {
-        Collection<RepositoryTuple> result = new LinkedList<>();
-        for (Entry<String, YamlAlgorithmConfiguration> entry : 
yamlRuleConfig.getLoadBalancers().entrySet()) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(ReadwriteSplittingRuleNodePathProvider.LOAD_BALANCERS).getPath(entry.getKey()),
 YamlEngine.marshal(entry.getValue())));
-        }
-        for (Entry<String, 
YamlReadwriteSplittingDataSourceGroupRuleConfiguration> entry : 
yamlRuleConfig.getDataSourceGroups().entrySet()) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(ReadwriteSplittingRuleNodePathProvider.DATA_SOURCES).getPath(entry.getKey()),
 YamlEngine.marshal(entry.getValue())));
-        }
-        return result;
-    }
-    
-    @Override
-    public Optional<YamlReadwriteSplittingRuleConfiguration> 
swapToObject(final Collection<RepositoryTuple> repositoryTuples) {
-        List<RepositoryTuple> validRepositoryTuples = 
repositoryTuples.stream().filter(each -> 
ruleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList());
-        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) {
-            
ruleNodePath.getNamedItem(ReadwriteSplittingRuleNodePathProvider.DATA_SOURCES).getName(each.getKey())
-                    .ifPresent(optional -> dataSourceGroups.put(optional, 
YamlEngine.unmarshal(each.getValue(), 
YamlReadwriteSplittingDataSourceGroupRuleConfiguration.class)));
-            
ruleNodePath.getNamedItem(ReadwriteSplittingRuleNodePathProvider.LOAD_BALANCERS).getName(each.getKey())
-                    .ifPresent(optional -> loadBalancers.put(optional, 
YamlEngine.unmarshal(each.getValue(), YamlAlgorithmConfiguration.class)));
-        }
-        yamlRuleConfig.setDataSourceGroups(dataSourceGroups);
-        yamlRuleConfig.setLoadBalancers(loadBalancers);
-        return Optional.of(yamlRuleConfig);
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "readwrite_splitting";
diff --git 
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/config/YamlShadowRuleConfiguration.java
 
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/config/YamlShadowRuleConfiguration.java
index 868fc45af72..95fa805e904 100644
--- 
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/config/YamlShadowRuleConfiguration.java
+++ 
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/config/YamlShadowRuleConfiguration.java
@@ -19,9 +19,12 @@ package org.apache.shardingsphere.shadow.yaml.config;
 
 import lombok.Getter;
 import lombok.Setter;
-import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleField;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
+import 
org.apache.shardingsphere.shadow.metadata.nodepath.ShadowRuleNodePathProvider;
 import 
org.apache.shardingsphere.shadow.yaml.config.datasource.YamlShadowDataSourceConfiguration;
 import 
org.apache.shardingsphere.shadow.yaml.config.table.YamlShadowTableConfiguration;
 
@@ -31,16 +34,21 @@ import java.util.Map;
 /**
  * Shadow rule configuration.
  */
+@RepositoryTupleEntity
 @Getter
 @Setter
 public final class YamlShadowRuleConfiguration implements 
YamlRuleConfiguration {
     
+    @RepositoryTupleField(value = ShadowRuleNodePathProvider.DATA_SOURCES, 
order = 100)
     private Map<String, YamlShadowDataSourceConfiguration> dataSources = new 
LinkedHashMap<>();
     
+    @RepositoryTupleField(value = ShadowRuleNodePathProvider.TABLES, order = 
101)
     private Map<String, YamlShadowTableConfiguration> tables = new 
LinkedHashMap<>();
     
+    @RepositoryTupleField(value = ShadowRuleNodePathProvider.ALGORITHMS, order 
= 0)
     private Map<String, YamlAlgorithmConfiguration> shadowAlgorithms = new 
LinkedHashMap<>();
     
+    @RepositoryTupleField(value = 
ShadowRuleNodePathProvider.DEFAULT_ALGORITHM, order = 1)
     private String defaultShadowAlgorithmName;
     
     @Override
diff --git 
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleConfigurationRepositoryTupleSwapper.java
 
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleConfigurationRepositoryTupleSwapper.java
index 3343284e7c7..811f3551700 100644
--- 
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleConfigurationRepositoryTupleSwapper.java
+++ 
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleConfigurationRepositoryTupleSwapper.java
@@ -17,79 +17,15 @@
 
 package org.apache.shardingsphere.shadow.yaml.swapper;
 
-import com.google.common.base.Strings;
-import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
-import org.apache.shardingsphere.mode.path.rule.RuleNodePath;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 import org.apache.shardingsphere.shadow.constant.ShadowOrder;
-import 
org.apache.shardingsphere.shadow.metadata.nodepath.ShadowRuleNodePathProvider;
 import 
org.apache.shardingsphere.shadow.yaml.config.YamlShadowRuleConfiguration;
-import 
org.apache.shardingsphere.shadow.yaml.config.datasource.YamlShadowDataSourceConfiguration;
-import 
org.apache.shardingsphere.shadow.yaml.config.table.YamlShadowTableConfiguration;
-
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.stream.Collectors;
 
 /**
  * Shadow rule configuration repository tuple swapper.
  */
 public final class ShadowRuleConfigurationRepositoryTupleSwapper implements 
RepositoryTupleSwapper<YamlShadowRuleConfiguration> {
     
-    private final RuleNodePath ruleNodePath = new 
ShadowRuleNodePathProvider().getRuleNodePath();
-    
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlShadowRuleConfiguration yamlRuleConfig) {
-        Collection<RepositoryTuple> result = new LinkedList<>();
-        for (Entry<String, YamlAlgorithmConfiguration> entry : 
yamlRuleConfig.getShadowAlgorithms().entrySet()) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(ShadowRuleNodePathProvider.ALGORITHMS).getPath(entry.getKey()),
 YamlEngine.marshal(entry.getValue())));
-        }
-        if 
(!Strings.isNullOrEmpty(yamlRuleConfig.getDefaultShadowAlgorithmName())) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getUniqueItem(ShadowRuleNodePathProvider.DEFAULT_ALGORITHM).getPath(),
 yamlRuleConfig.getDefaultShadowAlgorithmName()));
-        }
-        for (Entry<String, YamlShadowDataSourceConfiguration> entry : 
yamlRuleConfig.getDataSources().entrySet()) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(ShadowRuleNodePathProvider.DATA_SOURCES).getPath(entry.getKey()),
 YamlEngine.marshal(entry.getValue())));
-        }
-        for (Entry<String, YamlShadowTableConfiguration> entry : 
yamlRuleConfig.getTables().entrySet()) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(ShadowRuleNodePathProvider.TABLES).getPath(entry.getKey()),
 YamlEngine.marshal(entry.getValue())));
-        }
-        return result;
-    }
-    
-    @Override
-    public Optional<YamlShadowRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        List<RepositoryTuple> validRepositoryTuples = 
repositoryTuples.stream().filter(each -> 
ruleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList());
-        if (validRepositoryTuples.isEmpty()) {
-            return Optional.empty();
-        }
-        YamlShadowRuleConfiguration yamlRuleConfig = new 
YamlShadowRuleConfiguration();
-        Map<String, YamlShadowDataSourceConfiguration> dataSources = new 
LinkedHashMap<>();
-        Map<String, YamlShadowTableConfiguration> tables = new 
LinkedHashMap<>();
-        Map<String, YamlAlgorithmConfiguration> shadowAlgorithms = new 
LinkedHashMap<>();
-        for (RepositoryTuple each : validRepositoryTuples) {
-            
ruleNodePath.getNamedItem(ShadowRuleNodePathProvider.DATA_SOURCES).getName(each.getKey())
-                    .ifPresent(optional -> dataSources.put(optional, 
YamlEngine.unmarshal(each.getValue(), 
YamlShadowDataSourceConfiguration.class)));
-            
ruleNodePath.getNamedItem(ShadowRuleNodePathProvider.TABLES).getName(each.getKey())
-                    .ifPresent(optional -> tables.put(optional, 
YamlEngine.unmarshal(each.getValue(), YamlShadowTableConfiguration.class)));
-            
ruleNodePath.getNamedItem(ShadowRuleNodePathProvider.ALGORITHMS).getName(each.getKey())
-                    .ifPresent(optional -> shadowAlgorithms.put(optional, 
YamlEngine.unmarshal(each.getValue(), YamlAlgorithmConfiguration.class)));
-            if 
(ruleNodePath.getUniqueItem(ShadowRuleNodePathProvider.DEFAULT_ALGORITHM).isValidatedPath(each.getKey()))
 {
-                yamlRuleConfig.setDefaultShadowAlgorithmName(each.getValue());
-            }
-        }
-        yamlRuleConfig.setDataSources(dataSources);
-        yamlRuleConfig.setTables(tables);
-        yamlRuleConfig.setShadowAlgorithms(shadowAlgorithms);
-        return Optional.of(yamlRuleConfig);
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "shadow";
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/config/YamlShardingRuleConfiguration.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/config/YamlShardingRuleConfiguration.java
index 99cc48917f6..81ad57c2cc1 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/config/YamlShardingRuleConfiguration.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/config/YamlShardingRuleConfiguration.java
@@ -21,13 +21,18 @@ import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleField;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleKeyNameGenerator;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import 
org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodePathProvider;
 import 
org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheConfiguration;
 import 
org.apache.shardingsphere.sharding.yaml.config.rule.YamlShardingAutoTableRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
+import 
org.apache.shardingsphere.sharding.yaml.swapper.ShardingBindingTableRegistryCenterTupleKeyNameGenerator;
 
 import java.util.Collection;
 import java.util.LinkedHashMap;
@@ -37,32 +42,46 @@ import java.util.Map;
 /**
  * Sharding rule configuration for YAML.
  */
+@RepositoryTupleEntity
 @Getter
 @Setter
 public final class YamlShardingRuleConfiguration implements 
YamlRuleConfiguration {
     
+    @RepositoryTupleField(value = ShardingRuleNodePathProvider.TABLES, order = 
500)
     private Map<String, YamlTableRuleConfiguration> tables = new 
LinkedHashMap<>();
     
+    @RepositoryTupleField(value = ShardingRuleNodePathProvider.AUTO_TABLES, 
order = 501)
     private Map<String, YamlShardingAutoTableRuleConfiguration> autoTables = 
new LinkedHashMap<>();
     
+    @RepositoryTupleField(value = ShardingRuleNodePathProvider.BINDING_TABLES, 
order = 502)
+    
@RepositoryTupleKeyNameGenerator(ShardingBindingTableRegistryCenterTupleKeyNameGenerator.class)
     private Collection<String> bindingTables = new LinkedList<>();
     
+    @RepositoryTupleField(value = 
ShardingRuleNodePathProvider.DEFAULT_DATABASE_STRATEGY, order = 100)
     private YamlShardingStrategyConfiguration defaultDatabaseStrategy;
     
+    @RepositoryTupleField(value = 
ShardingRuleNodePathProvider.DEFAULT_TABLE_STRATEGY, order = 101)
     private YamlShardingStrategyConfiguration defaultTableStrategy;
     
+    @RepositoryTupleField(value = 
ShardingRuleNodePathProvider.DEFAULT_KEY_GENERATE_STRATEGY, order = 102)
     private YamlKeyGenerateStrategyConfiguration defaultKeyGenerateStrategy;
     
+    @RepositoryTupleField(value = 
ShardingRuleNodePathProvider.DEFAULT_AUDIT_STRATEGY, order = 103)
     private YamlShardingAuditStrategyConfiguration defaultAuditStrategy;
     
+    @RepositoryTupleField(value = ShardingRuleNodePathProvider.ALGORITHMS, 
order = 0)
     private Map<String, YamlAlgorithmConfiguration> shardingAlgorithms = new 
LinkedHashMap<>();
     
+    @RepositoryTupleField(value = ShardingRuleNodePathProvider.KEY_GENERATORS, 
order = 1)
     private Map<String, YamlAlgorithmConfiguration> keyGenerators = new 
LinkedHashMap<>();
     
+    @RepositoryTupleField(value = ShardingRuleNodePathProvider.AUDITORS, order 
= 2)
     private Map<String, YamlAlgorithmConfiguration> auditors = new 
LinkedHashMap<>();
     
+    @RepositoryTupleField(value = 
ShardingRuleNodePathProvider.DEFAULT_SHARDING_COLUMN, order = 200)
     private String defaultShardingColumn;
     
+    @RepositoryTupleField(value = ShardingRuleNodePathProvider.SHARDING_CACHE, 
order = 201)
     private YamlShardingCacheConfiguration shardingCache;
     
     @Override
diff --git 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingBindingTableRegistryCenterTupleKeyNameGenerator.java
similarity index 55%
copy from 
kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
copy to 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingBindingTableRegistryCenterTupleKeyNameGenerator.java
index c3521955393..3f98d60cd5a 100644
--- 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingBindingTableRegistryCenterTupleKeyNameGenerator.java
@@ -15,29 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.single.yaml.config.pojo;
+package org.apache.shardingsphere.sharding.yaml.swapper;
 
-import lombok.Getter;
-import lombok.Setter;
-import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
-import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
-
-import java.util.Collection;
-import java.util.LinkedList;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleKeyNameGenerator;
+import 
org.apache.shardingsphere.sharding.yaml.swapper.rule.YamlShardingTableReferenceRuleConfigurationConverter;
 
 /**
- * Single rule configuration for YAML.
+ * Sharding binding table registry center tuple key name generator.
  */
-@Getter
-@Setter
-public final class YamlSingleRuleConfiguration implements 
YamlRuleConfiguration {
-    
-    private Collection<String> tables = new LinkedList<>();
-    
-    private String defaultDataSource;
+public final class ShardingBindingTableRegistryCenterTupleKeyNameGenerator 
implements RepositoryTupleKeyNameGenerator.Generator {
     
     @Override
-    public Class<SingleRuleConfiguration> getRuleConfigurationType() {
-        return SingleRuleConfiguration.class;
+    public String generate(final Object tupleValue) {
+        return 
YamlShardingTableReferenceRuleConfigurationConverter.convertToObject(tupleValue.toString()).getName();
     }
 }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingRuleConfigurationRepositoryTupleSwapper.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingRuleConfigurationRepositoryTupleSwapper.java
index 9ae03ea89a8..50bdbae5f91 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingRuleConfigurationRepositoryTupleSwapper.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingRuleConfigurationRepositoryTupleSwapper.java
@@ -17,148 +17,15 @@
 
 package org.apache.shardingsphere.sharding.yaml.swapper;
 
-import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
-import org.apache.shardingsphere.mode.path.rule.RuleNodePath;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 import org.apache.shardingsphere.sharding.constant.ShardingOrder;
-import 
org.apache.shardingsphere.sharding.metadata.nodepath.ShardingRuleNodePathProvider;
 import 
org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
-import 
org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheConfiguration;
-import 
org.apache.shardingsphere.sharding.yaml.config.rule.YamlShardingAutoTableRuleConfiguration;
-import 
org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
-import 
org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.yaml.swapper.rule.YamlShardingTableReferenceRuleConfigurationConverter;
-
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.stream.Collectors;
 
 /**
  * Sharding rule configuration repository tuple swapper.
  */
 public final class ShardingRuleConfigurationRepositoryTupleSwapper implements 
RepositoryTupleSwapper<YamlShardingRuleConfiguration> {
     
-    private final RuleNodePath ruleNodePath = new 
ShardingRuleNodePathProvider().getRuleNodePath();
-    
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlShardingRuleConfiguration yamlRuleConfig) {
-        Collection<RepositoryTuple> result = new LinkedList<>();
-        swapAlgorithms(yamlRuleConfig, result);
-        swapStrategies(yamlRuleConfig, result);
-        if (null != yamlRuleConfig.getDefaultShardingColumn()) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getUniqueItem(ShardingRuleNodePathProvider.DEFAULT_SHARDING_COLUMN).getPath(),
 yamlRuleConfig.getDefaultShardingColumn()));
-        }
-        if (null != yamlRuleConfig.getShardingCache()) {
-            result.add(new 
RepositoryTuple(ruleNodePath.getUniqueItem(ShardingRuleNodePathProvider.SHARDING_CACHE).getPath(),
 YamlEngine.marshal(yamlRuleConfig.getShardingCache())));
-        }
-        swapTableRules(yamlRuleConfig, result);
-        return result;
-    }
-    
-    private void swapAlgorithms(final YamlShardingRuleConfiguration 
yamlRuleConfig, final Collection<RepositoryTuple> repositoryTuples) {
-        for (Entry<String, YamlAlgorithmConfiguration> each : 
yamlRuleConfig.getShardingAlgorithms().entrySet()) {
-            repositoryTuples.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(ShardingRuleNodePathProvider.ALGORITHMS).getPath(each.getKey()),
 YamlEngine.marshal(each.getValue())));
-        }
-        for (Entry<String, YamlAlgorithmConfiguration> each : 
yamlRuleConfig.getKeyGenerators().entrySet()) {
-            repositoryTuples.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(ShardingRuleNodePathProvider.KEY_GENERATORS).getPath(each.getKey()),
 YamlEngine.marshal(each.getValue())));
-        }
-        for (Entry<String, YamlAlgorithmConfiguration> each : 
yamlRuleConfig.getAuditors().entrySet()) {
-            repositoryTuples.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(ShardingRuleNodePathProvider.AUDITORS).getPath(each.getKey()),
 YamlEngine.marshal(each.getValue())));
-        }
-    }
-    
-    private void swapStrategies(final YamlShardingRuleConfiguration 
yamlRuleConfig, final Collection<RepositoryTuple> repositoryTuples) {
-        if (null != yamlRuleConfig.getDefaultDatabaseStrategy()) {
-            repositoryTuples.add(new RepositoryTuple(
-                    
ruleNodePath.getUniqueItem(ShardingRuleNodePathProvider.DEFAULT_DATABASE_STRATEGY).getPath(),
 YamlEngine.marshal(yamlRuleConfig.getDefaultDatabaseStrategy())));
-        }
-        if (null != yamlRuleConfig.getDefaultTableStrategy()) {
-            repositoryTuples.add(new RepositoryTuple(
-                    
ruleNodePath.getUniqueItem(ShardingRuleNodePathProvider.DEFAULT_TABLE_STRATEGY).getPath(),
 YamlEngine.marshal(yamlRuleConfig.getDefaultTableStrategy())));
-        }
-        if (null != yamlRuleConfig.getDefaultKeyGenerateStrategy()) {
-            repositoryTuples.add(new RepositoryTuple(
-                    
ruleNodePath.getUniqueItem(ShardingRuleNodePathProvider.DEFAULT_KEY_GENERATE_STRATEGY).getPath(),
 YamlEngine.marshal(yamlRuleConfig.getDefaultKeyGenerateStrategy())));
-        }
-        if (null != yamlRuleConfig.getDefaultAuditStrategy()) {
-            repositoryTuples.add(new RepositoryTuple(
-                    
ruleNodePath.getUniqueItem(ShardingRuleNodePathProvider.DEFAULT_AUDIT_STRATEGY).getPath(),
 YamlEngine.marshal(yamlRuleConfig.getDefaultAuditStrategy())));
-        }
-    }
-    
-    private void swapTableRules(final YamlShardingRuleConfiguration 
yamlRuleConfig, final Collection<RepositoryTuple> repositoryTuples) {
-        for (Entry<String, YamlTableRuleConfiguration> entry : 
yamlRuleConfig.getTables().entrySet()) {
-            repositoryTuples.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(ShardingRuleNodePathProvider.TABLES).getPath(entry.getKey()),
 YamlEngine.marshal(entry.getValue())));
-        }
-        for (Entry<String, YamlShardingAutoTableRuleConfiguration> entry : 
yamlRuleConfig.getAutoTables().entrySet()) {
-            repositoryTuples.add(
-                    new 
RepositoryTuple(ruleNodePath.getNamedItem(ShardingRuleNodePathProvider.AUTO_TABLES).getPath(entry.getKey()),
 YamlEngine.marshal(entry.getValue())));
-        }
-        for (String each : yamlRuleConfig.getBindingTables()) {
-            repositoryTuples.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(ShardingRuleNodePathProvider.BINDING_TABLES).getPath(getBindingGroupName(each)),
 each));
-        }
-    }
-    
-    private String getBindingGroupName(final String bindingGroup) {
-        return 
YamlShardingTableReferenceRuleConfigurationConverter.convertToObject(bindingGroup).getName();
-    }
-    
-    @Override
-    public Optional<YamlShardingRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        Collection<RepositoryTuple> validRepositoryTuples = 
repositoryTuples.stream().filter(each -> 
ruleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList());
-        if (validRepositoryTuples.isEmpty()) {
-            return Optional.empty();
-        }
-        YamlShardingRuleConfiguration yamlRuleConfig = new 
YamlShardingRuleConfiguration();
-        Map<String, YamlTableRuleConfiguration> tables = new LinkedHashMap<>();
-        Map<String, YamlShardingAutoTableRuleConfiguration> autoTables = new 
LinkedHashMap<>();
-        Collection<String> bindingTables = new LinkedList<>();
-        Map<String, YamlAlgorithmConfiguration> shardingAlgorithms = new 
LinkedHashMap<>();
-        Map<String, YamlAlgorithmConfiguration> keyGenerators = new 
LinkedHashMap<>();
-        Map<String, YamlAlgorithmConfiguration> auditors = new 
LinkedHashMap<>();
-        for (RepositoryTuple each : validRepositoryTuples) {
-            
ruleNodePath.getNamedItem(ShardingRuleNodePathProvider.TABLES).getName(each.getKey())
-                    .ifPresent(optional -> tables.put(optional, 
YamlEngine.unmarshal(each.getValue(), YamlTableRuleConfiguration.class)));
-            
ruleNodePath.getNamedItem(ShardingRuleNodePathProvider.AUTO_TABLES).getName(each.getKey())
-                    .ifPresent(optional -> autoTables.put(optional, 
YamlEngine.unmarshal(each.getValue(), 
YamlShardingAutoTableRuleConfiguration.class)));
-            
ruleNodePath.getNamedItem(ShardingRuleNodePathProvider.BINDING_TABLES).getName(each.getKey()).ifPresent(optional
 -> bindingTables.add(each.getValue()));
-            
ruleNodePath.getNamedItem(ShardingRuleNodePathProvider.ALGORITHMS).getName(each.getKey())
-                    .ifPresent(optional -> shardingAlgorithms.put(optional, 
YamlEngine.unmarshal(each.getValue(), YamlAlgorithmConfiguration.class)));
-            
ruleNodePath.getNamedItem(ShardingRuleNodePathProvider.KEY_GENERATORS).getName(each.getKey())
-                    .ifPresent(optional -> keyGenerators.put(optional, 
YamlEngine.unmarshal(each.getValue(), YamlAlgorithmConfiguration.class)));
-            
ruleNodePath.getNamedItem(ShardingRuleNodePathProvider.AUDITORS).getName(each.getKey())
-                    .ifPresent(optional -> auditors.put(optional, 
YamlEngine.unmarshal(each.getValue(), YamlAlgorithmConfiguration.class)));
-            if 
(ruleNodePath.getUniqueItem(ShardingRuleNodePathProvider.DEFAULT_DATABASE_STRATEGY).isValidatedPath(each.getKey()))
 {
-                
yamlRuleConfig.setDefaultDatabaseStrategy(YamlEngine.unmarshal(each.getValue(), 
YamlShardingStrategyConfiguration.class));
-            } else if 
(ruleNodePath.getUniqueItem(ShardingRuleNodePathProvider.DEFAULT_TABLE_STRATEGY).isValidatedPath(each.getKey()))
 {
-                
yamlRuleConfig.setDefaultTableStrategy(YamlEngine.unmarshal(each.getValue(), 
YamlShardingStrategyConfiguration.class));
-            } else if 
(ruleNodePath.getUniqueItem(ShardingRuleNodePathProvider.DEFAULT_KEY_GENERATE_STRATEGY).isValidatedPath(each.getKey()))
 {
-                
yamlRuleConfig.setDefaultKeyGenerateStrategy(YamlEngine.unmarshal(each.getValue(),
 YamlKeyGenerateStrategyConfiguration.class));
-            } else if 
(ruleNodePath.getUniqueItem(ShardingRuleNodePathProvider.DEFAULT_AUDIT_STRATEGY).isValidatedPath(each.getKey()))
 {
-                
yamlRuleConfig.setDefaultAuditStrategy(YamlEngine.unmarshal(each.getValue(), 
YamlShardingAuditStrategyConfiguration.class));
-            } else if 
(ruleNodePath.getUniqueItem(ShardingRuleNodePathProvider.DEFAULT_SHARDING_COLUMN).isValidatedPath(each.getKey()))
 {
-                yamlRuleConfig.setDefaultShardingColumn(each.getValue());
-            } else if 
(ruleNodePath.getUniqueItem(ShardingRuleNodePathProvider.SHARDING_CACHE).isValidatedPath(each.getKey()))
 {
-                
yamlRuleConfig.setShardingCache(YamlEngine.unmarshal(each.getValue(), 
YamlShardingCacheConfiguration.class));
-            }
-        }
-        yamlRuleConfig.setTables(tables);
-        yamlRuleConfig.setAutoTables(autoTables);
-        yamlRuleConfig.setBindingTables(bindingTables);
-        yamlRuleConfig.setShardingAlgorithms(shardingAlgorithms);
-        yamlRuleConfig.setKeyGenerators(keyGenerators);
-        yamlRuleConfig.setAuditors(auditors);
-        return Optional.of(yamlRuleConfig);
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "sharding";
diff --git 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/pojo/rule/annotation/RepositoryTupleEntity.java
similarity index 53%
copy from 
kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
copy to 
infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/pojo/rule/annotation/RepositoryTupleEntity.java
index c3521955393..3d45c41a9d7 100644
--- 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/pojo/rule/annotation/RepositoryTupleEntity.java
@@ -15,29 +15,17 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.single.yaml.config.pojo;
+package org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation;
 
-import lombok.Getter;
-import lombok.Setter;
-import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
-import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
-
-import java.util.Collection;
-import java.util.LinkedList;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 
 /**
- * Single rule configuration for YAML.
+ * Repository tuple entity.
  */
-@Getter
-@Setter
-public final class YamlSingleRuleConfiguration implements 
YamlRuleConfiguration {
-    
-    private Collection<String> tables = new LinkedList<>();
-    
-    private String defaultDataSource;
-    
-    @Override
-    public Class<SingleRuleConfiguration> getRuleConfigurationType() {
-        return SingleRuleConfiguration.class;
-    }
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface RepositoryTupleEntity {
 }
diff --git 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/pojo/rule/annotation/RepositoryTupleField.java
similarity index 54%
copy from 
kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
copy to 
infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/pojo/rule/annotation/RepositoryTupleField.java
index c3521955393..47d71b3d893 100644
--- 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/pojo/rule/annotation/RepositoryTupleField.java
@@ -15,29 +15,31 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.single.yaml.config.pojo;
+package org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation;
 
-import lombok.Getter;
-import lombok.Setter;
-import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
-import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
-
-import java.util.Collection;
-import java.util.LinkedList;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 
 /**
- * Single rule configuration for YAML.
+ * Repository tuple field.
  */
-@Getter
-@Setter
-public final class YamlSingleRuleConfiguration implements 
YamlRuleConfiguration {
-    
-    private Collection<String> tables = new LinkedList<>();
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface RepositoryTupleField {
     
-    private String defaultDataSource;
+    /**
+     * Get persist path name.
+     * 
+     * @return persist path name
+     */
+    String value();
     
-    @Override
-    public Class<SingleRuleConfiguration> getRuleConfigurationType() {
-        return SingleRuleConfiguration.class;
-    }
+    /**
+     * Get persist order.
+     * 
+     * @return persist order
+     */
+    int order();
 }
diff --git 
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/yaml/config/YamlGlobalClockRuleConfiguration.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/pojo/rule/annotation/RepositoryTupleKeyNameGenerator.java
similarity index 51%
copy from 
kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/yaml/config/YamlGlobalClockRuleConfiguration.java
copy to 
infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/pojo/rule/annotation/RepositoryTupleKeyNameGenerator.java
index 2d86578c016..0a8034f1f04 100644
--- 
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/yaml/config/YamlGlobalClockRuleConfiguration.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/pojo/rule/annotation/RepositoryTupleKeyNameGenerator.java
@@ -15,32 +15,35 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.globalclock.yaml.config;
+package org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation;
 
-import lombok.Getter;
-import lombok.Setter;
-import 
org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
-import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfiguration;
-
-import java.util.Properties;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 
 /**
- * Global clock rule configuration for YAML.
+ * Repository tuple key name generator.
  */
-@Getter
-@Setter
-public final class YamlGlobalClockRuleConfiguration implements 
YamlGlobalRuleConfiguration {
-    
-    private String type;
-    
-    private String provider;
-    
-    private boolean enabled;
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface RepositoryTupleKeyNameGenerator {
     
-    private Properties props;
+    /**
+     * Get repository tuple key name generator class.
+     * 
+     * @return repository tuple key name generator class
+     */
+    Class<? extends Generator> value();
     
-    @Override
-    public Class<GlobalClockRuleConfiguration> getRuleConfigurationType() {
-        return GlobalClockRuleConfiguration.class;
+    interface Generator {
+        
+        /**
+         * Generate name of tuple key.
+         * 
+         * @param tupleValue tuple value
+         * @return generated name
+         */
+        String generate(Object tupleValue);
     }
 }
diff --git 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/pojo/rule/annotation/RepositoryTupleType.java
similarity index 53%
copy from 
kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
copy to 
infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/pojo/rule/annotation/RepositoryTupleType.java
index c3521955393..eefb6d119e0 100644
--- 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/pojo/rule/annotation/RepositoryTupleType.java
@@ -15,29 +15,24 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.single.yaml.config.pojo;
+package org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation;
 
-import lombok.Getter;
-import lombok.Setter;
-import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
-import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
-
-import java.util.Collection;
-import java.util.LinkedList;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 
 /**
- * Single rule configuration for YAML.
+ * Repository tuple type.
  */
-@Getter
-@Setter
-public final class YamlSingleRuleConfiguration implements 
YamlRuleConfiguration {
-    
-    private Collection<String> tables = new LinkedList<>();
-    
-    private String defaultDataSource;
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface RepositoryTupleType {
     
-    @Override
-    public Class<SingleRuleConfiguration> getRuleConfigurationType() {
-        return SingleRuleConfiguration.class;
-    }
+    /**
+     * Get persist path name.
+     *
+     * @return persist path name
+     */
+    String value();
 }
diff --git 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/config/YamlAuthorityRuleConfiguration.java
 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/config/YamlAuthorityRuleConfiguration.java
index d07e39a5c9f..ff83334dff7 100644
--- 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/config/YamlAuthorityRuleConfiguration.java
+++ 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/config/YamlAuthorityRuleConfiguration.java
@@ -22,6 +22,8 @@ import lombok.Setter;
 import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
 import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleType;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 
 import java.util.Collection;
 import java.util.LinkedHashMap;
@@ -31,6 +33,8 @@ import java.util.Map;
 /**
  * Authority rule configuration for YAML.
  */
+@RepositoryTupleEntity
+@RepositoryTupleType("authority")
 @Getter
 @Setter
 public final class YamlAuthorityRuleConfiguration implements 
YamlGlobalRuleConfiguration {
diff --git 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/AuthorityRuleConfigurationRepositoryTupleSwapper.java
 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/AuthorityRuleConfigurationRepositoryTupleSwapper.java
index 914878ac3ef..a2abcca2f7e 100644
--- 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/AuthorityRuleConfigurationRepositoryTupleSwapper.java
+++ 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/yaml/swapper/AuthorityRuleConfigurationRepositoryTupleSwapper.java
@@ -19,35 +19,13 @@ package org.apache.shardingsphere.authority.yaml.swapper;
 
 import org.apache.shardingsphere.authority.constant.AuthorityOrder;
 import 
org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
-import org.apache.shardingsphere.mode.path.GlobalNodePath;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Optional;
-
 /**
  * Authority rule configuration repository tuple swapper.
  */
 public final class AuthorityRuleConfigurationRepositoryTupleSwapper implements 
RepositoryTupleSwapper<YamlAuthorityRuleConfiguration> {
     
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlAuthorityRuleConfiguration yamlRuleConfig) {
-        return Collections.singleton(new RepositoryTuple(getRuleTypeName(), 
YamlEngine.marshal(yamlRuleConfig)));
-    }
-    
-    @Override
-    public Optional<YamlAuthorityRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        for (RepositoryTuple each : repositoryTuples) {
-            if (GlobalNodePath.getVersion(getRuleTypeName(), 
each.getKey()).isPresent()) {
-                return Optional.of(YamlEngine.unmarshal(each.getValue(), 
YamlAuthorityRuleConfiguration.class));
-            }
-        }
-        return Optional.empty();
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "authority";
diff --git 
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/yaml/config/YamlGlobalClockRuleConfiguration.java
 
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/yaml/config/YamlGlobalClockRuleConfiguration.java
index 2d86578c016..dd40944cc28 100644
--- 
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/yaml/config/YamlGlobalClockRuleConfiguration.java
+++ 
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/yaml/config/YamlGlobalClockRuleConfiguration.java
@@ -21,12 +21,16 @@ import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleType;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 
 import java.util.Properties;
 
 /**
  * Global clock rule configuration for YAML.
  */
+@RepositoryTupleEntity
+@RepositoryTupleType("global_clock")
 @Getter
 @Setter
 public final class YamlGlobalClockRuleConfiguration implements 
YamlGlobalRuleConfiguration {
diff --git 
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/yaml/swapper/GlobalClockRuleConfigurationRepositoryTupleSwapper.java
 
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/yaml/swapper/GlobalClockRuleConfigurationRepositoryTupleSwapper.java
index 4b99cdf2753..c14a3124b4c 100644
--- 
a/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/yaml/swapper/GlobalClockRuleConfigurationRepositoryTupleSwapper.java
+++ 
b/kernel/global-clock/core/src/main/java/org/apache/shardingsphere/globalclock/yaml/swapper/GlobalClockRuleConfigurationRepositoryTupleSwapper.java
@@ -19,35 +19,13 @@ package org.apache.shardingsphere.globalclock.yaml.swapper;
 
 import org.apache.shardingsphere.globalclock.rule.constant.GlobalClockOrder;
 import 
org.apache.shardingsphere.globalclock.yaml.config.YamlGlobalClockRuleConfiguration;
-import org.apache.shardingsphere.mode.path.GlobalNodePath;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Optional;
-
 /**
  * Global clock rule configuration repository tuple swapper.
  */
 public final class GlobalClockRuleConfigurationRepositoryTupleSwapper 
implements RepositoryTupleSwapper<YamlGlobalClockRuleConfiguration> {
     
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlGlobalClockRuleConfiguration yamlRuleConfig) {
-        return Collections.singleton(new RepositoryTuple(getRuleTypeName(), 
YamlEngine.marshal(yamlRuleConfig)));
-    }
-    
-    @Override
-    public Optional<YamlGlobalClockRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        for (RepositoryTuple each : repositoryTuples) {
-            if (GlobalNodePath.getVersion(getRuleTypeName(), 
each.getKey()).isPresent()) {
-                return Optional.of(YamlEngine.unmarshal(each.getValue(), 
YamlGlobalClockRuleConfiguration.class));
-            }
-        }
-        return Optional.empty();
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "global_clock";
diff --git 
a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/config/YamlLoggingRuleConfiguration.java
 
b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/config/YamlLoggingRuleConfiguration.java
index c47bdb2eeb6..5c2da869dfe 100644
--- 
a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/config/YamlLoggingRuleConfiguration.java
+++ 
b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/config/YamlLoggingRuleConfiguration.java
@@ -20,6 +20,8 @@ package org.apache.shardingsphere.logging.yaml.config;
 import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleType;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 import org.apache.shardingsphere.logging.config.LoggingRuleConfiguration;
 
 import java.util.Collection;
@@ -28,6 +30,8 @@ import java.util.LinkedList;
 /**
  * Logging rule configuration for YAML.
  */
+@RepositoryTupleEntity
+@RepositoryTupleType("logging")
 @Getter
 @Setter
 public final class YamlLoggingRuleConfiguration implements 
YamlGlobalRuleConfiguration {
diff --git 
a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/swapper/LoggingRuleConfigurationRepositoryTupleSwapper.java
 
b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/swapper/LoggingRuleConfigurationRepositoryTupleSwapper.java
index e20082d2ee4..444347cba0c 100644
--- 
a/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/swapper/LoggingRuleConfigurationRepositoryTupleSwapper.java
+++ 
b/kernel/logging/core/src/main/java/org/apache/shardingsphere/logging/yaml/swapper/LoggingRuleConfigurationRepositoryTupleSwapper.java
@@ -17,37 +17,15 @@
 
 package org.apache.shardingsphere.logging.yaml.swapper;
 
-import org.apache.shardingsphere.mode.path.GlobalNodePath;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import org.apache.shardingsphere.logging.constant.LoggingOrder;
 import 
org.apache.shardingsphere.logging.yaml.config.YamlLoggingRuleConfiguration;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Optional;
-
 /**
  * Logging rule configuration repository tuple swapper.
  */
 public final class LoggingRuleConfigurationRepositoryTupleSwapper implements 
RepositoryTupleSwapper<YamlLoggingRuleConfiguration> {
     
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlLoggingRuleConfiguration yamlRuleConfig) {
-        return Collections.singleton(new RepositoryTuple(getRuleTypeName(), 
YamlEngine.marshal(yamlRuleConfig)));
-    }
-    
-    @Override
-    public Optional<YamlLoggingRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        for (RepositoryTuple each : repositoryTuples) {
-            if (GlobalNodePath.getVersion(getRuleTypeName(), 
each.getKey()).isPresent()) {
-                return Optional.of(YamlEngine.unmarshal(each.getValue(), 
YamlLoggingRuleConfiguration.class));
-            }
-        }
-        return Optional.empty();
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "logging";
diff --git 
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/RepositoryTupleSwapperEngine.java
 
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/RepositoryTupleSwapperEngine.java
index fae7bdfd424..ed1d2234735 100644
--- 
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/RepositoryTupleSwapperEngine.java
+++ 
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/RepositoryTupleSwapperEngine.java
@@ -22,6 +22,7 @@ import 
org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import 
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
+import org.apache.shardingsphere.mode.engine.AutoRepositoryTupleSwapperEngine;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 
 import java.util.Collection;
@@ -47,8 +48,10 @@ public final class RepositoryTupleSwapperEngine {
         }
         Collection<RuleConfiguration> result = new LinkedList<>();
         YamlRuleConfigurationSwapperEngine yamlSwapperEngine = new 
YamlRuleConfigurationSwapperEngine();
+        AutoRepositoryTupleSwapperEngine repositoryTupleSwapperEngine = new 
AutoRepositoryTupleSwapperEngine();
         for (RepositoryTupleSwapper each : 
OrderedSPILoader.getServices(RepositoryTupleSwapper.class)) {
-            each.swapToObject(repositoryTuples).ifPresent(optional -> 
result.add(yamlSwapperEngine.swapToRuleConfiguration((YamlRuleConfiguration) 
optional)));
+            repositoryTupleSwapperEngine
+                    .swapToObject(repositoryTuples, 
each.getTypeClass()).ifPresent(optional -> 
result.add(yamlSwapperEngine.swapToRuleConfiguration((YamlRuleConfiguration) 
optional)));
         }
         return result;
     }
@@ -66,9 +69,10 @@ public final class RepositoryTupleSwapperEngine {
             return Optional.empty();
         }
         YamlRuleConfigurationSwapperEngine yamlSwapperEngine = new 
YamlRuleConfigurationSwapperEngine();
+        AutoRepositoryTupleSwapperEngine repositoryTupleSwapperEngine = new 
AutoRepositoryTupleSwapperEngine();
         for (RepositoryTupleSwapper each : 
OrderedSPILoader.getServices(RepositoryTupleSwapper.class)) {
             if (ruleName.equals(each.getRuleTypeName())) {
-                Optional<YamlRuleConfiguration> yamlRuleConfig = 
each.swapToObject(repositoryTuples);
+                Optional<YamlRuleConfiguration> yamlRuleConfig = 
repositoryTupleSwapperEngine.swapToObject(repositoryTuples, 
each.getTypeClass());
                 return 
yamlRuleConfig.map(yamlSwapperEngine::swapToRuleConfiguration);
             }
         }
diff --git 
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/database/rule/DatabaseRulePersistService.java
 
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/database/rule/DatabaseRulePersistService.java
index 63e527b1938..88c8e077a51 100644
--- 
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/database/rule/DatabaseRulePersistService.java
+++ 
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/database/rule/DatabaseRulePersistService.java
@@ -28,6 +28,7 @@ import 
org.apache.shardingsphere.metadata.persist.node.metadata.DatabaseRuleMeta
 import 
org.apache.shardingsphere.metadata.persist.service.config.RepositoryTuplePersistService;
 import 
org.apache.shardingsphere.metadata.persist.service.config.RepositoryTupleSwapperEngine;
 import 
org.apache.shardingsphere.metadata.persist.service.config.database.DatabaseBasedPersistService;
+import org.apache.shardingsphere.mode.engine.AutoRepositoryTupleSwapperEngine;
 import org.apache.shardingsphere.mode.spi.PersistRepository;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 
@@ -53,12 +54,13 @@ public final class DatabaseRulePersistService implements 
DatabaseBasedPersistSer
         repositoryTuplePersistService = new 
RepositoryTuplePersistService(repository);
     }
     
-    @SuppressWarnings({"unchecked", "rawtypes"})
+    @SuppressWarnings("rawtypes")
     @Override
     public void persist(final String databaseName, final 
Collection<RuleConfiguration> configs) {
         Collection<YamlRuleConfiguration> yamlRuleConfigs = new 
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(configs);
+        AutoRepositoryTupleSwapperEngine repositoryTupleSwapperEngine = new 
AutoRepositoryTupleSwapperEngine();
         for (Entry<YamlRuleConfiguration, RepositoryTupleSwapper> entry : 
OrderedSPILoader.getServices(RepositoryTupleSwapper.class, 
yamlRuleConfigs).entrySet()) {
-            Collection<RepositoryTuple> repositoryTuples = 
entry.getValue().swapToRepositoryTuples(entry.getKey());
+            Collection<RepositoryTuple> repositoryTuples = 
repositoryTupleSwapperEngine.swapToRepositoryTuples(entry.getKey());
             if (!repositoryTuples.isEmpty()) {
                 persistDataNodes(databaseName, 
entry.getValue().getRuleTypeName(), repositoryTuples);
             }
@@ -75,13 +77,14 @@ public final class DatabaseRulePersistService implements 
DatabaseBasedPersistSer
         
repository.delete(DatabaseRuleMetaDataNode.getDatabaseRuleNode(databaseName, 
name));
     }
     
-    @SuppressWarnings({"unchecked", "rawtypes"})
+    @SuppressWarnings("rawtypes")
     @Override
     public Collection<MetaDataVersion> persistConfigurations(final String 
databaseName, final Collection<RuleConfiguration> configs) {
         Collection<MetaDataVersion> result = new LinkedList<>();
+        AutoRepositoryTupleSwapperEngine repositoryTupleSwapperEngine = new 
AutoRepositoryTupleSwapperEngine();
         Collection<YamlRuleConfiguration> yamlRuleConfigs = new 
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(configs);
         for (Entry<YamlRuleConfiguration, RepositoryTupleSwapper> entry : 
OrderedSPILoader.getServices(RepositoryTupleSwapper.class, 
yamlRuleConfigs).entrySet()) {
-            Collection<RepositoryTuple> repositoryTuples = 
entry.getValue().swapToRepositoryTuples(entry.getKey());
+            Collection<RepositoryTuple> repositoryTuples = 
repositoryTupleSwapperEngine.swapToRepositoryTuples(entry.getKey());
             if (!repositoryTuples.isEmpty()) {
                 result.addAll(persistDataNodes(databaseName, 
entry.getValue().getRuleTypeName(), repositoryTuples));
             }
@@ -103,13 +106,14 @@ public final class DatabaseRulePersistService implements 
DatabaseBasedPersistSer
         return result;
     }
     
-    @SuppressWarnings({"unchecked", "rawtypes"})
+    @SuppressWarnings("rawtypes")
     @Override
     public Collection<MetaDataVersion> deleteConfigurations(final String 
databaseName, final Collection<RuleConfiguration> configs) {
         Collection<MetaDataVersion> result = new LinkedList<>();
+        AutoRepositoryTupleSwapperEngine repositoryTupleSwapperEngine = new 
AutoRepositoryTupleSwapperEngine();
         Collection<YamlRuleConfiguration> yamlRuleConfigs = new 
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(configs);
         for (Entry<YamlRuleConfiguration, RepositoryTupleSwapper> entry : 
OrderedSPILoader.getServices(RepositoryTupleSwapper.class, 
yamlRuleConfigs).entrySet()) {
-            Collection<RepositoryTuple> repositoryTuples = 
entry.getValue().swapToRepositoryTuples(entry.getKey());
+            Collection<RepositoryTuple> repositoryTuples = 
repositoryTupleSwapperEngine.swapToRepositoryTuples(entry.getKey());
             if (repositoryTuples.isEmpty()) {
                 continue;
             }
diff --git 
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/global/GlobalRulePersistService.java
 
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/global/GlobalRulePersistService.java
index 92dbc1229b0..6a0d55663a0 100644
--- 
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/global/GlobalRulePersistService.java
+++ 
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/config/global/GlobalRulePersistService.java
@@ -24,6 +24,7 @@ import 
org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import 
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
+import org.apache.shardingsphere.mode.engine.AutoRepositoryTupleSwapperEngine;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 import 
org.apache.shardingsphere.metadata.persist.service.config.RepositoryTupleSwapperEngine;
 import org.apache.shardingsphere.metadata.persist.node.GlobalNode;
@@ -56,13 +57,14 @@ public final class GlobalRulePersistService implements 
GlobalPersistService<Coll
         repositoryTuplePersistService = new 
RepositoryTuplePersistService(repository);
     }
     
-    @SuppressWarnings({"unchecked", "rawtypes"})
+    @SuppressWarnings("rawtypes")
     @Override
     public void persist(final Collection<RuleConfiguration> globalRuleConfigs) 
{
         Collection<MetaDataVersion> metaDataVersions = new LinkedList<>();
+        AutoRepositoryTupleSwapperEngine repositoryTupleSwapperEngine = new 
AutoRepositoryTupleSwapperEngine();
         Collection<YamlRuleConfiguration> yamlGlobalRuleConfigs = new 
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(globalRuleConfigs);
         for (Entry<YamlRuleConfiguration, RepositoryTupleSwapper> entry : 
OrderedSPILoader.getServices(RepositoryTupleSwapper.class, 
yamlGlobalRuleConfigs).entrySet()) {
-            Collection<RepositoryTuple> repositoryTuples = 
entry.getValue().swapToRepositoryTuples(entry.getKey());
+            Collection<RepositoryTuple> repositoryTuples = 
repositoryTupleSwapperEngine.swapToRepositoryTuples(entry.getKey());
             if (!repositoryTuples.isEmpty()) {
                 metaDataVersions.addAll(persistTuples(repositoryTuples));
             }
diff --git 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
 
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
index c3521955393..f358700b0f8 100644
--- 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
+++ 
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
@@ -20,7 +20,10 @@ package org.apache.shardingsphere.single.yaml.config.pojo;
 import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleType;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
+import 
org.apache.shardingsphere.single.metadata.nodepath.SingleRuleNodePathProvider;
 
 import java.util.Collection;
 import java.util.LinkedList;
@@ -28,6 +31,8 @@ import java.util.LinkedList;
 /**
  * Single rule configuration for YAML.
  */
+@RepositoryTupleEntity
+@RepositoryTupleType(SingleRuleNodePathProvider.TABLES)
 @Getter
 @Setter
 public final class YamlSingleRuleConfiguration implements 
YamlRuleConfiguration {
diff --git 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/SingleRuleConfigurationRepositoryTupleSwapper.java
 
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/SingleRuleConfigurationRepositoryTupleSwapper.java
index 7e207564387..4337991ce3d 100644
--- 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/SingleRuleConfigurationRepositoryTupleSwapper.java
+++ 
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/SingleRuleConfigurationRepositoryTupleSwapper.java
@@ -17,41 +17,15 @@
 
 package org.apache.shardingsphere.single.yaml.config.swapper;
 
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
-import org.apache.shardingsphere.mode.path.rule.RuleNodePath;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 import org.apache.shardingsphere.single.constant.SingleOrder;
-import 
org.apache.shardingsphere.single.metadata.nodepath.SingleRuleNodePathProvider;
 import 
org.apache.shardingsphere.single.yaml.config.pojo.YamlSingleRuleConfiguration;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
 /**
  * Single rule configuration repository tuple swapper.
  */
 public final class SingleRuleConfigurationRepositoryTupleSwapper implements 
RepositoryTupleSwapper<YamlSingleRuleConfiguration> {
     
-    private final RuleNodePath ruleNodePath = new 
SingleRuleNodePathProvider().getRuleNodePath();
-    
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlSingleRuleConfiguration yamlRuleConfig) {
-        return Collections.singleton(new 
RepositoryTuple(SingleRuleNodePathProvider.TABLES, 
YamlEngine.marshal(yamlRuleConfig)));
-    }
-    
-    @Override
-    public Optional<YamlSingleRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        for (RepositoryTuple each : repositoryTuples.stream().filter(each -> 
ruleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList()))
 {
-            if 
(ruleNodePath.getUniqueItem(SingleRuleNodePathProvider.TABLES).isValidatedPath(each.getKey()))
 {
-                return Optional.of(YamlEngine.unmarshal(each.getValue(), 
YamlSingleRuleConfiguration.class));
-            }
-        }
-        return Optional.empty();
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "single";
diff --git 
a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/config/YamlSQLFederationRuleConfiguration.java
 
b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/config/YamlSQLFederationRuleConfiguration.java
index a8f52bf1b06..ec286312c6d 100644
--- 
a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/config/YamlSQLFederationRuleConfiguration.java
+++ 
b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/config/YamlSQLFederationRuleConfiguration.java
@@ -20,11 +20,15 @@ package org.apache.shardingsphere.sqlfederation.yaml.config;
 import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleType;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 import 
org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
 
 /**
  * SQL federation rule configuration for YAML.
  */
+@RepositoryTupleEntity
+@RepositoryTupleType("sql_federation")
 @Getter
 @Setter
 public final class YamlSQLFederationRuleConfiguration implements 
YamlGlobalRuleConfiguration {
diff --git 
a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/SQLFederationRuleConfigurationRepositoryTupleSwapper.java
 
b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/SQLFederationRuleConfigurationRepositoryTupleSwapper.java
index bd5fdf19570..6c7669bbdec 100644
--- 
a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/SQLFederationRuleConfigurationRepositoryTupleSwapper.java
+++ 
b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/SQLFederationRuleConfigurationRepositoryTupleSwapper.java
@@ -17,37 +17,15 @@
 
 package org.apache.shardingsphere.sqlfederation.yaml.swapper;
 
-import org.apache.shardingsphere.mode.path.GlobalNodePath;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 import org.apache.shardingsphere.sqlfederation.constant.SQLFederationOrder;
 import 
org.apache.shardingsphere.sqlfederation.yaml.config.YamlSQLFederationRuleConfiguration;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Optional;
-
 /**
  * SQL federation rule configuration repository tuple swapper.
  */
 public final class SQLFederationRuleConfigurationRepositoryTupleSwapper 
implements RepositoryTupleSwapper<YamlSQLFederationRuleConfiguration> {
     
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlSQLFederationRuleConfiguration yamlRuleConfig) {
-        return Collections.singleton(new RepositoryTuple(getRuleTypeName(), 
YamlEngine.marshal(yamlRuleConfig)));
-    }
-    
-    @Override
-    public Optional<YamlSQLFederationRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        for (RepositoryTuple each : repositoryTuples) {
-            if (GlobalNodePath.getVersion(getRuleTypeName(), 
each.getKey()).isPresent()) {
-                return Optional.of(YamlEngine.unmarshal(each.getValue(), 
YamlSQLFederationRuleConfiguration.class));
-            }
-        }
-        return Optional.empty();
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "sql_federation";
diff --git 
a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/config/YamlSQLParserRuleConfiguration.java
 
b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/config/YamlSQLParserRuleConfiguration.java
index 3cfacf2ba20..93ff4148cbd 100644
--- 
a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/config/YamlSQLParserRuleConfiguration.java
+++ 
b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/config/YamlSQLParserRuleConfiguration.java
@@ -20,11 +20,15 @@ package org.apache.shardingsphere.parser.yaml.config;
 import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleType;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
 
 /**
  * SQL parser configuration for YAML.
  */
+@RepositoryTupleEntity
+@RepositoryTupleType("sql_parser")
 @Getter
 @Setter
 public final class YamlSQLParserRuleConfiguration implements 
YamlGlobalRuleConfiguration {
diff --git 
a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/swapper/SQLParserRuleConfigurationRepositoryTupleSwapper.java
 
b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/swapper/SQLParserRuleConfigurationRepositoryTupleSwapper.java
index 4256387614c..7d41a558a2a 100644
--- 
a/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/swapper/SQLParserRuleConfigurationRepositoryTupleSwapper.java
+++ 
b/kernel/sql-parser/core/src/main/java/org/apache/shardingsphere/parser/yaml/swapper/SQLParserRuleConfigurationRepositoryTupleSwapper.java
@@ -17,37 +17,15 @@
 
 package org.apache.shardingsphere.parser.yaml.swapper;
 
-import org.apache.shardingsphere.mode.path.GlobalNodePath;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 import org.apache.shardingsphere.parser.constant.SQLParserOrder;
 import 
org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfiguration;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Optional;
-
 /**
  * SQL parser rule configuration repository tuple swapper.
  */
 public final class SQLParserRuleConfigurationRepositoryTupleSwapper implements 
RepositoryTupleSwapper<YamlSQLParserRuleConfiguration> {
     
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlSQLParserRuleConfiguration yamlRuleConfig) {
-        return Collections.singleton(new RepositoryTuple(getRuleTypeName(), 
YamlEngine.marshal(yamlRuleConfig)));
-    }
-    
-    @Override
-    public Optional<YamlSQLParserRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        for (RepositoryTuple each : repositoryTuples) {
-            if (GlobalNodePath.getVersion(getRuleTypeName(), 
each.getKey()).isPresent()) {
-                return Optional.of(YamlEngine.unmarshal(each.getValue(), 
YamlSQLParserRuleConfiguration.class));
-            }
-        }
-        return Optional.empty();
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "sql_parser";
diff --git 
a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/config/YamlSQLTranslatorRuleConfiguration.java
 
b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/config/YamlSQLTranslatorRuleConfiguration.java
index 5887855fc8c..12b0ba4f980 100644
--- 
a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/config/YamlSQLTranslatorRuleConfiguration.java
+++ 
b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/config/YamlSQLTranslatorRuleConfiguration.java
@@ -20,6 +20,8 @@ package org.apache.shardingsphere.sqltranslator.yaml.config;
 import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleType;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 import 
org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration;
 
 import java.util.Properties;
@@ -27,6 +29,8 @@ import java.util.Properties;
 /**
  * SQL translator configuration for YAML.
  */
+@RepositoryTupleEntity
+@RepositoryTupleType("sql_translator")
 @Getter
 @Setter
 public final class YamlSQLTranslatorRuleConfiguration implements 
YamlGlobalRuleConfiguration {
diff --git 
a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/swapper/SQLTranslatorRuleConfigurationRepositoryTupleSwapper.java
 
b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/swapper/SQLTranslatorRuleConfigurationRepositoryTupleSwapper.java
index aca0629d53e..86c1c215fc9 100644
--- 
a/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/swapper/SQLTranslatorRuleConfigurationRepositoryTupleSwapper.java
+++ 
b/kernel/sql-translator/core/src/main/java/org/apache/shardingsphere/sqltranslator/yaml/swapper/SQLTranslatorRuleConfigurationRepositoryTupleSwapper.java
@@ -17,37 +17,15 @@
 
 package org.apache.shardingsphere.sqltranslator.yaml.swapper;
 
-import org.apache.shardingsphere.mode.path.GlobalNodePath;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 import org.apache.shardingsphere.sqltranslator.constant.SQLTranslatorOrder;
 import 
org.apache.shardingsphere.sqltranslator.yaml.config.YamlSQLTranslatorRuleConfiguration;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Optional;
-
 /**
  * SQL translator rule configuration repository tuple swapper.
  */
 public final class SQLTranslatorRuleConfigurationRepositoryTupleSwapper 
implements RepositoryTupleSwapper<YamlSQLTranslatorRuleConfiguration> {
     
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlSQLTranslatorRuleConfiguration yamlRuleConfig) {
-        return Collections.singleton(new RepositoryTuple(getRuleTypeName(), 
YamlEngine.marshal(yamlRuleConfig)));
-    }
-    
-    @Override
-    public Optional<YamlSQLTranslatorRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        for (RepositoryTuple each : repositoryTuples) {
-            if (GlobalNodePath.getVersion(getRuleTypeName(), 
each.getKey()).isPresent()) {
-                return Optional.of(YamlEngine.unmarshal(each.getValue(), 
YamlSQLTranslatorRuleConfiguration.class));
-            }
-        }
-        return Optional.empty();
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "sql_translator";
diff --git 
a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/config/YamlTrafficRuleConfiguration.java
 
b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/config/YamlTrafficRuleConfiguration.java
index 85e0f983691..9d4aefa7e84 100644
--- 
a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/config/YamlTrafficRuleConfiguration.java
+++ 
b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/config/YamlTrafficRuleConfiguration.java
@@ -21,6 +21,8 @@ import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleType;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
 
 import java.util.LinkedHashMap;
@@ -29,6 +31,8 @@ import java.util.Map;
 /**
  * Traffic rule configuration for YAML.
  */
+@RepositoryTupleEntity
+@RepositoryTupleType("traffic")
 @Getter
 @Setter
 public final class YamlTrafficRuleConfiguration implements 
YamlGlobalRuleConfiguration {
diff --git 
a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficRuleConfigurationRepositoryTupleSwapper.java
 
b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficRuleConfigurationRepositoryTupleSwapper.java
index 19c8ee4d0ac..abfd53d333f 100644
--- 
a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficRuleConfigurationRepositoryTupleSwapper.java
+++ 
b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficRuleConfigurationRepositoryTupleSwapper.java
@@ -17,37 +17,15 @@
 
 package org.apache.shardingsphere.traffic.yaml.swapper;
 
-import org.apache.shardingsphere.mode.path.GlobalNodePath;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 import org.apache.shardingsphere.traffic.constant.TrafficOrder;
 import 
org.apache.shardingsphere.traffic.yaml.config.YamlTrafficRuleConfiguration;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Optional;
-
 /**
  * Traffic rule configuration repository tuple swapper.
  */
 public final class TrafficRuleConfigurationRepositoryTupleSwapper implements 
RepositoryTupleSwapper<YamlTrafficRuleConfiguration> {
     
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlTrafficRuleConfiguration yamlRuleConfig) {
-        return Collections.singleton(new RepositoryTuple(getRuleTypeName(), 
YamlEngine.marshal(yamlRuleConfig)));
-    }
-    
-    @Override
-    public Optional<YamlTrafficRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        for (RepositoryTuple each : repositoryTuples) {
-            if (GlobalNodePath.getVersion(getRuleTypeName(), 
each.getKey()).isPresent()) {
-                return Optional.of(YamlEngine.unmarshal(each.getValue(), 
YamlTrafficRuleConfiguration.class));
-            }
-        }
-        return Optional.empty();
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "traffic";
diff --git 
a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/config/YamlTransactionRuleConfiguration.java
 
b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/config/YamlTransactionRuleConfiguration.java
index 5c665ef1d52..12251de1785 100644
--- 
a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/config/YamlTransactionRuleConfiguration.java
+++ 
b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/config/YamlTransactionRuleConfiguration.java
@@ -20,6 +20,8 @@ package org.apache.shardingsphere.transaction.yaml.config;
 import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleType;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
 import 
org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
 
 import java.util.Properties;
@@ -27,6 +29,8 @@ import java.util.Properties;
 /**
  * Transaction rule configuration for YAML.
  */
+@RepositoryTupleEntity
+@RepositoryTupleType("transaction")
 @Getter
 @Setter
 public final class YamlTransactionRuleConfiguration implements 
YamlGlobalRuleConfiguration {
diff --git 
a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationRepositoryTupleSwapper.java
 
b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationRepositoryTupleSwapper.java
index 0c38f9efe1d..0b975360fe9 100644
--- 
a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationRepositoryTupleSwapper.java
+++ 
b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/yaml/swapper/TransactionRuleConfigurationRepositoryTupleSwapper.java
@@ -17,37 +17,15 @@
 
 package org.apache.shardingsphere.transaction.yaml.swapper;
 
-import org.apache.shardingsphere.mode.path.GlobalNodePath;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
 import org.apache.shardingsphere.transaction.constant.TransactionOrder;
 import 
org.apache.shardingsphere.transaction.yaml.config.YamlTransactionRuleConfiguration;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Optional;
-
 /**
  * Transaction rule configuration repository tuple swapper.
  */
 public final class TransactionRuleConfigurationRepositoryTupleSwapper 
implements RepositoryTupleSwapper<YamlTransactionRuleConfiguration> {
     
-    @Override
-    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlTransactionRuleConfiguration yamlRuleConfig) {
-        return Collections.singleton(new RepositoryTuple(getRuleTypeName(), 
YamlEngine.marshal(yamlRuleConfig)));
-    }
-    
-    @Override
-    public Optional<YamlTransactionRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples) {
-        for (RepositoryTuple each : repositoryTuples) {
-            if (GlobalNodePath.getVersion(getRuleTypeName(), 
each.getKey()).isPresent()) {
-                return Optional.of(YamlEngine.unmarshal(each.getValue(), 
YamlTransactionRuleConfiguration.class));
-            }
-        }
-        return Optional.empty();
-    }
-    
     @Override
     public String getRuleTypeName() {
         return "transaction";
diff --git 
a/mode/api/src/main/java/org/apache/shardingsphere/mode/engine/AutoRepositoryTupleSwapperEngine.java
 
b/mode/api/src/main/java/org/apache/shardingsphere/mode/engine/AutoRepositoryTupleSwapperEngine.java
new file mode 100644
index 00000000000..a8a9fdb0d3f
--- /dev/null
+++ 
b/mode/api/src/main/java/org/apache/shardingsphere/mode/engine/AutoRepositoryTupleSwapperEngine.java
@@ -0,0 +1,224 @@
+/*
+ * 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.mode.engine;
+
+import com.google.common.base.Strings;
+import lombok.SneakyThrows;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
+import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
+import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlGlobalRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleField;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleType;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleEntity;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.annotation.RepositoryTupleKeyNameGenerator;
+import org.apache.shardingsphere.mode.path.GlobalNodePath;
+import org.apache.shardingsphere.mode.path.rule.RuleNodePath;
+import org.apache.shardingsphere.mode.spi.RuleNodePathProvider;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * Auto repository tuple swapper engine.
+ */
+public final class AutoRepositoryTupleSwapperEngine {
+    
+    /**
+     * Swap to repository tuples.
+     *
+     * @param yamlRuleConfig YAML rule configuration to be swapped
+     * @return repository tuples
+     */
+    public Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlRuleConfiguration yamlRuleConfig) {
+        if (null == 
yamlRuleConfig.getClass().getAnnotation(RepositoryTupleEntity.class)) {
+            return Collections.emptyList();
+        }
+        RepositoryTupleType tupleType = 
yamlRuleConfig.getClass().getAnnotation(RepositoryTupleType.class);
+        if (null != tupleType) {
+            return Collections.singleton(new 
RepositoryTuple(tupleType.value(), YamlEngine.marshal(yamlRuleConfig)));
+        }
+        Collection<RepositoryTuple> result = new LinkedList<>();
+        RuleNodePath ruleNodePath = 
getRuleNodePathProvider(yamlRuleConfig).getRuleNodePath();
+        for (Field each : getFields(yamlRuleConfig.getClass())) {
+            boolean isAccessible = each.isAccessible();
+            each.setAccessible(true);
+            result.addAll(swapToRepositoryTuples(yamlRuleConfig, ruleNodePath, 
each));
+            each.setAccessible(isAccessible);
+        }
+        return result;
+    }
+    
+    @SneakyThrows(ReflectiveOperationException.class)
+    @SuppressWarnings("rawtypes")
+    private Collection<RepositoryTuple> swapToRepositoryTuples(final 
YamlRuleConfiguration yamlRuleConfig, final RuleNodePath ruleNodePath, final 
Field field) {
+        Object fieldValue = field.get(yamlRuleConfig);
+        if (null == fieldValue) {
+            return Collections.emptyList();
+        }
+        RepositoryTupleField tupleField = 
field.getAnnotation(RepositoryTupleField.class);
+        RepositoryTupleKeyNameGenerator tupleKeyNameGenerator = 
field.getAnnotation(RepositoryTupleKeyNameGenerator.class);
+        if (null != tupleKeyNameGenerator && fieldValue instanceof Collection) 
{
+            Collection<RepositoryTuple> result = new LinkedList<>();
+            for (Object value : (Collection) fieldValue) {
+                String tupleKeyName = 
tupleKeyNameGenerator.value().getConstructor().newInstance().generate(value);
+                result.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(tupleField.value()).getPath(tupleKeyName),
 value.toString()));
+            }
+            return result;
+        }
+        if (fieldValue instanceof Map) {
+            Collection<RepositoryTuple> result = new LinkedList<>();
+            for (Object entry : ((Map) fieldValue).entrySet()) {
+                result.add(new 
RepositoryTuple(ruleNodePath.getNamedItem(tupleField.value()).getPath(((Entry) 
entry).getKey().toString()), YamlEngine.marshal(((Entry) entry).getValue())));
+            }
+            return result;
+        }
+        if (fieldValue instanceof Collection && !((Collection) 
fieldValue).isEmpty()) {
+            return Collections.singleton(new 
RepositoryTuple(ruleNodePath.getUniqueItem(tupleField.value()).getPath(), 
YamlEngine.marshal(fieldValue)));
+        }
+        if (fieldValue instanceof String && !((String) fieldValue).isEmpty()) {
+            return Collections.singleton(new 
RepositoryTuple(ruleNodePath.getUniqueItem(tupleField.value()).getPath(), 
fieldValue.toString()));
+        }
+        if (fieldValue instanceof Boolean || fieldValue instanceof Integer || 
fieldValue instanceof Long) {
+            return Collections.singleton(new 
RepositoryTuple(ruleNodePath.getUniqueItem(tupleField.value()).getPath(), 
fieldValue.toString()));
+        }
+        return Collections.singleton(new 
RepositoryTuple(ruleNodePath.getUniqueItem(tupleField.value()).getPath(), 
YamlEngine.marshal(fieldValue)));
+    }
+    
+    // TODO 修改 RuleNodePathProvider 为 TypedSPI
+    private RuleNodePathProvider getRuleNodePathProvider(final 
YamlRuleConfiguration yamlRuleConfig) {
+        for (RuleNodePathProvider each : 
ShardingSphereServiceLoader.getServiceInstances(RuleNodePathProvider.class)) {
+            if 
(yamlRuleConfig.getRuleConfigurationType().getSimpleName().toLowerCase().contains(String.join("",
 each.getRuleNodePath().getRoot().getRuleType().split("_")))) {
+                return each;
+            }
+        }
+        throw new ServiceProviderNotFoundException(RuleNodePathProvider.class, 
yamlRuleConfig);
+    }
+    
+    private Collection<Field> getFields(final Class<? extends 
YamlRuleConfiguration> yamlRuleConfigurationClass) {
+        return Arrays.stream(yamlRuleConfigurationClass.getDeclaredFields())
+                .filter(each -> null != 
each.getAnnotation(RepositoryTupleField.class))
+                .sorted(Comparator.comparingInt(o -> 
o.getAnnotation(RepositoryTupleField.class).order())).collect(Collectors.toList());
+    }
+    
+    /**
+     * Swap from repository tuple to YAML rule configurations.
+     *
+     * @param repositoryTuples repository tuples
+     * @param yamlRuleConfigurationClass YAML rule configuration class
+     * @return swapped YAML rule configurations
+     */
+    public Optional<YamlRuleConfiguration> swapToObject(final 
Collection<RepositoryTuple> repositoryTuples, final Class<? extends 
YamlRuleConfiguration> yamlRuleConfigurationClass) {
+        if (null == 
yamlRuleConfigurationClass.getAnnotation(RepositoryTupleEntity.class)) {
+            return Optional.empty();
+        }
+        RepositoryTupleType tupleType = 
yamlRuleConfigurationClass.getAnnotation(RepositoryTupleType.class);
+        if (null != tupleType) {
+            return swapToObjectForTypePersist(repositoryTuples, 
yamlRuleConfigurationClass, tupleType);
+        }
+        return swapToObjectForFieldPersist(repositoryTuples, 
yamlRuleConfigurationClass);
+    }
+    
+    @SneakyThrows(ReflectiveOperationException.class)
+    private Optional<YamlRuleConfiguration> swapToObjectForTypePersist(final 
Collection<RepositoryTuple> repositoryTuples,
+                                                                       final 
Class<? extends YamlRuleConfiguration> yamlRuleConfigurationClass, final 
RepositoryTupleType tupleType) {
+        if 
(YamlGlobalRuleConfiguration.class.isAssignableFrom(yamlRuleConfigurationClass))
 {
+            for (RepositoryTuple each : repositoryTuples) {
+                if (GlobalNodePath.getVersion(tupleType.value(), 
each.getKey()).isPresent()) {
+                    return Optional.of(YamlEngine.unmarshal(each.getValue(), 
yamlRuleConfigurationClass));
+                }
+            }
+            return Optional.empty();
+        }
+        YamlRuleConfiguration yamlRuleConfig = 
yamlRuleConfigurationClass.getConstructor().newInstance();
+        RuleNodePath ruleNodePath = 
getRuleNodePathProvider(yamlRuleConfig).getRuleNodePath();
+        for (RepositoryTuple each : repositoryTuples.stream().filter(each -> 
ruleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList()))
 {
+            if 
(ruleNodePath.getUniqueItem(tupleType.value()).isValidatedPath(each.getKey())) {
+                return Optional.of(YamlEngine.unmarshal(each.getValue(), 
yamlRuleConfigurationClass));
+            }
+        }
+        return Optional.empty();
+    }
+    
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    @SneakyThrows(ReflectiveOperationException.class)
+    private Optional<YamlRuleConfiguration> swapToObjectForFieldPersist(final 
Collection<RepositoryTuple> repositoryTuples, final Class<? extends 
YamlRuleConfiguration> yamlRuleConfigurationClass) {
+        YamlRuleConfiguration yamlRuleConfig = 
yamlRuleConfigurationClass.getConstructor().newInstance();
+        RuleNodePath ruleNodePath = 
getRuleNodePathProvider(yamlRuleConfig).getRuleNodePath();
+        List<RepositoryTuple> validTuples = 
repositoryTuples.stream().filter(each -> 
ruleNodePath.getRoot().isValidatedPath(each.getKey())).collect(Collectors.toList());
+        if (validTuples.isEmpty()) {
+            return Optional.empty();
+        }
+        for (RepositoryTuple each : validTuples) {
+            for (Field field : getFields(yamlRuleConfigurationClass)) {
+                RepositoryTupleField tupleField = 
field.getAnnotation(RepositoryTupleField.class);
+                if (Strings.isNullOrEmpty(each.getValue())) {
+                    continue;
+                }
+                final boolean isAccessible = field.isAccessible();
+                field.setAccessible(true);
+                Object fieldValue = field.get(yamlRuleConfig);
+                RepositoryTupleKeyNameGenerator tupleKeyNameGenerator = 
field.getAnnotation(RepositoryTupleKeyNameGenerator.class);
+                if (null != tupleKeyNameGenerator && fieldValue instanceof 
Collection) {
+                    
ruleNodePath.getNamedItem(tupleField.value()).getName(each.getKey()).ifPresent(optional
 -> ((Collection) fieldValue).add(each.getValue()));
+                } else if (fieldValue instanceof Map) {
+                    Class<?> valueClass = (Class) ((ParameterizedType) 
field.getGenericType()).getActualTypeArguments()[1];
+                    
ruleNodePath.getNamedItem(tupleField.value()).getName(each.getKey()).ifPresent(optional
 -> ((Map) fieldValue).put(optional, YamlEngine.unmarshal(each.getValue(), 
valueClass)));
+                } else if (fieldValue instanceof Collection) {
+                    if 
(ruleNodePath.getUniqueItem(tupleField.value()).isValidatedPath(each.getKey())) 
{
+                        field.set(yamlRuleConfig, 
YamlEngine.unmarshal(each.getValue(), List.class));
+                    }
+                } else if (field.getType().equals(String.class)) {
+                    if 
(ruleNodePath.getUniqueItem(tupleField.value()).isValidatedPath(each.getKey())) 
{
+                        field.set(yamlRuleConfig, each.getValue());
+                    }
+                } else if (field.getType().equals(boolean.class) || 
field.getType().equals(Boolean.class)) {
+                    if 
(ruleNodePath.getUniqueItem(tupleField.value()).isValidatedPath(each.getKey())) 
{
+                        field.set(yamlRuleConfig, 
Boolean.parseBoolean(each.getValue()));
+                    }
+                } else if (field.getType().equals(int.class) || 
field.getType().equals(Integer.class)) {
+                    if 
(ruleNodePath.getUniqueItem(tupleField.value()).isValidatedPath(each.getKey())) 
{
+                        field.set(yamlRuleConfig, 
Integer.parseInt(each.getValue()));
+                    }
+                } else if (field.getType().equals(long.class) || 
field.getType().equals(Long.class)) {
+                    if 
(ruleNodePath.getUniqueItem(tupleField.value()).isValidatedPath(each.getKey())) 
{
+                        field.set(yamlRuleConfig, 
Long.parseLong(each.getValue()));
+                    }
+                } else {
+                    if 
(ruleNodePath.getUniqueItem(tupleField.value()).isValidatedPath(each.getKey())) 
{
+                        field.set(yamlRuleConfig, 
YamlEngine.unmarshal(each.getValue(), field.getType()));
+                    }
+                }
+                field.setAccessible(isAccessible);
+            }
+        }
+        return Optional.of(yamlRuleConfig);
+    }
+}
diff --git 
a/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RepositoryTupleSwapper.java
 
b/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RepositoryTupleSwapper.java
index 43ce6ffa9dd..cff459e4767 100644
--- 
a/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RepositoryTupleSwapper.java
+++ 
b/mode/api/src/main/java/org/apache/shardingsphere/mode/spi/RepositoryTupleSwapper.java
@@ -19,12 +19,8 @@ package org.apache.shardingsphere.mode.spi;
 
 import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
 import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPI;
-import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 
-import java.util.Collection;
-import java.util.Optional;
-
 /**
  * Repository tuple swapper.
  *
@@ -33,22 +29,6 @@ import java.util.Optional;
 @SingletonSPI
 public interface RepositoryTupleSwapper<T extends YamlRuleConfiguration> 
extends OrderedSPI<T> {
     
-    /**
-     * Swap to repository tuples.
-     *
-     * @param yamlRuleConfig YAML rule configuration to be swapped
-     * @return repository tuples
-     */
-    Collection<RepositoryTuple> swapToRepositoryTuples(T yamlRuleConfig);
-    
-    /**
-     * Swap from repository tuple to YAML rule configurations.
-     *
-     * @param repositoryTuples repository tuples
-     * @return swapped YAML rule configurations
-     */
-    Optional<T> swapToObject(Collection<RepositoryTuple> repositoryTuples);
-    
     /**
      * Get rule type name.
      *
diff --git 
a/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/RepositoryTupleSwapperIT.java
 
b/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/RepositoryTupleSwapperIT.java
index 6e3fe0c20b9..ea6e3029d2a 100644
--- 
a/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/RepositoryTupleSwapperIT.java
+++ 
b/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/RepositoryTupleSwapperIT.java
@@ -22,6 +22,7 @@ import 
org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
 import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
 import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.mode.spi.RepositoryTupleSwapper;
+import org.apache.shardingsphere.mode.engine.AutoRepositoryTupleSwapperEngine;
 import org.junit.jupiter.api.Test;
 
 import java.io.File;
@@ -59,11 +60,10 @@ public abstract class RepositoryTupleSwapperIT {
         this.isGlobalRule = isGlobalRule;
     }
     
-    @SuppressWarnings({"unchecked", "rawtypes"})
     @Test
     void assertSwapToRepositoryTuples() throws IOException {
         YamlRuleConfiguration yamlRuleConfig = loadYamlRuleConfiguration();
-        assertRepositoryTuples(new 
ArrayList<>(swapper.swapToRepositoryTuples(yamlRuleConfig)), yamlRuleConfig);
+        assertRepositoryTuples(new ArrayList<>(new 
AutoRepositoryTupleSwapperEngine().swapToRepositoryTuples(yamlRuleConfig)), 
yamlRuleConfig);
     }
     
     private YamlRuleConfiguration loadYamlRuleConfiguration() throws 
IOException {
@@ -91,9 +91,10 @@ public abstract class RepositoryTupleSwapperIT {
     @SuppressWarnings("unchecked")
     private String getActualYamlContent() throws IOException {
         YamlRuleConfiguration yamlRuleConfig = loadYamlRuleConfiguration();
-        Collection<RepositoryTuple> repositoryTuples = 
((Collection<RepositoryTuple>) 
swapper.swapToRepositoryTuples(yamlRuleConfig)).stream()
+        Collection<RepositoryTuple> repositoryTuples = new 
AutoRepositoryTupleSwapperEngine().swapToRepositoryTuples(yamlRuleConfig).stream()
                 .map(each -> new RepositoryTuple(getRepositoryTupleKey(each), 
each.getValue())).collect(Collectors.toList());
-        Optional<YamlRuleConfiguration> actualYamlRuleConfig = 
swapper.swapToObject(repositoryTuples);
+        AutoRepositoryTupleSwapperEngine repositoryTupleSwapperEngine = new 
AutoRepositoryTupleSwapperEngine();
+        Optional<YamlRuleConfiguration> actualYamlRuleConfig = 
repositoryTupleSwapperEngine.swapToObject(repositoryTuples, 
swapper.getTypeClass());
         assertTrue(actualYamlRuleConfig.isPresent());
         YamlRootConfiguration yamlRootConfig = new YamlRootConfiguration();
         
yamlRootConfig.setRules(Collections.singletonList(actualYamlRuleConfig.get()));

Reply via email to