liquibase.change
Class ColumnConfig

java.lang.Object
  extended by liquibase.serializer.AbstractLiquibaseSerializable
      extended by liquibase.change.ColumnConfig
All Implemented Interfaces:
LiquibaseSerializable
Direct Known Subclasses:
AddColumnConfig, LoadDataColumnConfig

public class ColumnConfig
extends AbstractLiquibaseSerializable

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
static class ColumnConfig.ValueNumeric
           
 
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
ColumnConfig()
          Create am empty ColumnConfig object.
ColumnConfig(Column columnSnapshot)
          Create a ColumnConfig object based on a Column snapshot.
 
Method Summary
static ColumnConfig[] arrayFromNames(String names)
           
static ColumnConfig fromName(String name)
           
 Boolean getComputed()
           
 ConstraintsConfig getConstraints()
          Returns the ConstraintsConfig this ColumnConfig is using.
 String getDefaultValue()
          The String default value to assign to this column.
 Boolean getDefaultValueBoolean()
          Return the boolean value this column should default to.
 DatabaseFunction getDefaultValueComputed()
          Return the function whose value should generate this column's default.
 Date getDefaultValueDate()
          Return the date value this column should default to.
 Number getDefaultValueNumeric()
          Return the numeric value this column should default to.
 Object getDefaultValueObject()
          Return the value to set this column's default to according to the setDefaultValue* function that was called.
 SequenceNextValueFunction getDefaultValueSequenceNext()
           
 Boolean getDescending()
           
 String getEncoding()
          Return encoding of a file, referenced via valueClobFile.
 BigInteger getIncrementBy()
          Return the amount to auto increment by.
 String getName()
          The name of the column.
 String getRemarks()
          Return the remarks to apply to this column.
 LiquibaseSerializable.SerializationType getSerializableFieldType(String field)
           
 String getSerializedObjectName()
           
 String getSerializedObjectNamespace()
           
 BigInteger getStartWith()
          Return the number to start auto incrementing with.
 String getType()
          The data type fof the column.
 String getValue()
          The String value to set this column to.
 String getValueBlobFile()
          Return the file containing the data to load into a BLOB.
 Boolean getValueBoolean()
          Return the boolean value this column should be set to.
 String getValueClobFile()
          Return the file containing the data to load into a CLOB.
 DatabaseFunction getValueComputed()
          Return the function this column should be set from.
 Date getValueDate()
          Return the date value this column should be set to.
 Number getValueNumeric()
          Return the numeric value this column should be set to.
 Object getValueObject()
          Return the value from whatever setValue* function was called.
 SequenceCurrentValueFunction getValueSequenceCurrent()
           
 SequenceNextValueFunction getValueSequenceNext()
           
 boolean hasDefaultValue()
          Returns true if any of the setDefaultValue* functions have had a non-null value set
 Boolean isAutoIncrement()
          Returns true if this Column should be set to be auto increment.
 void load(ParsedNode parsedNode, ResourceAccessor resourceAccessor)
           
protected  void loadConstraints(ParsedNode constraintsNode)
           
 ColumnConfig setAutoIncrement(Boolean autoIncrement)
           
 ColumnConfig setComputed(Boolean computed)
           
 ColumnConfig setConstraints(ConstraintsConfig constraints)
           
 ColumnConfig setDefaultValue(String defaultValue)
          Sets the string default value to assign to this column.
 ColumnConfig setDefaultValueBoolean(Boolean defaultValueBoolean)
           
 ColumnConfig setDefaultValueBoolean(String defaultValueBoolean)
          Set the defaultValueBoolean based on a given string.
 ColumnConfig setDefaultValueComputed(DatabaseFunction defaultValueComputed)
           
 ColumnConfig setDefaultValueDate(Date defaultValueDate)
           
 ColumnConfig setDefaultValueDate(String defaultValueDate)
          Set the date this column should default to.
 ColumnConfig setDefaultValueNumeric(Number defaultValueNumeric)
           
 ColumnConfig setDefaultValueNumeric(String defaultValueNumeric)
          Set the number this column should use as its default.
 ColumnConfig setDefaultValueSequenceNext(SequenceNextValueFunction defaultValueSequenceNext)
           
 ColumnConfig setDescending(Boolean descending)
           
 ColumnConfig setEncoding(String encoding)
           
 ColumnConfig setIncrementBy(BigInteger incrementBy)
           
 ColumnConfig setName(String name)
           
 ColumnConfig setName(String name, boolean computed)
           
 ColumnConfig setRemarks(String remarks)
           
 ColumnConfig setStartWith(BigInteger startWith)
           
 ColumnConfig setType(String type)
           
 ColumnConfig setValue(String value)
          Sets the string value this column should be set to.
 ColumnConfig setValueBlobFile(String valueBlobFile)
           
 ColumnConfig setValueBoolean(Boolean valueBoolean)
           
 ColumnConfig setValueBoolean(String valueBoolean)
          Set the valueBoolean based on a given string.
 ColumnConfig setValueClobFile(String valueClobFile)
           
 ColumnConfig setValueComputed(DatabaseFunction valueComputed)
           
 ColumnConfig setValueDate(Date valueDate)
           
 ColumnConfig setValueDate(String valueDate)
          Set the date this column should be set to.
 ColumnConfig setValueNumeric(Number valueNumeric)
           
 ColumnConfig setValueNumeric(String valueNumeric)
          Set the number this column should be set to.
 ColumnConfig setValueSequenceCurrent(SequenceCurrentValueFunction valueSequenceCurrent)
           
 ColumnConfig setValueSequenceNext(SequenceNextValueFunction valueSequenceNext)
           
 
