/*
 * Copyright 2016-2018 shardingsphere.io.
 * <p>
 * Licensed 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.
 * </p>
 */

package io.shardingsphere.core.keygen;

import io.shardingsphere.core.keygen.generator.KeyGenerator;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
 * Key generator factory.
 * 
 * @author zhangliang
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class KeyGeneratorFactory {
    
    /**
     * Create key generator.
     * 
     * @param keyGeneratorClassName key generator class name
     * @return key generator instance
     */
    public static KeyGenerator newInstance(final String keyGeneratorClassName) {
        try {
            return (KeyGenerator) Class.forName(keyGeneratorClassName).newInstance();
        } catch (final ReflectiveOperationException ex) {
            throw new IllegalArgumentException(String.format("Class %s should have public privilege and no argument constructor", keyGeneratorClassName));
        }
    }
}

@@ -664,59 +664,202 @@
 ort 
-io.shardingsphere.core.keygen.generator.KeyGenerato
+com.google.common.base.Predicate;%0Aimport com.google.common.collect.Collections2;%0Aimport io.shardingsphere.core.keygen.generator.KeyGenerator;%0Aimport io.shardingsphere.spi.NewInstanceServiceLoade
 r;%0Ai
@@ -918,16 +918,47 @@
 uctor;%0A%0A
+import java.util.Collections;%0A%0A
 /**%0A * K
@@ -1175,24 +1175,19 @@
 enerator
-ClassNam
+Typ
 e key ge
@@ -1198,17 +1198,11 @@
 tor 
-class nam
+typ
 e%0A  
@@ -1313,24 +1313,19 @@
 enerator
-ClassNam
+Typ
 e) %7B%0A   
@@ -1650,10 +1650,405 @@
 %7D%0A    %7D%0A
+    %0A    private static boolean isValid(final String keyGeneratorType) %7B%0A        return !Collections2.filter(NewInstanceServiceLoader.load(KeyGenerator.class), new Predicate%3CKeyGenerator%3E() %7B%0A            %0A            @Override%0A            public boolean apply(final KeyGenerator input) %7B%0A                return keyGeneratorType.equals(input.getType());%0A            %7D%0A        %7D).isEmpty();%0A    %7D%0A
 %7D%0A

add isValid()