Package liquibase.structure
Class AbstractDatabaseObject
- java.lang.Object
-
- liquibase.structure.AbstractDatabaseObject
-
- All Implemented Interfaces:
Comparable
,LiquibaseSerializable
,DatabaseObject
- Direct Known Subclasses:
Catalog
,Column
,Data
,ForeignKey
,Index
,PrimaryKey
,Relation
,Schema
,Sequence
,StoredDatabaseLogic
,UniqueConstraint
public abstract class AbstractDatabaseObject extends Object implements DatabaseObject
Template class for all types of database objects can be manipulated using ChangeSets. Objects represented by subclasses are not specific to any RDBMS and thus only contain "high-level" properties that can be found in most DBMS. Examples for things that are represented areTable
,PrimaryKey
andColumn
. Core features of this class include the functionality for the attributes collection (getAttributes()
) and the ability to load an object from a serialised formload(ParsedNode, ResourceAccessor)
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface liquibase.serializer.LiquibaseSerializable
LiquibaseSerializable.SerializationType
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern
CURLY_BRACKET_PATTERN
-
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 AbstractDatabaseObject()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Object o)
<T> T
getAttribute(String attribute, Class<T> type)
Retrieves the value of aDatabaseObject
's attributes and cast it into the desired type.<T> T
getAttribute(String attribute, T defaultValue)
Retrieves the value of aDatabaseObject
's attributes and cast it into the desired type.Set<String>
getAttributes()
Returns the name of all attributes currently stored for thisDatabaseObject
.String
getObjectTypeName()
String
getSerializableFieldNamespace(String field)
Set<String>
getSerializableFields()
LiquibaseSerializable.SerializationType
getSerializableFieldType(String field)
Object
getSerializableFieldValue(String field)
String
getSerializedObjectName()
String
getSerializedObjectNamespace()
String
getSnapshotId()
void
load(ParsedNode parsedNode, ResourceAccessor resourceAccessor)
ParsedNode
serialize()
DatabaseObject
setAttribute(String attribute, Object value)
Sets a given attribute for this object to the specified value.void
setSnapshotId(String snapshotId)
boolean
shouldIncludeCatalogInSpecification()
Returns a boolean value indicating whether the object types should include the catalog name in their specification.boolean
snapshotByDefault()
String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface liquibase.structure.DatabaseObject
getContainingObjects, getName, getSchema, setName
-
-
-
-
Field Detail
-
CURLY_BRACKET_PATTERN
public static final Pattern CURLY_BRACKET_PATTERN
-
-
Method Detail
-
getObjectTypeName
public String getObjectTypeName()
- Specified by:
getObjectTypeName
in interfaceDatabaseObject
-
getSnapshotId
public String getSnapshotId()
- Specified by:
getSnapshotId
in interfaceDatabaseObject
-
setSnapshotId
public void setSnapshotId(String snapshotId)
- Specified by:
setSnapshotId
in interfaceDatabaseObject
-
snapshotByDefault
public boolean snapshotByDefault()
- Specified by:
snapshotByDefault
in interfaceDatabaseObject
-
compareTo
public int compareTo(Object o)
- Specified by:
compareTo
in interfaceComparable
-
getAttributes
public Set<String> getAttributes()
Description copied from interface:DatabaseObject
Returns the name of all attributes currently stored for thisDatabaseObject
.- Specified by:
getAttributes
in interfaceDatabaseObject
- Returns:
- the Set of all attribute names
-
getAttribute
public <T> T getAttribute(String attribute, Class<T> type)
Description copied from interface:DatabaseObject
Retrieves the value of aDatabaseObject
's attributes and cast it into the desired type.- Specified by:
getAttribute
in interfaceDatabaseObject
- Type Parameters:
T
- the desired type of the value- Parameters:
attribute
- case-sensitive name of the attribute for which the value will be retrievedtype
- class compatible with the desired type T of the return value- Returns:
- if the attribute name exists, and the current value can be cast into the desired class, then the value is returned in the desired form. Note that null is a valid value, too.
- if the attribute name does not exist, null is returned.
- if the attribute has a value, but that value cannot be cast into the desired class, a
RuntimeException
will occur.
-
getAttribute
public <T> T getAttribute(String attribute, T defaultValue)
Description copied from interface:DatabaseObject
Retrieves the value of aDatabaseObject
's attributes and cast it into the desired type.- Specified by:
getAttribute
in interfaceDatabaseObject
- Type Parameters:
T
- the desired type of the value- Parameters:
attribute
- case-sensitive name of the attribute for which the value will be retrieveddefaultValue
- the value to be returned if no value (not even null) is stored for the attribute name in the object.- Returns:
- if the attribute name exists, and the current value can be cast into a type compatible with T, then value is returned in the desired form. Note that null is a valid value, too.
- if the attribute name does not exist, defaultValue is returned.
- if the attribute has a value, but that value cannot be cast into a type compatible with T, a
RuntimeException
will occur.
-
setAttribute
public DatabaseObject setAttribute(String attribute, Object value)
Description copied from interface:DatabaseObject
Sets a given attribute for this object to the specified value.- Specified by:
setAttribute
in interfaceDatabaseObject
- Parameters:
attribute
- case-sensitive name of the attributevalue
- value to be set- Returns:
- a reference to the same object
-
getSerializedObjectName
public String getSerializedObjectName()
- Specified by:
getSerializedObjectName
in interfaceLiquibaseSerializable
-
getSerializedObjectNamespace
public String getSerializedObjectNamespace()
- Specified by:
getSerializedObjectNamespace
in interfaceLiquibaseSerializable
-
getSerializableFieldNamespace
public String getSerializableFieldNamespace(String field)
- Specified by:
getSerializableFieldNamespace
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
-
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
-
shouldIncludeCatalogInSpecification
public boolean shouldIncludeCatalogInSpecification()
Returns a boolean value indicating whether the object types should include the catalog name in their specification. This method checks the current value of theINCLUDE_CATALOG_IN_SPECIFICATION
setting in theGlobalConfiguration
.- Returns:
true
if the object types should include the catalog name in their specification, otherwisefalse
.
-
-