Package com.ptsmods.mysqlw.table
Class TablePreset
java.lang.Object
com.ptsmods.mysqlw.table.TablePreset
-
Method Summary
Modifier and TypeMethodDescriptionaddCheck
(QueryCondition check) Adds a new check constraint insertions and updates must comply with to be valid.addForeignKey
(ForeignKey foreignKey) Add a foreign key to this preset.addForeignKey
(ForeignKey.Builder foreignKey) Add a foreign key to this preset.addIndex
(TableIndex index) Adds aTableIndex
to this preset.build
(Database.RDBMS type) Builds the type strings of all columns and maps them to their name.buildQuery
(Database.RDBMS type) Builds the query to create a table representing this preset.clone()
Builds a query and executes it on the given database.static TablePreset
Create a new TablePreset with the given name.createAsync
(Database db) Builds a query and executes it on the given database asynchronously.Map<String,
ColumnStructure<?>> getName()
putAll
(Map<String, ColumnStructure<?>> columns) Puts all columns with their names into this TablePreset.putColumn
(String name, ColumnStructure<?> structure) Puts a new column into this TablePreset.removeCheck
(QueryCondition check) Removes a check constraintremoveColumn
(String name) Removes a column by its name.removeForeignKey
(ForeignKey foreignKey) Remove a foreign key from this preset.removeIndex
(TableIndex index) Removes an index.Changes the name of this TablePreset.
-
Method Details
-
create
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
-
setName
Changes the name of this TablePreset.- Parameters:
name
- The new name- Returns:
- This TablePreset
-
putAll
Puts all columns with their names into this TablePreset.- Parameters:
columns
- The columns to add.- Returns:
- This TablePreset
-
putColumn
Puts a new column into this TablePreset.- Parameters:
name
- The name of the new columnstructure
- TheColumnStructure
of the column- Returns:
- This TablePreset
-
removeColumn
Removes a column by its name.- Parameters:
name
- The name of the column to remove.- Returns:
- This TablePreset
-
addIndex
Adds aTableIndex
to this preset.- Parameters:
index
- TheTableIndex
to add- Returns:
- This TablePreset
- See Also:
-
removeIndex
Removes an index.- Parameters:
index
- The index to remove.- Returns:
- This TablePreset
-
addForeignKey
Add a foreign key to this preset.- Parameters:
foreignKey
- The foreign key to add- Returns:
- This TablePreset
- See Also:
-
addForeignKey
Add a foreign key to this preset.- Parameters:
foreignKey
- The foreign key to add- Returns:
- This TablePreset
- See Also:
-
removeForeignKey
Remove a foreign key from this preset.- Parameters:
foreignKey
- The foreign key to remove- Returns:
- This TablePreset
-
addCheck
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
Removes a check constraint- Parameters:
check
- The check constraint to remove- Returns:
- This TablePreset
-
getColumns
- Returns:
- An immutable copy of the map of columns in this preset
-
getForeignKeys
- Returns:
- An immutable copy of the foreign keys added to this preset
-
getChecks
- Returns:
- An immutable copy of the checks keys added to this preset
-
build
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
Builds the query to create a table representing this preset.- Parameters:
type
- The type to build for- Returns:
- A built CREATE TABLE query
-
getIndices
- Returns:
- All indices that were added
-
create
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
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
-