// Path: src/main/java/io/vertx/ext/jdbc/JDBCClient.java
// @VertxGen
// public interface JDBCClient extends SQLClient {
// 
//   /**
//    * The default data source provider is C3P0
//    */
//   String DEFAULT_PROVIDER_CLASS =  "io.vertx.ext.jdbc.spi.impl.C3P0DataSourceProvider";
// 
//   /**
//    * The name of the default data source
//    */
//   String DEFAULT_DS_NAME = "DEFAULT_DS";
// 
//   /**
//    * Create a JDBC client which maintains its own data source.
//    *
//    * @param vertx  the Vert.x instance
//    * @param config the configuration
//    * @return the client
//    */
//   static JDBCClient create(Vertx vertx, JsonObject config) {
//     return new JDBCClientImpl(vertx, config, UUID.randomUUID().toString());
//   }
// 
//   /**
//    * Create a JDBC client which shares its data source with any other JDBC clients created with the same
//    * data source name
//    *
//    * @param vertx  the Vert.x instance
//    * @param config  the configuration
//    * @param dataSourceName  the data source name
//    * @return the client
//    */
//   static JDBCClient createShared(Vertx vertx, JsonObject config, String dataSourceName) {
//     return new JDBCClientImpl(vertx, config, dataSourceName);
//   }
// 
//   /**
//    * Like {@link #createShared(io.vertx.core.Vertx, JsonObject, String)} but with the default data source name
//    * @param vertx  the Vert.x instance
//    * @param config  the configuration
//    * @return the client
//    */
//   static JDBCClient createShared(Vertx vertx, JsonObject config) {
//     return new JDBCClientImpl(vertx, config, DEFAULT_DS_NAME);
//   }
// 
//   /**
//    * Create a client using a pre-existing data source
//    *
//    * @param vertx  the Vert.x instance
//    * @param dataSource  the datasource
//    * @return the client
//    */
//   @GenIgnore
//   static JDBCClient create(Vertx vertx, DataSource dataSource) {
//     return new JDBCClientImpl(vertx, dataSource);
//   }
// 
//   /**
//    * Create a client using a data source provider
//    *
//    * @param vertx  the Vert.x instance
//    * @param dataSourceProvider  the datasource provider
//    * @return the client
//    * @since 4.2.0
//    */
//   @GenIgnore
//   static JDBCClient create(Vertx vertx, DataSourceProvider dataSourceProvider) {
//     return new JDBCClientImpl(vertx, dataSourceProvider);
//   }
// 
// }


import java.sql.SQLException;
import java.util.Objects;
import javax.sql.DataSource;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.jdbc.JDBCClient;
/*
 * Copyright (c) 2011-2014 The original author or authors
 * ------------------------------------------------------
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 *
 *     The Eclipse Public License is available at
 *     http://www.eclipse.org/legal/epl-v10.html
 *
 *     The Apache License v2.0 is available at
 *     http://www.opensource.org/licenses/apache2.0.php
 *
 * You may elect to redistribute this code under either of these licenses.
 */

package io.vertx.ext.jdbc.spi;



/**
 * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
 */
public interface DataSourceProvider {

  /**
   * Init provider with specific configuration
   *
   * @param sqlConfig SQL connection configuration
   * @return a reference to this for fluent API
   * @apiNote Use it conjunction with {@link #create(JsonObject)}
   * @since 4.2.0
   */
  default DataSourceProvider init(JsonObject sqlConfig) {
    return this;
  }

  /**
   * Get the SQL initial configuration
   *
   * @return an initial configuration
   * @apiNote Use it conjunction with {@link #init(JsonObject)}
   * @since 4.2.0
   */
  default JsonObject getInitialConfig() {
    return new JsonObject();
  }

  int maximumPoolSize(DataSource dataSource, JsonObject config) throws SQLException;

  DataSource getDataSource(JsonObject config) throws SQLException;

  void close(DataSource dataSource) throws SQLException;

