Package com.ptsmods.mysqlw.table
Class ColumnStructure<C>
java.lang.Object
com.ptsmods.mysqlw.table.ColumnStructure<C>
- Type Parameters:
C
- The type of the configurable used to get the typeString of theColumnType
used to create this structure.
A structure used to describe a column.
Used when making new tables.
Acquire a
Used when making new tables.
Acquire a
ColumnStructure
via ColumnType.struct()
on any of the types in that class.-
Method Summary
Modifier and TypeMethodDescriptionBuilds the type string for the given database type.clone()
Run and return the value of the supplier of the selectedColumnType
.
This must be called if theColumnType
of this structure has no default values set for its supplier.
(This is the case for e.g.getExtra()
Deprecated.getType()
@Nullable String
boolean
boolean
boolean
boolean
isUnique()
readOnly()
Makes this ColumnStructure immutable so it cannot be edited.
Used when describing a table.satiateSupplier
(Function<C, String> configurator) Deprecated.Has been renamed.setAttributes
(@Nullable ColumnAttributes attributes) Sets auto increment to true.setAutoIncrement
(boolean autoIncrement) setComment
(@Nullable String comment) setDefault
(@Nullable ColumnDefault defValue) Sets null allowed to false.Sets null allowed to true.setNullAllowed
(boolean nullAllowed) Sets primary to true.setPrimary
(boolean primary) setTypeString
(String typeString) Basically what configuring does, except you put in raw data.
Don't forget to include the type in here too.
Example: VARCHAR(255)Sets unique to true.setUnique
(boolean unique) toString()
toString
(Database.RDBMS type)
-
Method Details
-
getType
-
setTypeString
Basically what configuring does, except you put in raw data.
Don't forget to include the type in here too.
Example: VARCHAR(255)- Parameters:
typeString
- The new typeString.- Returns:
- This structure
-
getTypeString
- Returns:
- The string set using
configure(Function)
. Will returnnull
unlesssetTypeString(String)
has been called.
-
buildTypeString
Builds the type string for the given database type.- Parameters:
type
-- Returns:
-
satiateSupplier
Deprecated.Has been renamed. Useconfigure(Function)
instead.Run and return the value of the supplier of the selectedColumnType
.THIS MUST BE RAN, UNLESS THE SUPPLIER IS AN INSTANCE OF
Supplier
.- Parameters:
configurator
- The function that gets the supplier and returns its value.- Returns:
- This structure
-
configure
Run and return the value of the supplier of the selectedColumnType
.
This must be called if theColumnType
of this structure has no default values set for its supplier.
(This is the case for e.g.ENUM
,SET
,CHAR
,VARCHAR
)- Parameters:
configurator
- The function that gets the supplier and returns its value.- Returns:
- This structure
-
getSupplier
Deprecated.Suppliers are now type-specific, please usegetTypeSpecificSupplier()
instead.- Returns:
- The supplier that's used to configure this structure.
- See Also:
-
getTypeSpecificSupplier
- Returns:
- The supplier that may return a different output based on the RDBMS it's used for. Used to configure this structure.
-
setUnique
Sets unique to true.- Returns:
- This structure
- See Also:
-
setUnique
- Parameters:
unique
- Whether this column may only contain unique values.- Returns:
- This structure
-
isUnique
public boolean isUnique()- Returns:
- Whether this column may only contain unique values.
-
setPrimary
Sets primary to true.- Returns:
- This structure
- See Also:
-
setPrimary
- Parameters:
primary
- Whether this column is the PRIMARY KEY of its table.- Returns:
- This structure
-
isPrimary
public boolean isPrimary()- Returns:
- Whether this column is the PRIMARY KEY of its table.
-
setDefault
- Parameters:
defValue
- The default value of this column, eitherNULL
,CURRENT_TIMESTAMP
or a custom default value.- Returns:
- This structure
-
getDefValue
- Returns:
- The default value of this column, either
NULL
,CURRENT_TIMESTAMP
or a custom default value.
-
setAttributes
- Parameters:
attributes
- The attributes of the type of this column.- Returns:
- This structure
-
getAttributes
- Returns:
- The attributes of the type of this column.
-
setNullable
Sets null allowed to true.- Returns:
- This structure
- See Also:
-
setNonNull
Sets null allowed to false.- Returns:
- This structure
- See Also:
-
setNullAllowed
- Parameters:
nullAllowed
- Whether this column can contain null values.- Returns:
- This structure
-
isNullAllowed
public boolean isNullAllowed()- Returns:
- Whether this column can contain null values.
-
setAutoIncrement
Sets auto increment to true.- Returns:
- This structure.
- See Also:
-
setAutoIncrement
- Parameters:
autoIncrement
- Whether the value of this column should be incremented by one for each row inserted.- Returns:
- This structure.
-
isAutoIncrement
public boolean isAutoIncrement()- Returns:
- Whether the value of this column should be incremented by one for each row inserted.
-
setComment
- Parameters:
comment
- The comment of this column. Used to describe what it's for.- Returns:
- This structure
-
getComment
- Returns:
- The comment of this column. Used to describe what it's for.
-
setExtra
- Parameters:
extra
- Anything else you could possibly want to add that this class does not cover. It would also be appreciated if you could make a pull request or issue to cover this on the GitHub page.- Returns:
- This structure
-
getExtra
- Returns:
- Anything else you could possibly want to add that this class does not cover.
-
readOnly
Makes this ColumnStructure immutable so it cannot be edited.
Used when describing a table.- Returns:
- This ColumnStructure
-
clone
-
toString
-
toString
-
getTypeSpecificSupplier()
instead.