Methods inherited from class liquibase.serializer.AbstractLiquibaseSerializable
convertEscaped, getSerializableFieldDataTypeClass, getSerializableFieldDataTypeClassParameters, getSerializableFieldNamespace, getSerializableFields, getSerializableFieldValue, serialize, serializeValue, setSerializableFieldValue, shouldAutoLoad
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnConfig

public ColumnConfig(Column columnSnapshot)
Create a ColumnConfig object based on a Column 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 Detail

getName

public String getName()
The name of the column.


setName

public ColumnConfig setName(String name)

setName

public ColumnConfig setName(String name,
                            boolean computed)

getComputed

public Boolean getComputed()

setComputed

public ColumnConfig setComputed(Boolean computed)

getType

public String getType()
The data type fof the column. This value will pass through DataTypeFactory.fromDescription(String, liquibase.database.Database) before being included in SQL.


setType

public ColumnConfig setType(String type)

getValue

public String getValue()
The String value to set this column to. If you do not want the value set by setValue(String) use a more specific function like getValueNumeric() or the more generic getValueObject()

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

public ColumnConfig setValue(String value)
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 like setValueNumeric(Number). This method does no processing of the string. Any trimming is expected to be done beforehand. It does not conver the string "null" to null so that you can set the string "null" as a value if you are feeling particularly crazy.


getValueNumeric

public Number getValueNumeric()
Return the numeric value this column should be set to.

See Also:
setValue(String)

setValueNumeric

public ColumnConfig setValueNumeric(String valueNumeric)
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, it is assumed to be a function that returns a number. If the value "null" is passed, it will set a null value.


setValueNumeric

public ColumnConfig setValueNumeric(Number valueNumeric)

getValueBoolean

public Boolean getValueBoolean()
Return the boolean value this column should be set to.

See Also:
setValue(String)

setValueBoolean

public ColumnConfig setValueBoolean(Boolean valueBoolean)

setValueBoolean

public ColumnConfig setValueBoolean(String valueBoolean)
Set the valueBoolean based on a given string. If the passed value cannot be parsed as a date, 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


getValueComputed

public DatabaseFunction getValueComputed()
Return the function this column should be set from.

See Also:
setValue(String)

setValueComputed

public ColumnConfig setValueComputed(DatabaseFunction valueComputed)

setValueSequenceNext

public ColumnConfig setValueSequenceNext(SequenceNextValueFunction valueSequenceNext)

getValueSequenceNext

public SequenceNextValueFunction getValueSequenceNext()

setValueSequenceCurrent

public ColumnConfig setValueSequenceCurrent(SequenceCurrentValueFunction valueSequenceCurrent)

getValueSequenceCurrent

public SequenceCurrentValueFunction getValueSequenceCurrent()

getValueDate

public Date getValueDate()
Return the date value this column should be set to.

See Also:
setValue(String)

setValueDate

public ColumnConfig setValueDate(Date valueDate)

setValueDate

public ColumnConfig setValueDate(String valueDate)
Set the date this column should be set to. Supports any of the date or datetime formats handled by ISODateFormat. 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.


getValueBlobFile

public String getValueBlobFile()
Return the file containing the data to load into a BLOB.

See Also:
setValue(String)

setValueBlobFile

public ColumnConfig setValueBlobFile(String valueBlobFile)

getValueClobFile

public String getValueClobFile()
Return the file containing the data to load into a CLOB.

See Also:
setValue(String)

setValueClobFile

public ColumnConfig setValueClobFile(String valueClobFile)

getEncoding

