Package liquibase.change.custom
Class CustomChangeWrapper
- java.lang.Object
-
- liquibase.AbstractExtensibleObject
-
- liquibase.plugin.AbstractPlugin
-
- liquibase.change.AbstractChange
-
- liquibase.change.custom.CustomChangeWrapper
-
- All Implemented Interfaces:
Cloneable,Change,ExtensibleObject,Plugin,LiquibaseSerializable
public class CustomChangeWrapper extends AbstractChange
Adapts CustomChange implementations to the standard change system used by Liquibase. Custom change implementations should implement CustomSqlChange or CustomTaskChange- See Also:
CustomSqlChange,CustomTaskChange
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface liquibase.serializer.LiquibaseSerializable
LiquibaseSerializable.SerializationType
-
-
Field Summary
-
Fields inherited from class liquibase.change.AbstractChange
NODENAME_COLUMN
-
Fields inherited from interface liquibase.change.Change
EMPTY_CHANGE, SHOULD_EXECUTE
-
Fields inherited from interface liquibase.serializer.LiquibaseSerializable
GENERIC_CHANGELOG_EXTENSION_NAMESPACE, GENERIC_SNAPSHOT_EXTENSION_NAMESPACE, STANDARD_CHANGELOG_NAMESPACE, STANDARD_SNAPSHOT_NAMESPACE
-
Fields inherited from interface liquibase.plugin.Plugin
PRIORITY_DATABASE, PRIORITY_DEFAULT, PRIORITY_NOT_APPLICABLE, PRIORITY_SPECIALIZED
-
-
Constructor Summary
Constructors Constructor Description CustomChangeWrapper()
-
Method Summary
-
Methods inherited from class liquibase.change.AbstractChange
checkStatus, createAlternateParameterNames, createChangeMetaData, createChangeParameterMetadata, createDescriptionMetaData, createEmptyColumnConfig, createExampleValueMetaData, createInverses, createMustEqualExistingMetaData, createRequiredDatabasesMetaData, createSerializationTypeMetaData, createSinceMetaData, createSupportedDatabasesMetaData, equals, finishInitialization, generateRollbackStatementsVolatile, getAffectedDatabaseObjects, getChangeSet, getDescription, getExcludedFieldFilters, getResourceAccessor, getSerializableFieldNamespace, getSerializedObjectName, hashCode, isInvalidProperty, modify, serialize, serializeValue, setChangeSet, setResourceAccessor, shouldExecuteChange, supports, toString
-
Methods inherited from class liquibase.AbstractExtensibleObject
clone, describe, get, get, get, getAttributes, getFieldValue, getObjectMetaData, getValuePath, has, set
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface liquibase.ExtensibleObject
clone, describe, get, get, getAttributes, getObjectMetaData, getValuePath, has, set
-
-
-
-
Method Detail
-
generateStatementsVolatile
public boolean generateStatementsVolatile(Database database)
Description copied from class:AbstractChangeImplementation delegates logic to theSqlGenerator.generateStatementsIsVolatile(Database)method on theSqlStatementobjects returned byChange.generateStatements(liquibase.database.Database). If zero or null SqlStatements are returned by generateStatements then this method returns false.- Specified by:
generateStatementsVolatilein interfaceChange- Overrides:
generateStatementsVolatilein classAbstractChange
-
getCustomChange
public CustomChange getCustomChange()
Return the CustomChange instance created by the call tosetClass(String).
-
setClass
public CustomChangeWrapper setClass(String className) throws CustomChangeException
Specify the name of the class to use as the CustomChange and assigns it togetCustomChange().- Throws:
CustomChangeException
-
getClassName
public String getClassName()
Returns the name of the custom class set insetClass(String)
-
setParam
public void setParam(String name, String value)
Specify a parameter on the CustomChange object to set before executingChange.generateStatements(liquibase.database.Database)orgenerateRollbackStatements(liquibase.database.Database)on it. The CustomChange class must have a set method for the given parameter. For example, to call setParam("lastName", "X") you must have a method setLastName(String val) on your class.
-
getParams
public SortedSet<String> getParams()
Returns the parameters set bysetParam(String, String). If no parameters are set, an empty set will be returned
-
getParamValue
public String getParamValue(String key)
Get the value of a parameter set bysetParam(String, String). If the parameter was not set, null will be returned.
-
validate
public ValidationErrors validate(Database database)
Call theCustomChange.validate(liquibase.database.Database)method and return the result.- Specified by:
validatein interfaceChange- Overrides:
validatein classAbstractChange
-
warn
public Warnings warn(Database database)
Required for the Change interface, but not supported by CustomChanges. Returns an empty Warnings object.- Specified by:
warnin interfaceChange- Overrides:
warnin classAbstractChange
-
generateStatements
public SqlStatement[] generateStatements(Database database)
Finishes configuring the CustomChange based on the values passed tosetParam(String, String)then callsCustomSqlChange.generateStatements(liquibase.database.Database)orCustomTaskChange.execute(liquibase.database.Database)depending on the CustomChange implementation. If the CustomChange returns a null SqlStatement array, this method returns an empty array. If a CustomTaskChange is being used, this method will return an empty array.
-
generateRollbackStatements
public SqlStatement[] generateRollbackStatements(Database database) throws RollbackImpossibleException
Finishes configuring the CustomChange based on the values passed tosetParam(String, String)then callsCustomSqlRollback.generateRollbackStatements(liquibase.database.Database)orCustomTaskRollback.rollback(liquibase.database.Database)depending on the CustomChange implementation. If the CustomChange returns a null SqlStatement array, this method returns an empty array. If a CustomTaskChange is being used, this method will return an empty array. AnyRollbackImpossibleExceptionexceptions thrown by the CustomChange will thrown by this method.- Specified by:
generateRollbackStatementsin interfaceChange- Overrides:
generateRollbackStatementsin classAbstractChange- Throws:
RollbackImpossibleException- if rollback is not supported for this change
-
generateCheckSum
public CheckSum generateCheckSum()
Description copied from class:AbstractChangeImplementation generates checksum by serializing the change withStringChangeLogSerializer- Specified by:
generateCheckSumin interfaceChange- Overrides:
generateCheckSumin classAbstractChange
-
supportsRollback
public boolean supportsRollback(Database database)
Returns true if the customChange supports rolling back.generateRollbackStatements(liquibase.database.Database)may still throw aRollbackImpossibleExceptionwhen it is actually executed, even if this method returns true. Currently only checks if the customChange implementsCustomSqlRollback- Specified by:
supportsRollbackin interfaceChange- Overrides:
supportsRollbackin classAbstractChange
-
getConfirmationMessage
public String getConfirmationMessage()
Return the customChange'sCustomChange.getConfirmationMessage()message as the Change's message.
-
getSerializableFieldType
public LiquibaseSerializable.SerializationType getSerializableFieldType(String field)
- Specified by:
getSerializableFieldTypein interfaceLiquibaseSerializable- Overrides:
getSerializableFieldTypein classAbstractChange
-
getSerializableFieldValue
public Object getSerializableFieldValue(String field)
- Specified by:
getSerializableFieldValuein interfaceLiquibaseSerializable- Overrides:
getSerializableFieldValuein classAbstractChange
-
getSerializableFields
public Set<String> getSerializableFields()
Description copied from class:AbstractChangeReturns the fields on this change that are serializable.- Specified by:
getSerializableFieldsin interfaceLiquibaseSerializable- Overrides:
getSerializableFieldsin classAbstractChange
-
getSerializedObjectNamespace
public String getSerializedObjectNamespace()
- Specified by:
getSerializedObjectNamespacein interfaceLiquibaseSerializable- Overrides:
getSerializedObjectNamespacein classAbstractChange
-
load
public void load(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException
- Specified by:
loadin interfaceLiquibaseSerializable- Overrides:
loadin classAbstractChange- Throws:
ParsedNodeException
-
customLoadLogic
public void customLoadLogic(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException
- Overrides:
customLoadLogicin classAbstractChange- Throws:
ParsedNodeException
-
-