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.
  • Constructor Details

    • 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 generated
      types - 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 generated
      types - 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 Details

    • getSnapshotListener

      public SnapshotListener getSnapshotListener()
    • setSnapshotListener

      public void setSnapshotListener(SnapshotListener snapshotListener)
    • getSerializedObjectName

      public String getSerializedObjectName()
      Specified by:
      getSerializedObjectName in interface LiquibaseSerializable
    • getSerializableFields

      public Set<String> getSerializableFields()
      Specified by:
      getSerializableFields in interface LiquibaseSerializable
    • getSerializableFieldValue

      public Object getSerializableFieldValue(String field)
      Specified by:
      getSerializableFieldValue in interface LiquibaseSerializable
    • getSerializableFieldType

      public LiquibaseSerializable.SerializationType getSerializableFieldType(String field)
      Specified by:
      getSerializableFieldType in interface LiquibaseSerializable
    • getSerializedObjectNamespace

      public String getSerializedObjectNamespace()
      Specified by:
      getSerializedObjectNamespace in interface LiquibaseSerializable
    • getSerializableFieldNamespace

      public String getSerializableFieldNamespace(String field)
      Specified by:
      getSerializableFieldNamespace in interface LiquibaseSerializable
    • 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 added
      database - 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 interface LiquibaseSerializable
      Throws:
      ParsedNodeException
    • serialize

      public ParsedNode serialize()
      Specified by:
      serialize in interface LiquibaseSerializable
    • 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.
    • shouldSearchNestedObjects

      public boolean shouldSearchNestedObjects()
      When searchNestedObjects is false this indicates to stop searching the snapshot the moment an example object has been found. With this disabled we will not search for nested objects.
      Returns:
      the search nested objects configuration
    • 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)