/*
 * 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.infra.config.datasource.jdbc.creator;

import com.google.common.base.Preconditions;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;

import java.util.Optional;

/**
 * JDBC data source creator factory.
 */
public final class JDBCDataSourceCreatorFactory {
    
    static {
        ShardingSphereServiceLoader.register(JDBCDataSourceCreator.class);
    }
    
    /**
     * Get JDBC data source creator instance.
     * 
     * @param type type
     * @return JDBC data source creator instance
     */
    public static JDBCDataSourceCreator getInstance(final String type) {
        Optional<JDBCDataSourceCreator> result = TypedSPIRegistry.findRegisteredService(JDBCDataSourceCreator.class, type, null);
        Preconditions.checkArgument(result.isPresent(), "Unsupported data source type '%s'", type);
        return result.get();
    }
}

@@ -873,53 +873,8 @@
 r;%0A%0A
-import com.google.common.base.Preconditions;%0A
 impo
@@ -935,16 +935,16 @@
 Loader;%0A
+
 import o
@@ -1001,36 +1001,8 @@
 y;%0A%0A
-import java.util.Optional;%0A%0A
 /**%0A
@@ -1277,16 +1277,41 @@
 am type 
+JDBC data source creator 
 type%0A   
@@ -1449,48 +1449,14 @@
     
-Optional%3CJDBCDataSourceCreator%3E result =
+return
  Typ
@@ -1473,12 +1473,11 @@
 try.
-find
+get
 Regi
@@ -1536,137 +1536,8 @@
 l);%0A
-        Preconditions.checkArgument(result.isPresent(), %22Unsupported data source type '%25s'%22, type);%0A        return result.get();%0A
     

Refactor JDBCDataSourceCreatorFactory (#14065)