Class SQLCreateStatement.SQLCreateStatementBuilder
java.lang.Object
com.github.tadukoo.database.mysql.syntax.statement.SQLCreateStatement.SQLCreateStatementBuilder
- All Implemented Interfaces:
SQLCreateStatement.AsOrColumns,SQLCreateStatement.Build,SQLCreateStatement.DatabaseName,SQLCreateStatement.ExistsOrDatabaseName,SQLCreateStatement.ExistsOrTableName,SQLCreateStatement.ForeignKeysOrBuild,SQLCreateStatement.TableName,SQLCreateStatement.Type
- Enclosing class:
- SQLCreateStatement
public static class SQLCreateStatement.SQLCreateStatementBuilder
extends Object
implements SQLCreateStatement.Type, SQLCreateStatement.ExistsOrTableName, SQLCreateStatement.TableName, SQLCreateStatement.AsOrColumns, SQLCreateStatement.ExistsOrDatabaseName, SQLCreateStatement.DatabaseName, SQLCreateStatement.ForeignKeysOrBuild, SQLCreateStatement.Build
A builder to create a
SQLCreateStatement. It takes the following parameters:
| Parameter | Description | Required or Default |
|---|---|---|
| type | The type to be created |
Required |
| ifNotExists | Whether to include IF NOT EXISTS in the statement or not | Defaults to false |
| name | The name of the table/database to be created | Required |
| selectStmt | The select statement to use to grab another table |
Requires either this or columns |
| columns | The columns to create in the table |
Requires either this or selectStmt |
| foreignKeys | The foreign keys to add to the table |
Defaults to an empty list |
- Version:
- Alpha v.0.3
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<ColumnDefinition>Thecolumnsto create in the tableprivate final List<ForeignKeyConstraint>Theforeign keysto add to the tableprivate booleanWhether to include IF NOT EXISTS or notprivate StringThe name of the table/database to be createdprivate SQLSelectStatementTheselect statementto use to grab another tableprivate SQLTypeThetypeto be created -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateNot allowed to instantiate outside of SQLCreateDatabaseStatement -
Method Summary
Modifier and TypeMethodDescriptionas(SQLSelectStatement selectStmt) Create the table using another tablebuild()Constructs a newSQLCreateStatementusing the set parametersprivate voidChecks for any errors and throws an IllegalArgumentException if any errors are foundcolumns(ColumnDefinition... columns) columns(List<ColumnDefinition> columns) database()We'll be creating a databasedatabaseName(String databaseName) foreignKey(ForeignKeyConstraint foreignKey) Set to add ifNotExists to the create statementSetsifNotExiststo trueSet to add ifNotExists to the create statementtable()We'll be creating a table
-
Field Details
-
type
Thetypeto be created -
ifNotExists
private boolean ifNotExistsWhether to include IF NOT EXISTS or not -
name
The name of the table/database to be created -
selectStmt
Theselect statementto use to grab another table -
columns
Thecolumnsto create in the table -
foreignKeys
Theforeign keysto add to the table
-
-
Constructor Details
-
SQLCreateStatementBuilder
private SQLCreateStatementBuilder()Not allowed to instantiate outside of SQLCreateDatabaseStatement
-
-
Method Details
-
table
We'll be creating a table- Specified by:
tablein interfaceSQLCreateStatement.Type- Returns:
- this, to continue building
-
database
We'll be creating a database- Specified by:
databasein interfaceSQLCreateStatement.Type- Returns:
- this, to continue building
-
ifNotExists
SetsifNotExiststo true- Returns:
- this, to continue building
-
ifTableNotExists
Set to add ifNotExists to the create statement- Specified by:
ifTableNotExistsin interfaceSQLCreateStatement.ExistsOrTableName- Returns:
- this, to continue building
-
ifDatabaseNotExists
Set to add ifNotExists to the create statement- Specified by:
ifDatabaseNotExistsin interfaceSQLCreateStatement.ExistsOrDatabaseName- Returns:
- this, to continue building
-
tableName
- Specified by:
tableNamein interfaceSQLCreateStatement.TableName- Parameters:
tableName- The name of the table to be created- Returns:
- this, to continue building
-
as
Create the table using another table- Specified by:
asin interfaceSQLCreateStatement.AsOrColumns- Parameters:
selectStmt- Theselect statementto use to grab another table- Returns:
- this, to continue building
-
columns
- Specified by:
columnsin interfaceSQLCreateStatement.AsOrColumns- Parameters:
columns- Thecolumnsto create in the table- Returns:
- this, to continue building
-
columns
- Specified by:
columnsin interfaceSQLCreateStatement.AsOrColumns- Parameters:
columns- Thecolumnsto create in the table- Returns:
- this, to continue building
-
foreignKey
- Specified by:
foreignKeyin interfaceSQLCreateStatement.ForeignKeysOrBuild- Parameters:
foreignKey- Aforeign keyto add to the table- Returns:
- this, to continue building
-
databaseName
- Specified by:
databaseNamein interfaceSQLCreateStatement.DatabaseName- Parameters:
databaseName- The name of the database to be created- Returns:
- this, to continue building
-
checkForErrors
private void checkForErrors()Checks for any errors and throws an IllegalArgumentException if any errors are found -
build
Constructs a newSQLCreateStatementusing the set parameters- Specified by:
buildin interfaceSQLCreateStatement.Build- Returns:
- The newly built
SQLCreateStatement
-