Class SQLAlterStatement.SQLAlterStatementBuilder
java.lang.Object
com.github.tadukoo.database.mysql.syntax.statement.SQLAlterStatement.SQLAlterStatementBuilder
- All Implemented Interfaces:
SQLAlterStatement.Build,SQLAlterStatement.ColumnDef,SQLAlterStatement.ColumnDefOrForeignKey,SQLAlterStatement.ColumnName,SQLAlterStatement.Operation,SQLAlterStatement.TableName,SQLAlterStatement.Type
- Enclosing class:
- SQLAlterStatement
public static class SQLAlterStatement.SQLAlterStatementBuilder
extends Object
implements SQLAlterStatement.Type, SQLAlterStatement.TableName, SQLAlterStatement.Operation, SQLAlterStatement.ColumnName, SQLAlterStatement.ColumnDefOrForeignKey, SQLAlterStatement.ColumnDef, SQLAlterStatement.Build
A builder to use to build a
SQLAlterStatement. It takes the following parameters:
| Parameter | Description | Default or Required |
|---|---|---|
| type | The type to be altered |
Required |
| tableName | The name of the table to alter | Required |
| operation | The operation to perform |
Required |
| columnName | The name of the column to alter | Either this or columnDef or foreignKey required, depending on operation |
| columnDef | The column definition to be used |
Either this or columnName or foreign key required, depending on operation |
| foreignKey | The foreign key to be added to the table |
Either this or columnName or columnDef required, depending on operation |
- Version:
- Alpha v.0.3
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ColumnDefinitionThecolumn definitionto be usedprivate StringThe name of the column to alterprivate ForeignKeyConstraintTheforeign keyto be added to the tableprivate SQLColumnOperationTheoperationto performprivate StringThe name of the table to alterprivate SQLTypeThetypeto be altered -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd()Sets theoperationto add a columnbuild()Builds a newSQLAlterStatementusing the set parametersprivate voidChecks for any errors in the set parameters and throws an exception if any are foundcolumnDef(ColumnDefinition columnDef) columnName(String columnName) drop()Sets theoperationto drop a columnforeignKey(ForeignKeyConstraint foreignKey) modify()Sets theoperationto modify a columntable()Set the type to altering a table
-
Field Details
-
type
Thetypeto be altered -
tableName
The name of the table to alter -
operation
Theoperationto perform -
columnName
The name of the column to alter -
columnDef
Thecolumn definitionto be used -
foreignKey
Theforeign keyto be added to the table
-
-
Constructor Details
-
SQLAlterStatementBuilder
private SQLAlterStatementBuilder()Not allowed to instantiate outsideSQLAlterStatement
-
-
Method Details
-
table
Set the type to altering a table- Specified by:
tablein interfaceSQLAlterStatement.Type- Returns:
- this, to continue building
-
tableName
- Specified by:
tableNamein interfaceSQLAlterStatement.TableName- Parameters:
tableName- The name of the table to alter- Returns:
- this, to continue building
-
add
Sets theoperationto add a column- Specified by:
addin interfaceSQLAlterStatement.Operation- Returns:
- this, to continue building
-
modify
Sets theoperationto modify a column- Specified by:
modifyin interfaceSQLAlterStatement.Operation- Returns:
- this, to continue building
-
drop
Sets theoperationto drop a column- Specified by:
dropin interfaceSQLAlterStatement.Operation- Returns:
- this, to continue building
-
columnName
- Specified by:
columnNamein interfaceSQLAlterStatement.ColumnName- Parameters:
columnName- The name of the column to alter- Returns:
- this, to continue building
-
foreignKey
- Specified by:
foreignKeyin interfaceSQLAlterStatement.ColumnDefOrForeignKey- Parameters:
foreignKey- Theforeign keyto add to the table- Returns:
- this, to continue building
-
columnDef
- Specified by:
columnDefin interfaceSQLAlterStatement.ColumnDef- Parameters:
columnDef- Thecolumn definitionto be used- Returns:
- this, to continue building
-
checkForErrors
private void checkForErrors()Checks for any errors in the set parameters and throws an exception if any are found -
build
Builds a newSQLAlterStatementusing the set parameters- Specified by:
buildin interfaceSQLAlterStatement.Build- Returns:
- The newly built
SQLAlterStatement
-