/*
 * 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.api.config.encrypt;

import lombok.Getter;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Encrypt rule configuration.
 *
 * @author panjuan
 */
@Getter
public final class EncryptRuleConfigurationBak {
    
    private final Map<String, EncryptorRuleConfigurationBak> encryptros = new LinkedHashMap<>();
    
    private final Map<String, EncryptTableRuleConfiguration> tables = new LinkedHashMap<>();
}

@@ -851,16 +851,148 @@
 crypt;%0A%0A
+import com.google.common.base.Function;%0Aimport com.google.common.base.Preconditions;%0Aimport com.google.common.collect.Collections2;%0A
 import l
@@ -1023,29 +1023,26 @@
 va.util.
-LinkedHashMap
+Collection
 ;%0Aimport
@@ -1253,133 +1253,1091 @@
 rypt
-ros = new LinkedHashMap%3C%3E();%0A    %0A    private final Map%3CString, EncryptTableRuleConfiguration%3E tables = new LinkedHashMap%3C%3E();
+ors;%0A    %0A    private final Map%3CString, EncryptTableRuleConfiguration%3E tables;%0A    %0A    public EncryptRuleConfigurationBak(final Map%3CString, EncryptorRuleConfigurationBak%3E encryptors, final Map%3CString, EncryptTableRuleConfiguration%3E tables) %7B%0A        this.encryptors = encryptors;%0A        this.tables = tables;%0A        Preconditions.checkArgument(isUsingValidEncryptNames(), %22Invalid encryptorNames are used in EncryptTableRuleConfigurations.%22);%0A    %7D%0A    %0A    private boolean isUsingValidEncryptNames() %7B%0A        for (EncryptTableRuleConfiguration each : tables.values()) %7B%0A            Collection%3CString%3E encryptors = Collections2.transform(each.getColumns().values(), new Function%3CEncryptColumnRuleConfiguration, String%3E() %7B%0A                %0A                @Override%0A                public String apply(final EncryptColumnRuleConfiguration input) %7B%0A                    return input.getEncryptor();%0A                %7D%0A            %7D);%0A            if (!this.encryptors.keySet().containsAll(encryptors)) %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D
 %0A%7D%0A

add isUsingValidEncryptNames()