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
FieldsModifier and TypeFieldDescriptionprivate StringThe name to use for the columnprivate SQLDataTypeThedata typeof the columnprivate IntegerThe number of digits after the decimalprivate IntegerThe precision for fractional secondsprivate LongThe length of the column or total number of digitsThe possible values for the column -
Constructor Summary
Constructors -
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.Builderprivate ColumnDefinition.NumericEndingdate()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 typeof 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:
columnNamein 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:
characterin 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:
varcharin 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:
binaryin 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:
varbinaryin interfaceColumnDefinition.DataType- Returns:
- this, to continue building
-
tinyblob
Sets the data type toTINYBLOB.- Specified by:
tinyblobin interfaceColumnDefinition.DataType- Returns:
- this, to continue building
-
tinytext
Sets the data type toTINYTEXT.- Specified by:
tinytextin 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:
textin 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:
blobin interfaceColumnDefinition.DataType- Returns:
- this, to continue building
-
mediumtext
Sets the data type toMEDIUMTEXT.- Specified by:
mediumtextin interfaceColumnDefinition.DataType- Returns:
- this, to continue building
-
mediumblob
Sets the data type toMEDIUMBLOB.- Specified by:
mediumblobin interfaceColumnDefinition.DataType- Returns:
- this, to continue building
-
longtext
Sets the data type toLONGTEXT.- Specified by:
longtextin interfaceColumnDefinition.DataType- Returns:
- this, to continue building
-
longblob
Sets the data type toLONGBLOB.- Specified by:
longblobin 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:
enumerationin interfaceColumnDefinition.DataType- Returns:
- this, to continue building
-
set
Sets the data type toSET. You can specify up to 64 values for it- Specified by:
setin 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:
bitin 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:
tinyintin interfaceColumnDefinition.DataType- Returns:
- this, to continue building
-
bool
Sets the data type toBOOL.- Specified by:
boolin 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:
smallintin 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:
mediumintin 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:
integerin 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:
bigintin 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:
floatTypein 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:
doubleTypein 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:
decimalin interfaceColumnDefinition.DataType- Returns:
- this, to continue building
-
date
Sets the data type toDATE.- Specified by:
datein 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:
datetimein 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:
timestampin 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:
timein interfaceColumnDefinition.DataType- Returns:
- this, to continue building
-
year
Sets the data type toYEAR.- Specified by:
yearin interfaceColumnDefinition.DataType- Returns:
- this, to continue building
-
length
- Specified by:
lengthin 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:
defaultLengthin interfaceColumnDefinition.AllowDefaultLength- Returns:
- this, to continue building
-
length
- Specified by:
lengthin interfaceColumnDefinition.AllowDefaultLengthLong- Parameters:
length- The length to use for the column- Returns:
- this, to continue building
-
size
- Specified by:
sizein 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:
defaultSizein interfaceColumnDefinition.AllowDefaultSize- Returns:
- this, to continue building
-
sizeAndDigits
- Specified by:
sizeAndDigitsin 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:
defaultSizeAndDigitsin interfaceColumnDefinition.SizeAndDigits- Returns:
- this, to continue building
-
values
- Specified by:
valuesin interfaceColumnDefinition.Values- Parameters:
values- The possible values for the column- Returns:
- this, to continue building
-
values
- Specified by:
valuesin interfaceColumnDefinition.Values- Parameters:
values- The possible values for the column- Returns:
- this, to continue building
-
fractionalSecondsPrecision
- Specified by:
fractionalSecondsPrecisionin 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:
defaultFractionalSecondsPrecisionin 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
-