/*
 * 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 com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.Collections2;
import lombok.Getter;

import java.util.Collection;
import java.util.Map;

/**
 * Encrypt rule configuration.
 *
 * @author panjuan
 */
@Getter
public final class EncryptRuleConfigurationBak {
    
    private final Map<String, EncryptorRuleConfigurationBak> encryptors;
    
    private final Map<String, EncryptTableRuleConfiguration> tables;
    
    public EncryptRuleConfigurationBak(final Map<String, EncryptorRuleConfigurationBak> encryptors, final Map<String, EncryptTableRuleConfiguration> tables) {
        this.encryptors = encryptors;
        this.tables = tables;
        Preconditions.checkArgument(isUsingValidEncryptNames(), "Invalid encryptorNames are used in EncryptTableRuleConfigurations.");
    }
    
    private boolean isUsingValidEncryptNames() {
        for (EncryptTableRuleConfiguration each : tables.values()) {
            Collection<String> encryptors = Collections2.transform(each.getColumns().values(), new Function<EncryptColumnRuleConfiguration, String>() {
                
                @Override
                public String apply(final EncryptColumnRuleConfiguration input) {
                    return input.getEncryptor();
                }
            });
            if (!this.encryptors.keySet().containsAll(encryptors)) {
                return false;
            }
        }
        return true;
    }
}

@@ -1031,24 +1031,56 @@
 Collection;%0A
+import java.util.LinkedHashMap;%0A
 import java.
@@ -1089,16 +1089,16 @@
 il.Map;%0A
-
 %0A/**%0A * 
@@ -1361,24 +1361,212 @@
 ables;%0A    %0A
+    public EncryptRuleConfigurationBak() %7B%0A        this(new LinkedHashMap%3CString, EncryptorRuleConfigurationBak%3E(), new LinkedHashMap%3CString, EncryptTableRuleConfiguration%3E());%0A    %7D%0A    %0A
     public E
@@ -1818,37 +1818,34 @@
 ument(is
-UsingValidEncryptName
+ValidConfiguration
 s(), %22In
@@ -1919,24 +1919,170 @@
 %0A    %7D%0A    %0A
+    private boolean isValidConfigurations() %7B%0A        return (encryptors.isEmpty() && tables.isEmpty()) %7C%7C isUsingValidEncryptNames();%0A    %7D%0A    %0A
     private 

add isValidConfigurations()