liquibase.change.custom
public class CustomChangeWrapper extends AbstractChange
CustomSqlChange
,
CustomTaskChange
LiquibaseSerializable.SerializationType
GENERIC_CHANGELOG_EXTENSION_NAMESPACE, GENERIC_SNAPSHOT_EXTENSION_NAMESPACE, STANDARD_CHANGELOG_NAMESPACE, STANDARD_SNAPSHOT_NAMESPACE
Constructor and Description |
---|
CustomChangeWrapper() |
Modifier and Type | Method and Description |
---|---|
SqlStatement[] |
generateRollbackStatements(Database database)
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. |
SqlStatement[] |
generateStatements(Database database)
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. |
boolean |
generateStatementsVolatile(Database database)
Implementation delegates logic to the
SqlGenerator.generateStatementsIsVolatile(Database) method on the SqlStatement objects returned by Change.generateStatements(liquibase.database.Database) . |
java.lang.ClassLoader |
getClassLoader()
Returns the classloader to use when creating the CustomChange instance in
setClass(String) . |
java.lang.String |
getClassName()
Return the name of the custom class set in
setClass(String) |
java.lang.String |
getConfirmationMessage()
Return the customChange's
CustomChange.getConfirmationMessage() message as the Change's message. |
CustomChange |
getCustomChange()
Return the CustomChange instance created by the call to
setClass(String) . |
java.util.SortedSet<java.lang.String> |
getParams()
Returns the parameters set by
setParam(String, String) . |
java.lang.String |
getParamValue(java.lang.String key)
Get the value of a parameter set by
setParam(String, String) . |
java.util.Set<java.lang.String> |
getSerializableFields()
Returns the fields on this change that are serializable.
|
LiquibaseSerializable.SerializationType |
getSerializableFieldType(java.lang.String field) |
java.lang.Object |
getSerializableFieldValue(java.lang.String field) |
java.lang.String |
getSerializedObjectNamespace() |
CustomChangeWrapper |
setClass(java.lang.String className)
Specify the name of the class to use as the CustomChange.
|
void |
setClassLoader(java.lang.ClassLoader classLoader) |
void |
setParam(java.lang.String name,
java.lang.String value)
Specify a parameter on the CustomChange object to set before executing
Change.generateStatements(liquibase.database.Database) or generateRollbackStatements(liquibase.database.Database) on it. |
boolean |
supportsRollback(Database database)
Returns true if the customChange supports rolling back.
|
ValidationErrors |
validate(Database database)
Call the
CustomChange.validate(liquibase.database.Database) method and return the result. |
Warnings |
warn(Database database)
Required for the Change interface, but not supported by CustomChanges.
|
createChangeMetaData, createChangeParameterMetadata, createDescriptionMetaData, createExampleValueMetaData, createInverses, createMustEqualExistingMetaData, createRequiredDatabasesMetaData, createSerializationTypeMetaData, createSinceMetaData, createSupportedDatabasesMetaData, finishInitialization, generateCheckSum, generateRollbackStatementsVolatile, getAffectedDatabaseObjects, getChangeSet, getResourceAccessor, getSerializedObjectName, setChangeSet, setResourceAccessor, supports
public boolean generateStatementsVolatile(Database database)
AbstractChange
SqlGenerator.generateStatementsIsVolatile(Database)
method on the SqlStatement
objects returned by Change.generateStatements(liquibase.database.Database)
.
If zero or null SqlStatements are returned by generateStatements then this method returns false.generateStatementsVolatile
in interface Change
generateStatementsVolatile
in class AbstractChange
public CustomChange getCustomChange()
setClass(String)
.public java.lang.ClassLoader getClassLoader()
setClass(String)
.public void setClassLoader(java.lang.ClassLoader classLoader)
public CustomChangeWrapper setClass(java.lang.String className) throws CustomChangeException
getClassLoader()
or fallback methods
and assigns it to getCustomChange()
.
setClassLoader(ClassLoader)
must be called before this method. The passed class is constructed, but no parameters are set. They are set in Change.generateStatements(liquibase.database.Database)
CustomChangeException
public java.lang.String getClassName()
setClass(String)
public void setParam(java.lang.String name, java.lang.String value)
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.public java.util.SortedSet<java.lang.String> getParams()
setParam(String, String)
. If no parameters are set, an empty set will be returnedpublic java.lang.String getParamValue(java.lang.String key)
setParam(String, String)
. If the parameter was not set, null will be returned.public ValidationErrors validate(Database database)
CustomChange.validate(liquibase.database.Database)
method and return the result.validate
in interface Change
validate
in class AbstractChange
public Warnings warn(Database database)
warn
in interface Change
warn
in class AbstractChange
public SqlStatement[] generateStatements(Database database)
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.public SqlStatement[] generateRollbackStatements(Database database) throws RollbackImpossibleException
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.generateRollbackStatements
in interface Change
generateRollbackStatements
in class AbstractChange
RollbackImpossibleException
- if rollback is not supported for this changepublic boolean supportsRollback(Database database)
generateRollbackStatements(liquibase.database.Database)
may still trow a RollbackImpossibleException
when it is actually exectued, even if this method returns true.
Currently only checks if the customChange implements CustomSqlRollback
supportsRollback
in interface Change
supportsRollback
in class AbstractChange
public java.lang.String getConfirmationMessage()
CustomChange.getConfirmationMessage()
message as the Change's message.public LiquibaseSerializable.SerializationType getSerializableFieldType(java.lang.String field)
getSerializableFieldType
in interface LiquibaseSerializable
getSerializableFieldType
in class AbstractChange
public java.lang.Object getSerializableFieldValue(java.lang.String field)
getSerializableFieldValue
in interface LiquibaseSerializable
getSerializableFieldValue
in class AbstractChange
public java.util.Set<java.lang.String> getSerializableFields()
AbstractChange
getSerializableFields
in interface LiquibaseSerializable
getSerializableFields
in class AbstractChange
public java.lang.String getSerializedObjectNamespace()
getSerializedObjectNamespace
in interface LiquibaseSerializable
getSerializedObjectNamespace
in class AbstractChange