Package liquibase.change
Class ColumnConfig
java.lang.Object
liquibase.serializer.AbstractLiquibaseSerializable
liquibase.change.ColumnConfig
- All Implemented Interfaces:
LiquibaseSerializable
- Direct Known Subclasses:
AddColumnConfig
,LoadDataColumnConfig
The standard configuration used by Change classes to represent a column.
It is not required that a column-based Change uses this class, but parsers should look for it so it is a helpful
convenience. The definitions of "defaultValue" and "value" will vary based on the Change and may not be applicable
in all cases.
-
Nested Class Summary
Nested classes/interfaces inherited from interface liquibase.serializer.LiquibaseSerializable
LiquibaseSerializable.SerializationType
-
Field Summary
Fields inherited from interface liquibase.serializer.LiquibaseSerializable
GENERIC_CHANGELOG_EXTENSION_NAMESPACE, GENERIC_SNAPSHOT_EXTENSION_NAMESPACE, STANDARD_CHANGELOG_NAMESPACE, STANDARD_SNAPSHOT_NAMESPACE
-
Constructor Summary
ConstructorDescriptionCreate am empty ColumnConfig object.ColumnConfig
(Column columnSnapshot) Create a ColumnConfig object based on aColumn
snapshot. -
Method Summary
Modifier and TypeMethodDescriptionstatic ColumnConfig[]
arrayFromNames
(String names) static ColumnConfig
Returns the ConstraintsConfig this ColumnConfig is using.The String default value to assign to this column.Return the boolean value this column should default to.Return the function whose value should generate this column's default.Return the date value this column should default to.Return the numeric value this column should default to.Return the value to set this column's default to according to the setDefaultValue* function that was called.Return encoding of a file, referenced viavalueClobFile
.Return the amount to auto increment by.getName()
The name of the column.Return the remarks to apply to this column.getSerializableFieldType
(String field) getSerializableFieldValue
(String field) Return the number to start auto incrementing with.getType()
The data type fof the column.getValue()
The String value to set this column to.Return the file containing the data to load into a BLOB.Return the boolean value this column should be set to.Return the file containing the data to load into a CLOB.Return the function this column should be set from.Return the date value this column should be set to.Return the numeric value this column should be set to.Return the value from whatever setValue* function was called.boolean
Returns true if any of the setDefaultValue* functions have had a non-null value setReturns true if this Column should be set to be auto increment.void
load
(ParsedNode parsedNode, ResourceAccessor resourceAccessor) protected void
loadConstraints
(ParsedNode constraintsNode) setAutoIncrement
(Boolean autoIncrement) setComputed
(Boolean computed) setConstraints
(ConstraintsConfig constraints) setDefaultOnNull
(Boolean defaultOnNull) setDefaultValue
(String defaultValue) Sets the string default value to assign to this column.setDefaultValueBoolean
(Boolean defaultValueBoolean) setDefaultValueBoolean
(String defaultValueBoolean) Set the defaultValueBoolean based on a given string.setDefaultValueComputed
(DatabaseFunction defaultValueComputed) void
setDefaultValueConstraintName
(String defaultValueConstraintName) setDefaultValueDate
(String defaultValueDate) Set the date this column should default to.setDefaultValueDate
(Date defaultValueDate) setDefaultValueNumeric
(Number defaultValueNumeric) setDefaultValueNumeric
(String defaultValueNumeric) Set the number this column should use as its default.setDefaultValueSequenceNext
(SequenceNextValueFunction defaultValueSequenceNext) setDescending
(Boolean descending) setEncoding
(String encoding) setGenerationType
(String generationType) setIncluded
(Boolean included) setIncrementBy
(BigInteger incrementBy) setRemarks
(String remarks) setStartWith
(BigInteger startWith) Sets the string value this column should be set to.setValueBlobFile
(String valueBlobFile) setValueBoolean
(Boolean valueBoolean) setValueBoolean
(String valueBoolean) Set the valueBoolean based on a given string.setValueClobFile
(String valueClobFile) setValueComputed
(DatabaseFunction valueComputed) setValueDate
(String valueDate) Set the date this column should be set to.setValueDate
(Date valueDate) setValueNumeric
(Number valueNumeric) setValueNumeric
(String valueNumeric) Set the number this column should be set to.setValueSequenceCurrent
(SequenceCurrentValueFunction valueSequenceCurrent) setValueSequenceNext
(SequenceNextValueFunction valueSequenceNext) Methods inherited from class liquibase.serializer.AbstractLiquibaseSerializable
convertEscaped, getSerializableFieldDataTypeClass, getSerializableFieldDataTypeClassParameters, getSerializableFieldNamespace, getSerializableFields, serialize, serializeValue, setSerializableFieldValue, shouldAutoLoad
-
Constructor Details
-
ColumnConfig
Create a ColumnConfig object based on aColumn
snapshot. It will attempt to set as much as possible based on the information in the snapshot. -
ColumnConfig
public ColumnConfig()Create am empty ColumnConfig object. Boolean and other object values will default to null.
-
-
Method Details
-
fromName
-
arrayFromNames
-
getName
The name of the column. -
setName
-
setName
-
getComputed
-
setComputed
-
getType
The data type fof the column. This value will pass throughDataTypeFactory.fromDescription(String, liquibase.database.Database)
before being included in SQL. -
setType
-
getValue
The String value to set this column to. If you do not want the value set bysetValue(String)
use a more specific function likegetValueNumeric()
or the more genericgetValueObject()
If performing an data manipulation operation, the setValue* functions should be used to set what the columns should be set to. If performing a data definition operation, this setValue* functions should be used to set what existing rows should be set to (may be different than the default value for new rows) -
setValue
Sets the string value this column should be set to. If you are trying to set a value type other than a string, use the more specific functions likesetValueNumeric(Number)
. This method does no processing of the string. Any trimming is expected to be done beforehand. It does not convert the string "null" to null so that you can set the string "null" as a value if you are feeling particularly crazy. -
getValueNumeric
Return the numeric value this column should be set to.- See Also:
-
setValueNumeric
-
setValueNumeric
Set the number this column should be set to. Supports integers and decimals, and strips off any wrapping parentheses. If the passed value cannot be parsed as a number in US locale, it is assumed to be a function that returns a number. If the value "null" is passed, it will set a null value. -
getValueBoolean
Return the boolean value this column should be set to.- See Also:
-
setValueBoolean
Set the valueBoolean based on a given string. If the passed value cannot be parsed as a boolean, it is assumed to be a function that returns a boolean. If the string "null" or an empty string is passed, it will set a null value. If "1" is passed, defaultValueBoolean is set to true. If 0 is passed, defaultValueBoolean is set to false -
setValueBoolean
-
getValueComputed
Return the function this column should be set from.- See Also:
-
setValueComputed
-
getValueSequenceNext
-
setValueSequenceNext
-
getValueSequenceCurrent
-
setValueSequenceCurrent
-
getValueDate
Return the date value this column should be set to.- See Also:
-
setValueDate
Set the date this column should be set to. Supports any of the date or datetime formats handled byISODateFormat
. If the passed value cannot be parsed as a date, it is assumed to be a function that returns a date. If the string "null" is passed, it will set a null value.- Parameters:
valueDate
- the Date Value to use (may be null or "null", or start with "now" or "today").- Throws:
DateParseException
- if the columnType isn't supported for "now" or "today" values.
-
setValueDate
-
getValueBlobFile
Return the file containing the data to load into a BLOB.- See Also:
-
setValueBlobFile
-
getValueClobFile
Return the file containing the data to load into a CLOB.- See Also:
-
setValueClobFile
-
getEncoding
Return encoding of a file, referenced viavalueClobFile
. -
setEncoding
-
getValueObject
Return the value from whatever setValue* function was called. Will return null if none were set. -
getDefaultValue
The String default value to assign to this column. If you do not want the default set bysetDefaultValue(String)
use a more specific function likegetDefaultValueNumeric()
or the more genericgetDefaultValueObject()
-
setDefaultValue
Sets the string default value to assign to this column. If you are trying to set a default value type other than a string, use the more specific functions likesetDefaultValueNumeric(Number)
. This method does no processing of the string. Any trimming is expected to be done beforehand. It does not convert the string "null" to null so that you can set the string "null" as a value if you are feeling particularly crazy. -
getDefaultValueNumeric
Return the numeric value this column should default to.- See Also:
-
setDefaultValueNumeric
Set the number this column should use as its default. Supports integers and decimals, and strips off any wrapping parentheses. If the passed value cannot be parsed as a number, it is assumed to be a function that returns a number. If the value "null" is passed, it will set a null value. A special case is made for "GENERATED_BY_DEFAULT" which simply sets the ColumnConfig object to autoIncrement. -
setDefaultValueNumeric
-
getDefaultValueDate
Return the date value this column should default to.- See Also:
-
setDefaultValueDate
-
setDefaultValueDate
Set the date this column should default to. Supports any of the date or datetime formats handled byISODateFormat
. If the passed value cannot be parsed as a date, it is assumed to be a function that returns a date. If the string "null" or an empty string is passed, it will set a null value. -
getDefaultValueBoolean
Return the boolean value this column should default to.- See Also:
-
setDefaultValueBoolean
Set the defaultValueBoolean based on a given string. If the passed value cannot be parsed as a boolean, it is assumed to be a function that returns a boolean. If the string "null" or an empty string is passed, it will set a null value. If "1" is passed, defaultValueBoolean is set to true. If 0 is passed, defaultValueBoolean is set to false -
setDefaultValueBoolean
-
getDefaultValueComputed
Return the function whose value should generate this column's default.- See Also:
-
setDefaultValueComputed
-
getDefaultValueObject
Return the value to set this column's default to according to the setDefaultValue* function that was called. If none were called, this function returns null. -
getConstraints
Returns the ConstraintsConfig this ColumnConfig is using. Returns null if nho constraints have been assigned yet. -
setConstraints
-
isAutoIncrement
Returns true if this Column should be set to be auto increment. Returns null if auto-increment hasn't been explicitly assigned. -
setAutoIncrement
-
getStartWith
Return the number to start auto incrementing with. -
setStartWith
-
getIncrementBy
Return the amount to auto increment by. -
setIncrementBy
-
hasDefaultValue
public boolean hasDefaultValue()Returns true if any of the setDefaultValue* functions have had a non-null value set -
getRemarks
Return the remarks to apply to this column. -
setRemarks
-
getDescending
-
getIncluded
-
setDescending
-
setIncluded
-
getDefaultOnNull
-
setDefaultOnNull
-
getGenerationType
-
setGenerationType
-
getSerializedObjectName
-
getDefaultValueSequenceNext
-
setDefaultValueSequenceNext
-
getDefaultValueConstraintName
-
setDefaultValueConstraintName
-
getSerializableFieldType
- Specified by:
getSerializableFieldType
in interfaceLiquibaseSerializable
- Overrides:
getSerializableFieldType
in classAbstractLiquibaseSerializable
-
getSerializedObjectNamespace
-
load
public void load(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException - Specified by:
load
in interfaceLiquibaseSerializable
- Overrides:
load
in classAbstractLiquibaseSerializable
- Throws:
ParsedNodeException
-
loadConstraints
- Throws:
ParsedNodeException
-
getSerializableFieldValue
- Specified by:
getSerializableFieldValue
in interfaceLiquibaseSerializable
- Overrides:
getSerializableFieldValue
in classAbstractLiquibaseSerializable
-