Class ColumnDefinition.ColumnDefinitionBuilder
java.lang.Object
com.github.tadukoo.database.mysql.syntax.ColumnDefinition.ColumnDefinitionBuilder
- All Implemented Interfaces:
ColumnDefinition.AllowDefaultLength
,ColumnDefinition.AllowDefaultLengthLong
,ColumnDefinition.AllowDefaultSize
,ColumnDefinition.ColumnName
,ColumnDefinition.DataType
,ColumnDefinition.FractionalSecondsPrecision
,ColumnDefinition.Length
,ColumnDefinition.Size
,ColumnDefinition.SizeAndDigits
,ColumnDefinition.Values
- Enclosing class:
- ColumnDefinition
public static class ColumnDefinition.ColumnDefinitionBuilder
extends Object
implements ColumnDefinition.ColumnName, ColumnDefinition.DataType, ColumnDefinition.Length, ColumnDefinition.AllowDefaultLength, ColumnDefinition.AllowDefaultLengthLong, ColumnDefinition.Size, ColumnDefinition.AllowDefaultSize, ColumnDefinition.SizeAndDigits, ColumnDefinition.Values, ColumnDefinition.FractionalSecondsPrecision
A builder used to build a
ColumnDefinition
. It takes the following parameters:
Parameter | Description | Required or Default |
---|---|---|
columnName | The name to use for the column | Required |
dataType | The data type of the column |
Required |
size | The length of the column or total number of digits | Required for some data types - otherwise defaults to -1 |
values | The possible values for the column | Required for some data types - otherwise defaults to an empty List |
digits | The number of digits after the decimal | Required for some data types - otherwise defaults to -1 |
fractionalSecondsPrecision | The precision for fractional seconds | Required for some data types - otherwise defaults to -1 |
notNull | Whether this column allows null (false) or not (true) | Defaults to false (allowing null) |
unsigned | Whether this column is unsigned (true) or signed (false) | Defaults to signed (false) |
autoIncrement | Whether to auto-increment the column or not | Defaults to false |
primaryKey | Whether this column is the primary key or not | Defaults to false |
- Version:
- Alpha v.0.3
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
Modifier and TypeFieldDescriptionprivate String
The name to use for the columnprivate SQLDataType
Thedata type
of the columnprivate Integer
The number of digits after the decimalprivate Integer
The precision for fractional secondsprivate Long
The length of the column or total number of digitsThe possible values for the column -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbigint()
Sets the data type toBIGINT
.binary()
Sets the data type toBINARY
.bit()
Sets the data type toBIT
.blob()
Sets the data type toBLOB
.bool()
Sets the data type toBOOL
.Sets the data type toCHAR
.columnName
(String columnName) private ColumnDefinition.Builder
private ColumnDefinition.NumericEnding
date()
Sets the data type toDATE
.datetime()
Sets the data type toDATETIME
.decimal()
Sets the data type toDECIMAL
.Sets to use the default fractional seconds precision for the data typeSets length to the default for the data typeSets size to the default for the data typeSets to use the default size and digits for the data typeSets the data type toDOUBLE
.Sets the data type toENUM
.Sets the data type toFLOAT
.fractionalSecondsPrecision
(int fractionalSecondsPrecision) integer()
Sets the data type toINTEGER
.length
(int length) length
(long length) longblob()
Sets the data type toLONGBLOB
.longtext()
Sets the data type toLONGTEXT
.Sets the data type toMEDIUMBLOB
.Sets the data type toMEDIUMINT
.Sets the data type toMEDIUMTEXT
.set()
Sets the data type toSET
.size
(int size) sizeAndDigits
(int size, int digits) smallint()
Sets the data type toSMALLINT
.text()
Sets the data type toTEXT
.time()
Sets the data type toTIME
.Sets the data type toTIMESTAMP
.tinyblob()
Sets the data type toTINYBLOB
.tinyint()
Sets the data type toTINYINT
.tinytext()
Sets the data type toTINYTEXT
.Sets the data type toVARBINARY
.varchar()
Sets the data type toVARCHAR
.year()
Sets the data type toYEAR
.
-
Field Details
-
columnName
The name to use for the column -
dataType
Thedata type
of the column -
size
The length of the column or total number of digits -
values
The possible values for the column -
digits
The number of digits after the decimal -
fractionalSecondsPrecision
The precision for fractional seconds
-
-
Constructor Details
-
ColumnDefinitionBuilder
private ColumnDefinitionBuilder()Not allowed to instantiate outside ofColumnDefinition
-
-
Method Details
-
columnName
- Specified by:
columnName
in interfaceColumnDefinition.ColumnName
- Parameters:
columnName
- The name to use for the column- Returns:
- this, to continue building
-
character
Sets the data type toCHAR
. Length specifies the column length in characters - can be 0 to 255. Defaults to 1- Specified by:
character
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
varchar
Sets the data type toVARCHAR
. Length specifies the column length in characters - can be 0 to 65,535- Specified by:
varchar
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
binary
Sets the data type toBINARY
. Length specifies the column length in bytes - can be 0 to 255. Defaults to 1- Specified by:
binary
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
varbinary
Sets the data type toVARBINARY
. Length specifies the column length in bytes - can be 0 to 65,535- Specified by:
varbinary
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
tinyblob
Sets the data type toTINYBLOB
.- Specified by:
tinyblob
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
tinytext
Sets the data type toTINYTEXT
.- Specified by:
tinytext
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
text
Sets the data type toTEXT
. If you specify length, MySQL will pick the smallest text type that can fit that many characters.- Specified by:
text
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
blob
Sets the data type toBLOB
. If you specify length, MySQL will pick the smallest blob type that can fit that many bytes.- Specified by:
blob
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
mediumtext
Sets the data type toMEDIUMTEXT
.- Specified by:
mediumtext
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
mediumblob
Sets the data type toMEDIUMBLOB
.- Specified by:
mediumblob
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
longtext
Sets the data type toLONGTEXT
.- Specified by:
longtext
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
longblob
Sets the data type toLONGBLOB
.- Specified by:
longblob
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
enumeration
Sets the data type toENUM
. You can specify up to 65,535 values for it- Specified by:
enumeration
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
set
Sets the data type toSET
. You can specify up to 64 values for it- Specified by:
set
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
bit
Sets the data type toBIT
. Size specifies the length in bits for values - can be 1 to 64, defaults to 1.- Specified by:
bit
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
tinyint
Sets the data type toTINYINT
. Size specifies the maximum display width - can be 1 to 255, defaults to 255.- Specified by:
tinyint
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
bool
Sets the data type toBOOL
.- Specified by:
bool
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
smallint
Sets the data type toSMALLINT
. Size specifies the maximum display width - can be 1 to 255, defaults to 255.- Specified by:
smallint
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
mediumint
Sets the data type toMEDIUMINT
. Size specifies the maximum display width - can be 1 to 255, defaults to 255.- Specified by:
mediumint
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
integer
Sets the data type toINTEGER
. Size specifies the maximum display width - can be 1 to 255, defaults to 255.- Specified by:
integer
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
bigint
Sets the data type toBIGINT
. Size specifies the maximum display width - can be 1 to 255, defaults to 255.- Specified by:
bigint
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
floatType
Sets the data type toFLOAT
. Size specifies the total number of digits and digits is the number of digits after the decimal- Specified by:
floatType
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
doubleType
Sets the data type toDOUBLE
. Size specifies the total number of digits and digits is the number of digits after the decimal- Specified by:
doubleType
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
decimal
Sets the data type toDECIMAL
. Size specifies the total number of digits - can be 1 to 65, defaults to 10. Digits specifies the number of digits after the decimal - can be 0 to 30, defaults to 0.- Specified by:
decimal
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
date
Sets the data type toDATE
.- Specified by:
date
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
datetime
Sets the data type toDATETIME
. Fractional Seconds Precision specifies how many digits after the decimal to use for fractions of a second - can be 0 to 6, defaults to 0- Specified by:
datetime
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
timestamp
Sets the data type toTIMESTAMP
. Fractional Seconds Precision specifies how many digits after the decimal to use for fractions of a second - can be 0 to 6, defaults to 0- Specified by:
timestamp
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
time
Sets the data type toTIME
. Fractional Seconds Precision specifies how many digits after the decimal to use for fractions of a second - can be 0 to 6, defaults to 0- Specified by:
time
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
year
Sets the data type toYEAR
.- Specified by:
year
in interfaceColumnDefinition.DataType
- Returns:
- this, to continue building
-
length
- Specified by:
length
in interfaceColumnDefinition.Length
- Parameters:
length
- The length of the column- Returns:
- this, to continue building
-
defaultLength
Sets length to the default for the data type- Specified by:
defaultLength
in interfaceColumnDefinition.AllowDefaultLength
- Returns:
- this, to continue building
-
length
- Specified by:
length
in interfaceColumnDefinition.AllowDefaultLengthLong
- Parameters:
length
- The length to use for the column- Returns:
- this, to continue building
-
size
- Specified by:
size
in interfaceColumnDefinition.Size
- Parameters:
size
- The length of the column- Returns:
- this, to continue building
-
defaultSize
Sets size to the default for the data type- Specified by:
defaultSize
in interfaceColumnDefinition.AllowDefaultSize
- Returns:
- this, to continue building
-
sizeAndDigits
- Specified by:
sizeAndDigits
in interfaceColumnDefinition.SizeAndDigits
- Parameters:
size
- The total number of digitsdigits
- The number of digits after the decimal- Returns:
- this, to continue building
-
defaultSizeAndDigits
Sets to use the default size and digits for the data type- Specified by:
defaultSizeAndDigits
in interfaceColumnDefinition.SizeAndDigits
- Returns:
- this, to continue building
-
values
- Specified by:
values
in interfaceColumnDefinition.Values
- Parameters:
values
- The possible values for the column- Returns:
- this, to continue building
-
values
- Specified by:
values
in interfaceColumnDefinition.Values
- Parameters:
values
- The possible values for the column- Returns:
- this, to continue building
-
fractionalSecondsPrecision
- Specified by:
fractionalSecondsPrecision
in interfaceColumnDefinition.FractionalSecondsPrecision
- Parameters:
fractionalSecondsPrecision
- The precision for fractional seconds- Returns:
- this, to continue building
-
defaultFractionalSecondsPrecision
Sets to use the default fractional seconds precision for the data type- Specified by:
defaultFractionalSecondsPrecision
in interfaceColumnDefinition.FractionalSecondsPrecision
- Returns:
- this, to continue building
-
createNormalEnding
- Returns:
- A normal ending to continue building this for non-numeric data types
-
createNumericEnding
- Returns:
- A numeric ending to continue building this for numeric data types
-