Class SchemaBuilder

java.lang.Object
com.valqueries.automapper.context.schema.SchemaBuilder
All Implemented Interfaces:
ISchemaBuilder, AutoCloseable

public class SchemaBuilder extends Object implements ISchemaBuilder
  • Constructor Details

    • SchemaBuilder

      public SchemaBuilder(Database database)
  • Method Details

    • create

      @CheckReturnValue public ICreateTableBuilder create(Token table)
      Description copied from interface: ISchemaBuilder
      Create a new table. Will fail if a table with the same name already exists.

      Note: remember to call IBaseBuilder.execute()

      Specified by:
      create in interface ISchemaBuilder
      Parameters:
      table - that will be created.
      Returns:
      a builder that can be used to build the new table.
    • createIfNotExists

      @CheckReturnValue public ICreateTableBuilder createIfNotExists(Token table)
      Description copied from interface: ISchemaBuilder
      Create a new table if it does not already exist. Does nothing if a table with the same name already exists, no matter its contents.

      Note: remember to call IBaseBuilder.execute()

      Specified by:
      createIfNotExists in interface ISchemaBuilder
      Parameters:
      table - that will be created if not already.
      Returns:
      a builder that can be used to build the new table.
    • alter

      @CheckReturnValue public IAlterTableBuilder alter(Token table)
      Description copied from interface: ISchemaBuilder
      Alter an existing table.

      Note: remember to call IBaseBuilder.execute()

      Specified by:
      alter in interface ISchemaBuilder
      Parameters:
      table - that will be altered.
      Returns:
      a builder that can be used to alter the table.
    • alterIfExists

      @CheckReturnValue public IAlterTableBuilder alterIfExists(Token table)
      Description copied from interface: ISchemaBuilder
      Alter an existing table if it exists.

      Note: remember to call IBaseBuilder.execute()

      Specified by:
      alterIfExists in interface ISchemaBuilder
      Parameters:
      table - that will be altered if it exists.
      Returns:
      a builder that can be used to alter the table.
    • drop

      public void drop(Token table)
      Description copied from interface: ISchemaBuilder
      Drop an existing table.
      Specified by:
      drop in interface ISchemaBuilder
      Parameters:
      table - that will be dropped.
    • dropIfExists

      public void dropIfExists(Token table)
      Description copied from interface: ISchemaBuilder
      Drop an existing table if it exists.
      Specified by:
      dropIfExists in interface ISchemaBuilder
      Parameters:
      table - that will be dropped.
    • exists

      @CheckReturnValue public boolean exists(Token table)
      Description copied from interface: ISchemaBuilder
      Check if a table exists.
      Specified by:
      exists in interface ISchemaBuilder
      Parameters:
      table - to be checked
      Returns:
      true if the table exists, false otherwise
    • columnExists

      @CheckReturnValue public boolean columnExists(Token table, Token column)
      Description copied from interface: ISchemaBuilder
      Check if a column exists.
      Specified by:
      columnExists in interface ISchemaBuilder
      Parameters:
      table - the table to check in
      column - the column to be checked
      Returns:
      true if the column exists, false otherwise
    • createDatabaseAndUser

      public void createDatabaseAndUser(String databaseName, String username, String password)
      Description copied from interface: ISchemaBuilder
      Creates a new database and user. The user will be granted all privileges on the database.
      Specified by:
      createDatabaseAndUser in interface ISchemaBuilder
      Parameters:
      databaseName - The name of the database to create
      username - The name of the user to create
      password - The password of the user to create
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface ISchemaBuilder