public abstract class AbstractChange extends Object implements Change
Change implementations. You can implement Change directly, this class is purely for convenience but recommended.
By default, this base class relies on annotations such as DatabaseChange and DatabaseChangeProperty
and delegating logic to the SqlGenerator objects created to do the actual change work.
Place the @DatabaseChangeProperty annotations on the read "get" methods to control property metadata.LiquibaseSerializable.SerializationTypeGENERIC_CHANGELOG_EXTENSION_NAMESPACE, GENERIC_SNAPSHOT_EXTENSION_NAMESPACE, STANDARD_CHANGELOG_NAMESPACE, STANDARD_SNAPSHOT_NAMESPACE| Constructor and Description |
|---|
AbstractChange() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgenerateStatements, getConfirmationMessagepublic void finishInitialization()
throws SetupException
finishInitialization in interface ChangeSetupExceptionpublic ChangeMetaData createChangeMetaData()
DatabaseChange annotation
and calls out to createChangeParameterMetadata(String) for each property.createChangeMetaData in interface ChangeUnexpectedLiquibaseException - if no @DatabaseChange annotation on this Change classprotected boolean isInvalidProperty(PropertyDescriptor property)
protected ChangeParameterMetaData createChangeParameterMetadata(String parameterName)
createChangeMetaData() to create metadata for a given parameter. It finds the method that corresponds to the parameter
and calls the corresponding create*MetaData methods such as createRequiredDatabasesMetaData(String, DatabaseChangeProperty) to determine the
correct values for the ChangeParameterMetaData fields.UnexpectedLiquibaseException - if the passed parameter does not existprotected String createSinceMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)
ChangeParameterMetaData "since" value. Uses the value on the DatabaseChangeProperty annotation or returns null as a default.protected String createDescriptionMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)
ChangeParameterMetaData "description" value. Uses the value on the DatabaseChangeProperty annotation or returns null as a default.protected LiquibaseSerializable.SerializationType createSerializationTypeMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)
ChangeParameterMetaData "serializationType" value. Uses the value on the DatabaseChangeProperty annotation or returns SerializationType.NAMED_FIELD as a default.protected String createMustEqualExistingMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)
ChangeParameterMetaData "mustEqual" value. Uses the value on the DatabaseChangeProperty annotation or returns null as a default.protected Map<String,Object> createExampleValueMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)
ChangeParameterMetaData "example" value. Uses the value on the DatabaseChangeProperty annotation or returns null as a default.
Returns map with key=database short name, value=example. Use short-name "all" as the fallback.protected String[] createRequiredDatabasesMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)
ChangeParameterMetaData "requiredDatabases" value.
Uses the value on the DatabaseChangeProperty annotation or returns an array containing the string "COMPUTE" as a default.
"COMPUTE" will cause ChangeParameterMetaData to attempt to determine the required databases based on the generated Statementsprotected String[] createSupportedDatabasesMetaData(String parameterName, DatabaseChangeProperty changePropertyAnnotation)
ChangeParameterMetaData "supportedDatabase" value.
Uses the value on the DatabaseChangeProperty annotation or returns an array containing the string "COMPUTE" as a default.
"COMPUTE" will cause ChangeParameterMetaData to attempt to determine the required databases based on the generated Statementspublic ChangeSet getChangeSet()
getChangeSet in interface Changepublic void setChangeSet(ChangeSet changeSet)
setChangeSet in interface Changepublic boolean generateStatementsVolatile(Database database)
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 Changepublic boolean generateRollbackStatementsVolatile(Database database)
SqlGenerator.generateRollbackStatementsIsVolatile(Database) method on the SqlStatement objects returned by Change.generateStatements(liquibase.database.Database)
If no or null SqlStatements are returned by generateRollbackStatements then this method returns false.generateRollbackStatementsVolatile in interface Changepublic boolean supports(Database database)
SqlGenerator.supports(liquibase.statement.SqlStatement, liquibase.database.Database) method on the SqlStatement objects returned by Change.generateStatements(liquibase.database.Database).
If no or null SqlStatements are returned by generateStatements then this method returns true.
If generateStatementsVolatile(liquibase.database.Database) returns true, we cannot call generateStatements and so assume true.public Warnings warn(Database database)
SqlGenerator.warn(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain) method on the SqlStatement objects returned by Change.generateStatements(liquibase.database.Database).
If a generated statement is not supported for the given database, no warning will be added since that is a validation error.
If no or null SqlStatements are returned by generateStatements then this method returns no warnings.public ValidationErrors validate(Database database)
SqlGenerator.validate(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain) method on the SqlStatement objects returned by Change.generateStatements(liquibase.database.Database).
If no or null SqlStatements are returned by generateStatements then this method returns no errors.
If there are no parameters than this method returns no errorspublic ChangeStatus checkStatus(Database database)
ChangecheckStatus in interface Changepublic SqlStatement[] generateRollbackStatements(Database database) throws RollbackImpossibleException
createInverses().generateRollbackStatements in interface ChangeRollbackImpossibleException - if rollback is not supported for this changepublic boolean supportsRollback(Database database)
createInverses() returns a non-null value.supportsRollback in interface Changepublic CheckSum generateCheckSum()
StringChangeLogSerializergenerateCheckSum in interface Changeprotected Change[] createInverses()
generateRollbackStatements(liquibase.database.Database) is overridden, this method may not be called.public void setResourceAccessor(ResourceAccessor resourceAccessor)
ResourceAccessor that should be used for any file and/or resource loading needed by this Change.
Called automatically by Liquibase during the changelog parsing process.setResourceAccessor in interface Changepublic ResourceAccessor getResourceAccessor()
public Set<DatabaseObject> getAffectedDatabaseObjects(Database database)
SqlGeneratorFactory.getAffectedDatabaseObjects(liquibase.statement.SqlStatement, liquibase.database.Database) method on the SqlStatement objects returned by Change.generateStatements(liquibase.database.Database)
Returns empty set if change is not supported for the passed databasegetAffectedDatabaseObjects in interface Changepublic Set<String> getSerializableFields()
getSerializableFields in interface LiquibaseSerializablepublic Object getSerializableFieldValue(String field)
getSerializableFieldValue in interface LiquibaseSerializablepublic String getSerializedObjectName()
getSerializedObjectName in interface LiquibaseSerializablepublic LiquibaseSerializable.SerializationType getSerializableFieldType(String field)
getSerializableFieldType in interface LiquibaseSerializablepublic String getSerializedObjectNamespace()
getSerializedObjectNamespace in interface LiquibaseSerializablepublic String getSerializableFieldNamespace(String field)
getSerializableFieldNamespace in interface LiquibaseSerializablepublic void load(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException
load in interface LiquibaseSerializableParsedNodeExceptionprotected ColumnConfig createEmptyColumnConfig(Class collectionType) throws InstantiationException, IllegalAccessException
protected void customLoadLogic(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException
ParsedNodeExceptionpublic ParsedNode serialize() throws ParsedNodeException
serialize in interface LiquibaseSerializableParsedNodeExceptionprotected Object serializeValue(Object value) throws ParsedNodeException
ParsedNodeExceptionpublic String getDescription()
ChangegetDescription in interface ChangeCopyright © 2018 Liquibase.org. All rights reserved.