Top Description Fields Constructors Methods
liquibase.change.custom

public Class CustomChangeWrapper

extends AbstractChange
Class Inheritance
Annotations
@DatabaseChange
name:customChange
description:Although Liquibase tries to provide a wide range of database refactorings, there are times you may want to create your own custom refactoring class. To create your own custom refactoring, simply create a class that implements the liquibase.change.custom.CustomSqlChange or liquibase.change.custom.CustomTaskChange interface and use the tag in your changeset. If your change can be rolled back, implement the liquibase.change.custom.CustomSqlRollback interface as well. For a sample custom change class, see liquibase.change.custom.ExampleCustomSqlChange
priority:1
Imports
liquibase.Scope, liquibase.change.*, liquibase.database.Database, liquibase.exception.*, liquibase.parser.core.ParsedNode, .ParsedNodeException, liquibase.resource.ResourceAccessor, liquibase.statement.SqlStatement, liquibase.util.ObjectUtil, .OsgiUtil, java.util.*

Adapts CustomChange implementations to the standard change system used by Liquibase. Custom change implementations should implement CustomSqlChange or CustomTaskChange
See Also
liquibase.change.custom.CustomSqlChange, liquibase.change.custom.CustomTaskChange

Field Summary

Modifier and TypeField and Description
private String
private boolean
pack-priv CustomChange
customChange

Non-private access only for testing.

private final SortedSet<String>
private final Map<String, String>
Inherited from liquibase.change.AbstractChange:
NODENAME_COLUMN

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
public void
public SqlStatement[]
public SqlStatement[]
generateStatements(Database database)

Implements liquibase.change.Change.generateStatements.

Finishes configuring the CustomChange based on the values passed to setParam(String, String) then calls CustomSqlChange#generateStatements(liquibase.database.Database) or CustomTaskChange#execute(liquibase.database.Database) depending on the CustomChange implementation.

public boolean
public String
getClassName()

Returns the name of the custom class set in setClass(String)

public String
getConfirmationMessage()

Implements liquibase.change.Change.getConfirmationMessage.

Return the customChange's CustomChange#getConfirmationMessage message as the Change's message.

public CustomChange
getCustomChange()

Return the CustomChange instance created by the call to setClass(String).

public SortedSet<String>
getParams()

Returns the parameters set by setParam(String, String).

public String
getParamValue(String key)

Get the value of a parameter set by setParam(String, String).

public Set<String>
public LiquibaseSerializable.SerializationType
public Object
public String
public void
public CustomChangeWrapper
setClass(String className)

Specify the name of the class to use as the CustomChange and assigns it to getCustomChange().

public void
setParam(String name, String value)

Specify a parameter on the CustomChange object to set before executing liquibase.change.Change#generateStatements(liquibase.database.Database) or generateRollbackStatements(liquibase.database.Database) on it.

public boolean
supportsRollback(Database database)

Overrides liquibase.change.AbstractChange.supportsRollback.

Implements liquibase.change.Change.supportsRollback.

Returns true if the customChange supports rolling back.

public ValidationErrors
public Warnings
warn(Database database)

Overrides liquibase.change.AbstractChange.warn.

Implements liquibase.change.Change.warn.

Required for the Change interface, but not supported by CustomChanges.

Inherited from liquibase.change.AbstractChange:
checkStatuscreateChangeMetaDatacreateChangeParameterMetadatacreateDescriptionMetaDatacreateEmptyColumnConfigcreateExampleValueMetaDatacreateInversescreateMustEqualExistingMetaDatacreateRequiredDatabasesMetaDatacreateSerializationTypeMetaDatacreateSinceMetaDatacreateSupportedDatabasesMetaDataequalsfinishInitializationgenerateCheckSumgenerateRollbackStatementsVolatilegetAffectedDatabaseObjectsgetChangeSetgetDescriptiongetExcludedFieldFiltersgetResourceAccessorgetSerializableFieldNamespacegetSerializedObjectNamehashCodeisInvalidPropertymodifyserializeserializeValuesetChangeSetsetResourceAccessorshouldExecuteChangesupportstoString

Field Detail

classNameback to summary
private String className
configuredback to summary
private boolean configured
customChangeback to summary
pack-priv CustomChange customChange

Non-private access only for testing.

paramsback to summary
private final SortedSet<String> params
paramValuesback to summary
private final Map<String, String> paramValues

Constructor Detail

CustomChangeWrapperback to summary
public CustomChangeWrapper()

Method Detail