public String getEncoding()
Return encoding of a file, referenced via valueClobFile.


setEncoding

public ColumnConfig setEncoding(String encoding)

getValueObject

public Object getValueObject()
Return the value from whatever setValue* function was called. Will return null if none were set.


getDefaultValue

public String getDefaultValue()
The String default value to assign to this column. If you do not want the default set by setDefaultValue(String) use a more specific function like getDefaultValueNumeric() or the more generic getDefaultValueObject()


setDefaultValue

public ColumnConfig setDefaultValue(String defaultValue)
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 like setDefaultValueNumeric(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

public Number getDefaultValueNumeric()
Return the numeric value this column should default to.

See Also:
setDefaultValue(String)

setDefaultValueNumeric

public ColumnConfig setDefaultValueNumeric(Number defaultValueNumeric)

setDefaultValueNumeric

public ColumnConfig setDefaultValueNumeric(String defaultValueNumeric)
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.


getDefaultValueDate

public Date getDefaultValueDate()
Return the date value this column should default to.

See Also:
setDefaultValue(String)

setDefaultValueDate

public ColumnConfig setDefaultValueDate(String defaultValueDate)
Set the date this column should default to. Supports any of the date or datetime formats handled by ISODateFormat. 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.


setDefaultValueDate

public ColumnConfig setDefaultValueDate(Date defaultValueDate)

getDefaultValueBoolean

public Boolean getDefaultValueBoolean()
Return the boolean value this column should default to.

See Also:
setDefaultValue(String)

setDefaultValueBoolean

public ColumnConfig setDefaultValueBoolean(Boolean defaultValueBoolean)

setDefaultValueBoolean

public ColumnConfig setDefaultValueBoolean(String defaultValueBoolean)
Set the defaultValueBoolean based on a given string. If the passed value cannot be parsed as a date, 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


getDefaultValueComputed

public DatabaseFunction getDefaultValueComputed()
Return the function whose value should generate this column's default.

See Also:
setDefaultValue(String)

setDefaultValueComputed

public ColumnConfig setDefaultValueComputed(DatabaseFunction defaultValueComputed)

getDefaultValueObject

public Object 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

public ConstraintsConfig getConstraints()
Returns the ConstraintsConfig this ColumnConfig is using. Returns null if nho constraints have been assigned yet.


setConstraints

public ColumnConfig setConstraints(ConstraintsConfig constraints)

isAutoIncrement

public Boolean isAutoIncrement()
Returns true if this Column should be set to be auto increment. Returns null if auto-increment hasn't been explicitly assigned.


setAutoIncrement

public ColumnConfig setAutoIncrement(Boolean autoIncrement)

getStartWith

public BigInteger getStartWith()
Return the number to start auto incrementing with.


setStartWith

public ColumnConfig setStartWith(BigInteger startWith)

getIncrementBy

public BigInteger getIncrementBy()
Return the amount to auto increment by.


setIncrementBy

public ColumnConfig setIncrementBy(BigInteger incrementBy)

hasDefaultValue

public boolean hasDefaultValue()
Returns true if any of the setDefaultValue* functions have had a non-null value set


getRemarks

public String getRemarks()
Return the remarks to apply to this column.


setRemarks

public ColumnConfig setRemarks(String remarks)

getDescending

public Boolean getDescending()

setDescending

public ColumnConfig setDescending(Boolean descending)

getSerializedObjectName

public String getSerializedObjectName()

getDefaultValueSequenceNext

public SequenceNextValueFunction getDefaultValueSequenceNext()

setDefaultValueSequenceNext

public ColumnConfig setDefaultValueSequenceNext(SequenceNextValueFunction defaultValueSequenceNext)

getSerializableFieldType

public LiquibaseSerializable.SerializationType getSerializableFieldType(String field)
Specified by:
getSerializableFieldType in interface LiquibaseSerializable
Overrides:
getSerializableFieldType in class AbstractLiquibaseSerializable

getSerializedObjectNamespace

public String getSerializedObjectNamespace()

load

public void load(ParsedNode parsedNode,
                 ResourceAccessor resourceAccessor)
          throws ParsedNodeException
Specified by:
load in interface LiquibaseSerializable
Overrides:
load in class AbstractLiquibaseSerializable
Throws:
ParsedNodeException

loadConstraints

protected void loadConstraints(ParsedNode constraintsNode)
                        throws ParsedNodeException
Throws:
ParsedNodeException

fromName

public static ColumnConfig fromName(String name)

arrayFromNames

public static ColumnConfig[] arrayFromNames(String names)


Copyright © 2016 Liquibase.org. All rights reserved.