  static DataSourceProvider create(JsonObject config) {
    String providerClass = config.getString("provider_class");
    if (providerClass == null) {
// Path: src/main/java/io/vertx/ext/jdbc/JDBCClient.java
// @VertxGen
// public interface JDBCClient extends SQLClient {
// 
//   /**
//    * The default data source provider is C3P0
//    */
//   String DEFAULT_PROVIDER_CLASS =  "io.vertx.ext.jdbc.spi.impl.C3P0DataSourceProvider";
// 
//   /**
//    * The name of the default data source
//    */
//   String DEFAULT_DS_NAME = "DEFAULT_DS";
// 
//   /**
//    * Create a JDBC client which maintains its own data source.
//    *
//    * @param vertx  the Vert.x instance
//    * @param config the configuration
//    * @return the client
//    */
//   static JDBCClient create(Vertx vertx, JsonObject config) {
//     return new JDBCClientImpl(vertx, config, UUID.randomUUID().toString());
//   }
// 
//   /**
//    * Create a JDBC client which shares its data source with any other JDBC clients created with the same
//    * data source name
//    *
//    * @param vertx  the Vert.x instance
//    * @param config  the configuration
//    * @param dataSourceName  the data source name
//    * @return the client
//    */
//   static JDBCClient createShared(Vertx vertx, JsonObject config, String dataSourceName) {
//     return new JDBCClientImpl(vertx, config, dataSourceName);
//   }
// 
//   /**
//    * Like {@link #createShared(io.vertx.core.Vertx, JsonObject, String)} but with the default data source name
//    * @param vertx  the Vert.x instance
//    * @param config  the configuration
//    * @return the client
//    */
//   static JDBCClient createShared(Vertx vertx, JsonObject config) {
//     return new JDBCClientImpl(vertx, config, DEFAULT_DS_NAME);
//   }
// 
//   /**
//    * Create a client using a pre-existing data source
//    *
//    * @param vertx  the Vert.x instance
//    * @param dataSource  the datasource
//    * @return the client
//    */
//   @GenIgnore
//   static JDBCClient create(Vertx vertx, DataSource dataSource) {
//     return new JDBCClientImpl(vertx, dataSource);
//   }
// 
//   /**
//    * Create a client using a data source provider
//    *
//    * @param vertx  the Vert.x instance
//    * @param dataSourceProvider  the datasource provider
//    * @return the client
//    * @since 4.2.0
//    */
//   @GenIgnore
//   static JDBCClient create(Vertx vertx, DataSourceProvider dataSourceProvider) {
//     return new JDBCClientImpl(vertx, dataSourceProvider);
//   }
// 
// }


// Path: src/main/java/io/vertx/ext/jdbc/spi/DataSourceProvider.java
import java.sql.SQLException;
import java.util.Objects;
import javax.sql.DataSource;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.jdbc.JDBCClient;

/*
 * Copyright (c) 2011-2014 The original author or authors
 * ------------------------------------------------------
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 *
 *     The Eclipse Public License is available at
 *     http://www.eclipse.org/legal/epl-v10.html
 *
 *     The Apache License v2.0 is available at
 *     http://www.opensource.org/licenses/apache2.0.php
 *
 * You may elect to redistribute this code under either of these licenses.
 */

package io.vertx.ext.jdbc.spi;



/**
 * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
 */
public interface DataSourceProvider {

  /**
   * Init provider with specific configuration
   *
   * @param sqlConfig SQL connection configuration
   * @return a reference to this for fluent API
   * @apiNote Use it conjunction with {@link #create(JsonObject)}
   * @since 4.2.0
   */
  default DataSourceProvider init(JsonObject sqlConfig) {
    return this;
  }

  /**
   * Get the SQL initial configuration
   *
   * @return an initial configuration
   * @apiNote Use it conjunction with {@link #init(JsonObject)}
   * @since 4.2.0
   */
  default JsonObject getInitialConfig() {
    return new JsonObject();
  }

  int maximumPoolSize(DataSource dataSource, JsonObject config) throws SQLException;

  DataSource getDataSource(JsonObject config) throws SQLException;

  void close(DataSource dataSource) throws SQLException;

  static DataSourceProvider create(JsonObject config) {
    String providerClass = config.getString("provider_class");
    if (providerClass == null) {
      providerClass = JDBCClient.DEFAULT_PROVIDER_CLASS;