configureCustomChangeback to summary
private void configureCustomChange() throws CustomChangeException
customLoadLogicback to summary
public void customLoadLogic(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException

Overrides liquibase.change.AbstractChange.customLoadLogic.

Annotations
@Override
generateRollbackStatementsback to summary
public SqlStatement[] generateRollbackStatements(Database database) throws RollbackImpossibleException

Overrides liquibase.change.AbstractChange.generateRollbackStatements.

Implements liquibase.change.Change.generateRollbackStatements.

Finishes configuring the CustomChange based on the values passed to setParam(String, String) then calls CustomSqlRollback#generateRollbackStatements(liquibase.database.Database) or CustomTaskRollback#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. Any RollbackImpossibleException exceptions thrown by the CustomChange will thrown by this method.
Annotations
@Override
Exceptions
RollbackImpossibleException:

Doc from liquibase.change.Change.generateRollbackStatements.

if rollback is not supported for this change

generateStatementsback to summary
public SqlStatement[] generateStatements(Database database)

Implements liquibase.change.Change.generateStatements.

Finishes configuring the CustomChange based on the values passed to setParam(String, String) then calls CustomSqlChange#generateStatements(liquibase.database.Database) or CustomTaskChange#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.
Annotations
@Override
generateStatementsVolatileback to summary
public boolean generateStatementsVolatile(Database database)

Overrides liquibase.change.AbstractChange.generateStatementsVolatile.

Implements liquibase.change.Change.generateStatementsVolatile.

Doc from liquibase.change.AbstractChange.generateStatementsVolatile.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#generateStatementsIsVolatile(Database) method on the SqlStatement objects returned by generateStatements. If zero or null SqlStatements are returned by generateStatements then this method returns false.

Annotations
@Override
getClassNameback to summary
public String getClassName()

Returns the name of the custom class set in setClass(String)

Annotations
@DatabaseChangeProperty
description:Name class that implements the custom change.
getConfirmationMessageback to summary
public String getConfirmationMessage()

Implements liquibase.change.Change.getConfirmationMessage.

Return the customChange's CustomChange#getConfirmationMessage message as the Change's message.

Annotations
@Override
getCustomChangeback to summary
public CustomChange getCustomChange()

Return the CustomChange instance created by the call to setClass(String).

Annotations
@DatabaseChangeProperty
isChangeProperty:false
getParamsback to summary
public SortedSet<String> getParams()

Returns the parameters set by setParam(String, String). If no parameters are set, an empty set will be returned

Annotations
@DatabaseChangeProperty
isChangeProperty:false
getParamValueback to summary
public String getParamValue(String key)

Get the value of a parameter set by setParam(String, String). If the parameter was not set, null will be returned.

getSerializableFieldsback to summary
public Set<String> getSerializableFields()

Overrides liquibase.change.AbstractChange.getSerializableFields.

Implements liquibase.serializer.LiquibaseSerializable.getSerializableFields.

Doc from liquibase.change.AbstractChange.getSerializableFields.

Returns the fields on this change that are serializable.

Annotations
@Override
getSerializableFieldTypeback to summary
public LiquibaseSerializable.SerializationType getSerializableFieldType(String field)

Overrides liquibase.change.AbstractChange.getSerializableFieldType.

Implements liquibase.serializer.LiquibaseSerializable.getSerializableFieldType.

Annotations
@Override
getSerializableFieldValueback to summary
public Object getSerializableFieldValue(String field)

Overrides liquibase.change.AbstractChange.getSerializableFieldValue.

Implements liquibase.serializer.LiquibaseSerializable.getSerializableFieldValue.

Annotations
@Override
getSerializedObjectNamespaceback to summary
public String getSerializedObjectNamespace()

Overrides liquibase.change.AbstractChange.getSerializedObjectNamespace.

Implements liquibase.serializer.LiquibaseSerializable.getSerializedObjectNamespace.

Annotations
@Override
loadback to summary
public void load(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException

Overrides liquibase.change.AbstractChange.load.

Implements liquibase.serializer.LiquibaseSerializable.load.

Annotations
@Override
setClassback to summary
public CustomChangeWrapper setClass(String className) throws CustomChangeException

Specify the name of the class to use as the CustomChange and assigns it to getCustomChange().

setParamback to summary
public void setParam(String name, String value)

Specify a parameter on the CustomChange object to set before executing liquibase.change.Change#generateStatements(liquibase.database.Database) or generateRollbackStatements(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.

supportsRollbackback to summary
public boolean supportsRollback(Database database)

Overrides liquibase.change.AbstractChange.supportsRollback.

Implements liquibase.change.Change.supportsRollback.

Returns true if the customChange supports rolling back. generateRollbackStatements may still throw a RollbackImpossibleException when it is actually executed, even if this method returns true. Currently only checks if the customChange implements CustomSqlRollback

Annotations
@Override
validateback to summary
public ValidationErrors validate(Database database)

Overrides liquibase.change.AbstractChange.validate.

Implements liquibase.change.Change.validate.

Call the CustomChange#validate(liquibase.database.Database) method and return the result.

Annotations
@Override
warnback to summary
public Warnings warn(Database database)

Overrides liquibase.change.AbstractChange.warn.

Implements liquibase.change.Change.warn.

Required for the Change interface, but not supported by CustomChanges. Returns an empty Warnings object.

Annotations
@Override