Class ForeignKeyConstraint.ForeignKeyConstraintBuilder
java.lang.Object
com.github.tadukoo.database.mysql.syntax.ForeignKeyConstraint.ForeignKeyConstraintBuilder
- All Implemented Interfaces:
ForeignKeyConstraint.ColumnNames
,ForeignKeyConstraint.OptionsOrBuild
,ForeignKeyConstraint.ReferenceColumnNames
,ForeignKeyConstraint.ReferenceTable
- Enclosing class:
- ForeignKeyConstraint
public static class ForeignKeyConstraint.ForeignKeyConstraintBuilder
extends Object
implements ForeignKeyConstraint.ColumnNames, ForeignKeyConstraint.ReferenceTable, ForeignKeyConstraint.ReferenceColumnNames, ForeignKeyConstraint.OptionsOrBuild
A builder to use to make a
ForeignKeyConstraint
. It takes the following parameters:
Parameter | Description | Default or Required |
---|---|---|
columnNames | The names of the columns for the foreign key | Required |
referenceTable | The name of the reference table for the foreign key | Required |
referenceColumnNames | The names of the columns from the reference table | Required |
onDeleteOption | The reference option for on delete |
Defaults to null |
onUpdateOption | The reference option for on update |
Defaults to null |
- Version:
- Alpha v.0.3
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
Modifier and TypeFieldDescriptionThe names of the columns for the foreign keyprivate SQLReferenceOption
Thereference option
for on deleteprivate SQLReferenceOption
Thereference option
for on updateThe names of the columns from the reference tableprivate String
The name of the reference table for the foreign key -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a newForeignKeyConstraint
using the set parametersprivate void
Checks for any errors in the set parameters and will throw an error if any are foundcolumnDefs
(ColumnDefinition... columnDefs) columnDefs
(List<ColumnDefinition> columnDefs) columnNames
(String... columnNames) columnNames
(List<String> columnNames) columnRefs
(ColumnRef... columnRefs) columnRefs
(List<ColumnRef> columnRefs) onDelete
(SQLReferenceOption onDeleteOption) onUpdate
(SQLReferenceOption onUpdateOption) referenceColumnDefs
(ColumnDefinition... referenceColumnDefs) referenceColumnDefs
(List<ColumnDefinition> referenceColumnDefs) referenceColumnNames
(String... referenceColumnNames) referenceColumnNames
(List<String> referenceColumnNames) referenceColumnRefs
(ColumnRef... referenceColumnRefs) referenceColumnRefs
(List<ColumnRef> referenceColumnRefs) references
(TableRef referenceTable) references
(String referenceTable)
-
Field Details
-
columnNames
The names of the columns for the foreign key -
referenceTable
The name of the reference table for the foreign key -
referenceColumnNames
The names of the columns from the reference table -
onDeleteOption
Thereference option
for on delete -
onUpdateOption
Thereference option
for on update
-
-
Constructor Details
-
ForeignKeyConstraintBuilder
private ForeignKeyConstraintBuilder()Not allowed to instantiate outside ofForeignKeyConstraint
-
-
Method Details
-
columnNames
- Specified by:
columnNames
in interfaceForeignKeyConstraint.ColumnNames
- Parameters:
columnNames
- The names of the columns for the foreign key- Returns:
- this, to continue building
-
columnNames
- Specified by:
columnNames
in interfaceForeignKeyConstraint.ColumnNames
- Parameters:
columnNames
- The names of the columns for the foreign key- Returns:
- this, to continue building
-
columnRefs
- Specified by:
columnRefs
in interfaceForeignKeyConstraint.ColumnNames
- Parameters:
columnRefs
- The columns for the foreign key asColumnRefs
- Returns:
- this, to continue building
-
columnRefs
- Specified by:
columnRefs
in interfaceForeignKeyConstraint.ColumnNames
- Parameters:
columnRefs
- The columns for the foreign key asColumnRefs
- Returns:
- this, to continue building
-
columnDefs
- Specified by:
columnDefs
in interfaceForeignKeyConstraint.ColumnNames
- Parameters:
columnDefs
- The columns for the foreign key asColumnDefinitions
- Returns:
- this, to continue building
-
columnDefs
- Specified by:
columnDefs
in interfaceForeignKeyConstraint.ColumnNames
- Parameters:
columnDefs
- The columns for the foreign key asColumnDefinitions
- Returns:
- this, to continue building
-
references
- Specified by:
references
in interfaceForeignKeyConstraint.ReferenceTable
- Parameters:
referenceTable
- The name of the reference table for the foreign key- Returns:
- this, to continue building
-
references
- Specified by:
references
in interfaceForeignKeyConstraint.ReferenceTable
- Parameters:
referenceTable
- The reference table for the foreign key as aTableRef
- Returns:
- this, to continue building
-
referenceColumnNames
- Specified by:
referenceColumnNames
in interfaceForeignKeyConstraint.ReferenceColumnNames
- Parameters:
referenceColumnNames
- The names of the columns from the reference table- Returns:
- this, to continue building
-
referenceColumnNames
- Specified by:
referenceColumnNames
in interfaceForeignKeyConstraint.ReferenceColumnNames
- Parameters:
referenceColumnNames
- The names of the columns from the reference table- Returns:
- this, to continue building
-
referenceColumnRefs
- Specified by:
referenceColumnRefs
in interfaceForeignKeyConstraint.ReferenceColumnNames
- Parameters:
referenceColumnRefs
- The columns from the reference table asColumnRefs
- Returns:
- this, to continue building
-
referenceColumnRefs
- Specified by:
referenceColumnRefs
in interfaceForeignKeyConstraint.ReferenceColumnNames
- Parameters:
referenceColumnRefs
- The columns from the reference table asColumnRefs
- Returns:
- this, to continue building
-
referenceColumnDefs
public ForeignKeyConstraint.OptionsOrBuild referenceColumnDefs(ColumnDefinition... referenceColumnDefs) - Specified by:
referenceColumnDefs
in interfaceForeignKeyConstraint.ReferenceColumnNames
- Parameters:
referenceColumnDefs
- The columns from the reference table asColumnDefinitions
- Returns:
- this, to continue building
-
referenceColumnDefs
public ForeignKeyConstraint.OptionsOrBuild referenceColumnDefs(List<ColumnDefinition> referenceColumnDefs) - Specified by:
referenceColumnDefs
in interfaceForeignKeyConstraint.ReferenceColumnNames
- Parameters:
referenceColumnDefs
- The columns from the reference table asColumnDefinitions
- Returns:
- this, to continue building
-
onDelete
- Specified by:
onDelete
in interfaceForeignKeyConstraint.OptionsOrBuild
- Parameters:
onDeleteOption
- Thereference option
for on delete- Returns:
- this, to continue building
-
onUpdate
- Specified by:
onUpdate
in interfaceForeignKeyConstraint.OptionsOrBuild
- Parameters:
onUpdateOption
- Thereference option
for on update- Returns:
- this, to continue building
-
checkForErrors
private void checkForErrors()Checks for any errors in the set parameters and will throw an error if any are found -
build
Builds a newForeignKeyConstraint
using the set parameters- Specified by:
build
in interfaceForeignKeyConstraint.OptionsOrBuild
- Returns:
- The newly built
ForeignKeyConstraint
-