Class DbClientBuilderBase<T extends DbClientBuilderBase<T>>

java.lang.Object
io.helidon.dbclient.DbClientBuilderBase<T>
Type Parameters:
T - type of builder subclass
All Implemented Interfaces:
Builder<T,DbClient>, DbClientBuilder<T>, Supplier<DbClient>
Direct Known Subclasses:
JdbcClientBuilder, MongoDbClientBuilder

public abstract class DbClientBuilderBase<T extends DbClientBuilderBase<T>> extends Object implements DbClientBuilder<T>
Base DbClientBuilder implementation.
  • Constructor Details

    • DbClientBuilderBase

      protected DbClientBuilderBase()
      Creates an instance of DbClientBuilderBase.
  • Method Details

    • build

      public DbClient build()
      Description copied from interface: Builder
      Build the instance from this builder.
      Specified by:
      build in interface Builder<T extends DbClientBuilderBase<T>,DbClient>
      Returns:
      instance of the built type
    • doBuild

      protected abstract DbClient doBuild()
      Actual build() implementation for DbClient subclasses.
      Returns:
      new client
    • config

      public T config(Config config)
      Description copied from interface: DbClientBuilder
      Use database connection configuration from configuration file.
      Specified by:
      config in interface DbClientBuilder<T extends DbClientBuilderBase<T>>
      Parameters:
      config - Config instance with database connection attributes
      Returns:
      database provider builder
    • url

      public T url(String url)
      Description copied from interface: DbClientBuilder
      Set database connection string (URL).
      Specified by:
      url in interface DbClientBuilder<T extends DbClientBuilderBase<T>>
      Parameters:
      url - database connection string
      Returns:
      database provider builder
    • username

      public T username(String username)
      Description copied from interface: DbClientBuilder
      Set database connection username.
      Specified by:
      username in interface DbClientBuilder<T extends DbClientBuilderBase<T>>
      Parameters:
      username - database connection user name
      Returns:
      database provider builder
    • password

      public T password(String password)
      Description copied from interface: DbClientBuilder
      Set database connection password.
      Specified by:
      password in interface DbClientBuilder<T extends DbClientBuilderBase<T>>
      Parameters:
      password - database connection password
      Returns:
      database provider builder
    • statements

      public T statements(DbStatements statements)
      Description copied from interface: DbClientBuilder
      Statements to use either from configuration or manually configured.
      Specified by:
      statements in interface DbClientBuilder<T extends DbClientBuilderBase<T>>
      Parameters:
      statements - Statements to use
      Returns:
      updated builder instance
    • addMapper

      public <TYPE> T addMapper(DbMapper<TYPE> dbMapper, Class<TYPE> mappedClass)
      Description copied from interface: DbClientBuilder
      Add a custom mapper.
      Specified by:
      addMapper in interface DbClientBuilder<T extends DbClientBuilderBase<T>>
      Type Parameters:
      TYPE - type of the supported class
      Parameters:
      dbMapper - the mapper capable of mapping the mappedClass to various database objects
      mappedClass - class that this mapper supports
      Returns:
      updated builder instance.
    • addMapper

      public <TYPE> T addMapper(DbMapper<TYPE> dbMapper, GenericType<TYPE> mappedType)
      Description copied from interface: DbClientBuilder
      Add a custom mapper with generic types support.
      Specified by:
      addMapper in interface DbClientBuilder<T extends DbClientBuilderBase<T>>
      Type Parameters:
      TYPE - type of the supported class
      Parameters:
      dbMapper - the mapper capable of mapping the mappedClass to various database objects
      mappedType - type that this mapper supports
      Returns:
      updated builder instance.
    • mapperManager

      public T mapperManager(MapperManager manager)
      Description copied from interface: DbClientBuilder
      Mapper manager for generic mapping, such as mapping of parameters to expected types.
      Specified by:
      mapperManager in interface DbClientBuilder<T extends DbClientBuilderBase<T>>
      Parameters:
      manager - mapper manager
      Returns:
      updated builder instance
    • dbMapperManager

      public T dbMapperManager(DbMapperManager manager)
      Description copied from interface: DbClientBuilder
      Mapper manager of all configured mappers.
      Specified by:
      dbMapperManager in interface DbClientBuilder<T extends DbClientBuilderBase<T>>
      Parameters:
      manager - mapper manager
      Returns:
      updated builder instance
    • addMapperProvider

      public T addMapperProvider(DbMapperProvider provider)
      Description copied from interface: DbClientBuilder
      Database schema mappers provider.
      Specified by:
      addMapperProvider in interface DbClientBuilder<T extends DbClientBuilderBase<T>>
      Parameters:
      provider - database schema mappers provider to use
      Returns:
      updated builder instance
    • addService

      public T addService(DbClientService clientService)
      Description copied from interface: DbClientBuilder
      Add an interceptor. This allows to add implementation of tracing, metrics, logging etc. without the need to hard-code these into the base.
      Specified by:
      addService in interface DbClientBuilder<T extends DbClientBuilderBase<T>>
      Parameters:
      clientService - interceptor instance
      Returns:
      updated builder instance
    • url

      public String url()
      Get database URL.
      Returns:
      database URL
    • username

      public String username()
      Get database user name.
      Returns:
      database user name
    • password

      public String password()
      Get database user password.
      Returns:
      database user password.
    • statements

      public DbStatements statements()
      Get configured statements to be used by database provider.
      Returns:
      statements to be used by database provider
    • clientServices

      public List<DbClientService> clientServices()
      Get configured client services (interceptors). List of services is converted to unmodifiable List.
      Returns:
      client services
    • mapperManager

      public MapperManager mapperManager()
      Get Mapper manager.
      Returns:
      Mapper manager.
    • dbMapperManager

      public DbMapperManager dbMapperManager()
      Get manager of all configured mappers.
      Returns:
      manager of all configured mappers