Class TablePreset

java.lang.Object
com.ptsmods.mysqlw.table.TablePreset

public class TablePreset extends Object
  • Method Details

    • create

      public static TablePreset create(String name)
      Create a new TablePreset with the given name.
      Parameters:
      name - The name of the new TablePreset.
      Returns:
      A new TablePreset with the given name.
    • getName

      public String getName()
    • setName

      public TablePreset setName(String name)
      Changes the name of this TablePreset.
      Parameters:
      name - The new name
      Returns:
      This TablePreset
    • putAll

      public TablePreset putAll(Map<String,ColumnStructure<?>> columns)
      Puts all columns with their names into this TablePreset.
      Parameters:
      columns - The columns to add.
      Returns:
      This TablePreset
    • putColumn

      public TablePreset putColumn(String name, ColumnStructure<?> structure)
      Puts a new column into this TablePreset.
      Parameters:
      name - The name of the new column
      structure - The ColumnStructure of the column
      Returns:
      This TablePreset
    • removeColumn

      public TablePreset removeColumn(String name)
      Removes a column by its name.
      Parameters:
      name - The name of the column to remove.
      Returns:
      This TablePreset
    • addIndex

      public TablePreset addIndex(TableIndex index)
      Adds a TableIndex to this preset.
      Parameters:
      index - The TableIndex to add
      Returns:
      This TablePreset
      See Also:
    • removeIndex

      public TablePreset removeIndex(TableIndex index)
      Removes an index.
      Parameters:
      index - The index to remove.
      Returns:
      This TablePreset
    • addForeignKey

      public TablePreset addForeignKey(ForeignKey foreignKey)
      Add a foreign key to this preset.
      Parameters:
      foreignKey - The foreign key to add
      Returns:
      This TablePreset
      See Also:
    • addForeignKey

      public TablePreset addForeignKey(ForeignKey.Builder foreignKey)
      Add a foreign key to this preset.
      Parameters:
      foreignKey - The foreign key to add
      Returns:
      This TablePreset
      See Also:
    • removeForeignKey

      public TablePreset removeForeignKey(ForeignKey foreignKey)
      Remove a foreign key from this preset.
      Parameters:
      foreignKey - The foreign key to remove
      Returns:
      This TablePreset
    • addCheck

      public TablePreset addCheck(QueryCondition check)
      Adds a new check constraint insertions and updates must comply with to be valid.
      Parameters:
      check - The check constraint to add
      Returns:
      This TablePreset
      See Also:
    • removeCheck

      public TablePreset removeCheck(QueryCondition check)
      Removes a check constraint
      Parameters:
      check - The check constraint to remove
      Returns:
      This TablePreset
    • getColumns

      public Map<String,ColumnStructure<?>> getColumns()
      Returns:
      An immutable copy of the map of columns in this preset
    • getForeignKeys

      public List<ForeignKey> getForeignKeys()
      Returns:
      An immutable copy of the foreign keys added to this preset
    • getChecks

      public List<QueryCondition> getChecks()
      Returns:
      An immutable copy of the checks keys added to this preset
    • build

      public Map<String,String> build(Database.RDBMS type)
      Builds the type strings of all columns and maps them to their name.
      Parameters:
      type - The type to build for
      Returns:
      A map of column name keys and column definition values
    • buildQuery

      public String buildQuery(Database.RDBMS type)
      Builds the query to create a table representing this preset.
      Parameters:
      type - The type to build for
      Returns:
      A built CREATE TABLE query
    • getIndices

      public List<TableIndex> getIndices()
      Returns:
      All indices that were added
    • create

      public TablePreset create(Database db)
      Builds a query and executes it on the given database.
      Parameters:
      db - The database to create this table on
      Returns:
      This TablePreset
      See Also:
    • createAsync

      public CompletableFuture<TablePreset> createAsync(Database db)
      Builds a query and executes it on the given database asynchronously.
      Parameters:
      db - The database to create this table on
      Returns:
      This TablePreset
      See Also:
    • clone

      public TablePreset clone()
      Overrides:
      clone in class Object
      Returns:
      A (deep) copy of this TablePreset