Package liquibase.snapshot
Class SnapshotControl
- java.lang.Object
-
- liquibase.snapshot.SnapshotControl
-
- All Implemented Interfaces:
LiquibaseSerializable
public class SnapshotControl extends Object implements LiquibaseSerializable
Allows the class user to influence various aspects of the database object snapshot generation, e.g. what types of database objects they want.
-
-
Nested Class Summary
-
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
Constructors Constructor Description SnapshotControl(Database database)
Create a SnapshotControl for a given database and mark the database's standard types for inclusion.SnapshotControl(Database database, boolean expandTypesIfNeeded, Class<? extends DatabaseObject>... types)
SnapshotControl(Database database, Class<? extends DatabaseObject>... types)
Create a Snapshot control for a given database, but explicitly set the object types to be included in snapshots.SnapshotControl(Database database, String types)
Create a Snapshot control for a given database, but explicitly set the object types to be included in snapshots.SnapshotControl(Database database, ObjectChangeFilter objectChangeFilter, Class<? extends DatabaseObject>... types)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addType(Class<? extends DatabaseObject> type, Database database)
Adds a new DatabaseObject type to the list of object types to be included in snapshots.String
getSerializableFieldNamespace(String field)
Set<String>
getSerializableFields()
LiquibaseSerializable.SerializationType
getSerializableFieldType(String field)
Object
getSerializableFieldValue(String field)
String
getSerializedObjectName()
String
getSerializedObjectNamespace()
SnapshotListener
getSnapshotListener()
Set<Class<? extends DatabaseObject>>
getTypesToInclude()
Return the types to be included in snapshotsboolean
isWarnIfObjectNotFound()
Returns if the code should log a LogLevel.WARNING message if the object to be snapshotted could not be found.void
load(ParsedNode parsedNode, ResourceAccessor resourceAccessor)
ParsedNode
serialize()
void
setSnapshotListener(SnapshotListener snapshotListener)
SnapshotControl
setWarnIfObjectNotFound(boolean warnIfObjectNotFound)
Configures the code to log a LogLevel.WARNING message if the object to be snapshotted could not be found.boolean
shouldInclude(Class<? extends DatabaseObject> type)
Queries the currently registered list of types to be included and returns true if the given type is in that list<T extends DatabaseObject>
booleanshouldInclude(T example)
-
-
-
Constructor Detail
-
SnapshotControl
public SnapshotControl(Database database)
Create a SnapshotControl for a given database and mark the database's standard types for inclusion.- Parameters:
database
- the DBMS for which snapshots should be generated
-
SnapshotControl
@SafeVarargs public SnapshotControl(Database database, Class<? extends DatabaseObject>... types)
Create a Snapshot control for a given database, but explicitly set the object types to be included in snapshots.- Parameters:
database
- the DBMS for which snapshots should be generatedtypes
- the list of object types to be included in the snapshot
-
SnapshotControl
@SafeVarargs public SnapshotControl(Database database, boolean expandTypesIfNeeded, Class<? extends DatabaseObject>... types)
-
SnapshotControl
public SnapshotControl(Database database, String types)
Create a Snapshot control for a given database, but explicitly set the object types to be included in snapshots.- Parameters:
database
- the DBMS for which snapshots should be generatedtypes
- the list of object types to be included in the snapshot, separated by commas
-
SnapshotControl
public SnapshotControl(Database database, ObjectChangeFilter objectChangeFilter, Class<? extends DatabaseObject>... types)
-
-
Method Detail
-
getSnapshotListener
public SnapshotListener getSnapshotListener()
-
setSnapshotListener
public void setSnapshotListener(SnapshotListener snapshotListener)
-
getSerializedObjectName
public String getSerializedObjectName()
- Specified by:
getSerializedObjectName
in interfaceLiquibaseSerializable
-
getSerializableFields
public Set<String> getSerializableFields()
- Specified by:
getSerializableFields
in interfaceLiquibaseSerializable
-
getSerializableFieldValue
public Object getSerializableFieldValue(String field)
- Specified by:
getSerializableFieldValue
in interfaceLiquibaseSerializable
-
getSerializableFieldType
public LiquibaseSerializable.SerializationType getSerializableFieldType(String field)
- Specified by:
getSerializableFieldType
in interfaceLiquibaseSerializable
-
getSerializedObjectNamespace
public String getSerializedObjectNamespace()
- Specified by:
getSerializedObjectNamespace
in interfaceLiquibaseSerializable
-
getSerializableFieldNamespace
public String getSerializableFieldNamespace(String field)
- Specified by:
getSerializableFieldNamespace
in interfaceLiquibaseSerializable
-
addType
public boolean addType(Class<? extends DatabaseObject> type, Database database)
Adds a new DatabaseObject type to the list of object types to be included in snapshots.- Parameters:
type
- The type to be addeddatabase
- The database to check for any dependent types that need to be included as well- Returns:
- true if the type was added to the list, false if it was already present.
-
getTypesToInclude
public Set<Class<? extends DatabaseObject>> getTypesToInclude()
Return the types to be included in snapshots- Returns:
- the set of currently registered types
-
shouldInclude
public boolean shouldInclude(Class<? extends DatabaseObject> type)
Queries the currently registered list of types to be included and returns true if the given type is in that list- Parameters:
type
- the DatabaseObject type to be checked- Returns:
- true if that type is registered for inclusion, false if not
-
load
public void load(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException
- Specified by:
load
in interfaceLiquibaseSerializable
- Throws:
ParsedNodeException
-
serialize
public ParsedNode serialize()
- Specified by:
serialize
in interfaceLiquibaseSerializable
-
isWarnIfObjectNotFound
public boolean isWarnIfObjectNotFound()
Returns if the code should log a LogLevel.WARNING message if the object to be snapshotted could not be found.- Returns:
- true if WARNINGs should be emitted (default), false if not.
-
setWarnIfObjectNotFound
public SnapshotControl setWarnIfObjectNotFound(boolean warnIfObjectNotFound)
Configures the code to log a LogLevel.WARNING message if the object to be snapshotted could not be found.- Parameters:
warnIfObjectNotFound
- true if a warning should emitted (default value), false if not.
-
shouldInclude
public <T extends DatabaseObject> boolean shouldInclude(T example)
-
-