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
Modifier and TypeFieldDescriptionprivate ColumnDefinition
Thecolumn definition
to be usedprivate String
The name of the column to alterprivate ForeignKeyConstraint
Theforeign key
to be added to the tableprivate SQLColumnOperation
Theoperation
to performprivate String
The name of the table to alterprivate SQLType
Thetype
to be altered -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd()
Sets theoperation
to add a columnbuild()
Builds a newSQLAlterStatement
using the set parametersprivate void
Checks for any errors in the set parameters and throws an exception if any are foundcolumnDef
(ColumnDefinition columnDef) columnName
(String columnName) drop()
Sets theoperation
to drop a columnforeignKey
(ForeignKeyConstraint foreignKey) modify()
Sets theoperation
to modify a columntable()
Set the type to altering a table
-
Field Details
-
type
Thetype
to be altered -
tableName
The name of the table to alter -
operation
Theoperation
to perform -
columnName
The name of the column to alter -
columnDef
Thecolumn definition
to be used -
foreignKey
Theforeign key
to 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:
table
in interfaceSQLAlterStatement.Type
- Returns:
- this, to continue building
-
tableName
- Specified by:
tableName
in interfaceSQLAlterStatement.TableName
- Parameters:
tableName
- The name of the table to alter- Returns:
- this, to continue building
-
add
Sets theoperation
to add a column- Specified by:
add
in interfaceSQLAlterStatement.Operation
- Returns:
- this, to continue building
-
modify
Sets theoperation
to modify a column- Specified by:
modify
in interfaceSQLAlterStatement.Operation
- Returns:
- this, to continue building
-
drop
Sets theoperation
to drop a column- Specified by:
drop
in interfaceSQLAlterStatement.Operation
- Returns:
- this, to continue building
-
columnName
- Specified by:
columnName
in interfaceSQLAlterStatement.ColumnName
- Parameters:
columnName
- The name of the column to alter- Returns:
- this, to continue building
-
foreignKey
- Specified by:
foreignKey
in interfaceSQLAlterStatement.ColumnDefOrForeignKey
- Parameters:
foreignKey
- Theforeign key
to add to the table- Returns:
- this, to continue building
-
columnDef
- Specified by:
columnDef
in interfaceSQLAlterStatement.ColumnDef
- Parameters:
columnDef
- Thecolumn definition
to 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 newSQLAlterStatement
using the set parameters- Specified by:
build
in interfaceSQLAlterStatement.Build
- Returns:
- The newly built
SQLAlterStatement
-