Class RegistrationContext

java.lang.Object
org.litebridgedb.orm.api.register.RegistrationContext

public final class RegistrationContext extends Object
Registration context for associating a Data Transfer Object (DTO) class with database-related functionality and specifications.

This class is the first step to configure mappings between a DTO and database tables, and to register additional interfaces that the DTO may implement.

It serves as a builder-like structure for progressively defining the registration configuration.

  • Constructor Details

    • RegistrationContext

      public RegistrationContext(Class<?> dtoClass, DatabaseProvider databaseProvider)
  • Method Details

    • allowInterface

      public RegistrationContext allowInterface(Class<?> dtoInterface)
      Specifies an additional superinterface of the DTO class that will be recognised by Litebridge relational mapping if used in collections.

      For example, if the DTO class is defined as class MyDto implements MyInterface, then allowInterface(MyInterface.class) should be called to ensure that Litebridge can correctly handle collections of MyInterface instances in related DTOs.

      Parameters:
      dtoInterface - The additional superinterface to allow
      Returns:
      This registration context for method chaining
    • mapToTable

      public RegistrationContextTerminal mapToTable(String tableName)
      Maps a Data Transfer Object (DTO) class to a specified database table. This method initiates the final stage of the registration process by associating the DTO class with the given table name and any provided DTO interfaces.

      Following this, the table mapping is complete and the builder proceeds to field/column mappings.

      Parameters:
      tableName - The name of the table in the database to which the DTO class should be mapped.
      Returns:
      A RegistrationContextTerminal instance to finalize the mapping configuration.