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
Modifier and TypeFieldDescriptionprivate List<ColumnDefinition>
Thecolumns
to create in the tableprivate final List<ForeignKeyConstraint>
Theforeign keys
to add to the tableprivate boolean
Whether to include IF NOT EXISTS or notprivate String
The name of the table/database to be createdprivate SQLSelectStatement
Theselect statement
to use to grab another tableprivate SQLType
Thetype
to be created -
Constructor Summary
ModifierConstructorDescriptionprivate
Not allowed to instantiate outside of SQLCreateDatabaseStatement -
Method Summary
Modifier and TypeMethodDescriptionas
(SQLSelectStatement selectStmt) Create the table using another tablebuild()
Constructs a newSQLCreateStatement
using the set parametersprivate void
Checks 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 statementSetsifNotExists
to trueSet to add ifNotExists to the create statementtable()
We'll be creating a table
-
Field Details
-
type
Thetype
to 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 statement
to use to grab another table -
columns
Thecolumns
to create in the table -
foreignKeys
Theforeign keys
to 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:
table
in interfaceSQLCreateStatement.Type
- Returns:
- this, to continue building
-
database
We'll be creating a database- Specified by:
database
in interfaceSQLCreateStatement.Type
- Returns:
- this, to continue building
-
ifNotExists
SetsifNotExists
to true- Returns:
- this, to continue building
-
ifTableNotExists
Set to add ifNotExists to the create statement- Specified by:
ifTableNotExists
in interfaceSQLCreateStatement.ExistsOrTableName
- Returns:
- this, to continue building
-
ifDatabaseNotExists
Set to add ifNotExists to the create statement- Specified by:
ifDatabaseNotExists
in interfaceSQLCreateStatement.ExistsOrDatabaseName
- Returns:
- this, to continue building
-
tableName
- Specified by:
tableName
in 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:
as
in interfaceSQLCreateStatement.AsOrColumns
- Parameters:
selectStmt
- Theselect statement
to use to grab another table- Returns:
- this, to continue building
-
columns
- Specified by:
columns
in interfaceSQLCreateStatement.AsOrColumns
- Parameters:
columns
- Thecolumns
to create in the table- Returns:
- this, to continue building
-
columns
- Specified by:
columns
in interfaceSQLCreateStatement.AsOrColumns
- Parameters:
columns
- Thecolumns
to create in the table- Returns:
- this, to continue building
-
foreignKey
- Specified by:
foreignKey
in interfaceSQLCreateStatement.ForeignKeysOrBuild
- Parameters:
foreignKey
- Aforeign key
to add to the table- Returns:
- this, to continue building
-
databaseName
- Specified by:
databaseName
in 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 newSQLCreateStatement
using the set parameters- Specified by:
build
in interfaceSQLCreateStatement.Build
- Returns:
- The newly built
SQLCreateStatement
-