Class LitebridgeBuilder<LB extends LitebridgeCore>

java.lang.Object
org.litebridge.orm.LitebridgeBuilder<LB>
Type Parameters:
LB - The specific subtype of LitebridgeCore this builder will construct based on the database provider.

public final class LitebridgeBuilder<LB extends LitebridgeCore> extends Object
A builder class for constructing Litebridge instances.

The constructed Litebridge instance type depends on the capabilities of the specified database provider. Some database providers may provide a specialised Litebridge implementation that supports additional vendor-specific features, or they may limit the default Litebridge API due to lack of support for features like SQL MERGE INTO operations (in which case a LitebridgeCore instance is returned).

This builder provides a fluent API for configuring dependencies and optional parameters used during the instantiation of the Litebridge instance.

  • Method Details

    • withDataSource

      public LitebridgeBuilder<LB> withDataSource(DataSource dataSource)
      Sets the data source to be used by the Litebridge instance, using the default transaction manager.

      This is not needed if withTransactionManager(TransactionManager) is used.

      Parameters:
      dataSource - the data source to use
      Returns:
      this builder instance for method chaining
    • withTransactionManager

      public LitebridgeBuilder<LB> withTransactionManager(TransactionManager transactionManager)
      Sets the transaction manager to be used by the Litebridge instance.
      Parameters:
      transactionManager - the transaction manager to use
      Returns:
      this builder instance for method chaining
    • withConfig

      public LitebridgeBuilder<LB> withConfig(LitebridgeConfig config)
      Sets the Litebridge configuration to be used by the Litebridge instance.
      Parameters:
      config - the Litebridge configuration to use
      Returns:
      this builder instance for method chaining
    • withLookup

      public LitebridgeBuilder<LB> withLookup(MethodHandles.Lookup lookup)
      Sets the method handle lookup to be used by the Litebridge instance.
      Parameters:
      lookup - the method handle lookup to use
      Returns:
      this builder instance for method chaining
    • build

      public LB build()
      Constructs the Litebridge instance based on the configuration provided to this builder.

      The constructed Litebridge instance type depends on the capabilities of the specified database provider. Some database providers may provide a specialised Litebridge implementation that supports additional vendor-specific features, or they may limit the default Litebridge API due to lack of support for features like SQL MERGE INTO operations (in which case a LitebridgeCore instance is returned).

      Returns:
      the constructed Litebridge instance