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
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 are
Table
,
PrimaryKey
and Column
.
Core features of this class include the functionality for the attributes collection ( getAttributes()
)
and the ability to load an object from a serialised form load(ParsedNode, ResourceAccessor)
.-
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
-
Method Summary
Modifier and TypeMethodDescriptionint
<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.Returns the name of all attributes currently stored for thisDatabaseObject
.getSerializableFieldType
(String field) getSerializableFieldValue
(String field) void
load
(ParsedNode parsedNode, ResourceAccessor resourceAccessor) setAttribute
(String attribute, Object value) Sets a given attribute for this object to the specified value.void
setSnapshotId
(String snapshotId) boolean
Returns a boolean value indicating whether the object types should include the catalog name in their specification.boolean
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 Details
-
CURLY_BRACKET_PATTERN
-
-
Constructor Details
-
AbstractDatabaseObject
public AbstractDatabaseObject()
-
-
Method Details
-
getObjectTypeName
- Specified by:
getObjectTypeName
in interfaceDatabaseObject
-
getSnapshotId
- Specified by:
getSnapshotId
in interfaceDatabaseObject
-
setSnapshotId
- Specified by:
setSnapshotId
in interfaceDatabaseObject
-
snapshotByDefault
public boolean snapshotByDefault()- Specified by:
snapshotByDefault
in interfaceDatabaseObject
-
compareTo
- Specified by:
compareTo
in interfaceComparable
-
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
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
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
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
- Specified by:
getSerializedObjectName
in interfaceLiquibaseSerializable
-
getSerializedObjectNamespace
- Specified by:
getSerializedObjectNamespace
in interfaceLiquibaseSerializable
-
getSerializableFieldNamespace
- Specified by:
getSerializableFieldNamespace
in interfaceLiquibaseSerializable
-
getSerializableFields
- Specified by:
getSerializableFields
in interfaceLiquibaseSerializable
-
getSerializableFieldValue
- Specified by:
getSerializableFieldValue
in interfaceLiquibaseSerializable
-
getSerializableFieldType
- Specified by:
getSerializableFieldType
in interfaceLiquibaseSerializable
-
load
public void load(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException - Specified by:
load
in interfaceLiquibaseSerializable
- Throws:
ParsedNodeException
-
serialize
- Specified by:
serialize
in interfaceLiquibaseSerializable
-
toString
-
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
.
-