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,PrimaryKeyandColumn. 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 PatternCURLY_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 intcompareTo(Object o)<T> TgetAttribute(String attribute, Class<T> type)Retrieves the value of aDatabaseObject's attributes and cast it into the desired type.<T> TgetAttribute(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.StringgetObjectTypeName()StringgetSerializableFieldNamespace(String field)Set<String>getSerializableFields()LiquibaseSerializable.SerializationTypegetSerializableFieldType(String field)ObjectgetSerializableFieldValue(String field)StringgetSerializedObjectName()StringgetSerializedObjectNamespace()StringgetSnapshotId()voidload(ParsedNode parsedNode, ResourceAccessor resourceAccessor)ParsedNodeserialize()DatabaseObjectsetAttribute(String attribute, Object value)Sets a given attribute for this object to the specified value.voidsetSnapshotId(String snapshotId)booleanshouldIncludeCatalogInSpecification()Returns a boolean value indicating whether the object types should include the catalog name in their specification.booleansnapshotByDefault()StringtoString()-
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:
getObjectTypeNamein interfaceDatabaseObject
-
getSnapshotId
public String getSnapshotId()
- Specified by:
getSnapshotIdin interfaceDatabaseObject
-
setSnapshotId
public void setSnapshotId(String snapshotId)
- Specified by:
setSnapshotIdin interfaceDatabaseObject
-
snapshotByDefault
public boolean snapshotByDefault()
- Specified by:
snapshotByDefaultin interfaceDatabaseObject
-
compareTo
public int compareTo(Object o)
- Specified by:
compareToin interfaceComparable
-
getAttributes
public Set<String> getAttributes()
Description copied from interface:DatabaseObjectReturns the name of all attributes currently stored for thisDatabaseObject.- Specified by:
getAttributesin interfaceDatabaseObject- Returns:
- the Set of all attribute names
-
getAttribute
public <T> T getAttribute(String attribute, Class<T> type)
Description copied from interface:DatabaseObjectRetrieves the value of aDatabaseObject's attributes and cast it into the desired type.- Specified by:
getAttributein 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
RuntimeExceptionwill occur.
-
getAttribute
public <T> T getAttribute(String attribute, T defaultValue)
Description copied from interface:DatabaseObjectRetrieves the value of aDatabaseObject's attributes and cast it into the desired type.- Specified by:
getAttributein 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
RuntimeExceptionwill occur.
-
setAttribute
public DatabaseObject setAttribute(String attribute, Object value)
Description copied from interface:DatabaseObjectSets a given attribute for this object to the specified value.- Specified by:
setAttributein 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:
getSerializedObjectNamein interfaceLiquibaseSerializable
-
getSerializedObjectNamespace
public String getSerializedObjectNamespace()
- Specified by:
getSerializedObjectNamespacein interfaceLiquibaseSerializable
-
getSerializableFieldNamespace
public String getSerializableFieldNamespace(String field)
- Specified by:
getSerializableFieldNamespacein interfaceLiquibaseSerializable
-
getSerializableFields
public Set<String> getSerializableFields()
- Specified by:
getSerializableFieldsin interfaceLiquibaseSerializable
-
getSerializableFieldValue
public Object getSerializableFieldValue(String field)
- Specified by:
getSerializableFieldValuein interfaceLiquibaseSerializable
-
getSerializableFieldType
public LiquibaseSerializable.SerializationType getSerializableFieldType(String field)
- Specified by:
getSerializableFieldTypein interfaceLiquibaseSerializable
-
load
public void load(ParsedNode parsedNode, ResourceAccessor resourceAccessor) throws ParsedNodeException
- Specified by:
loadin interfaceLiquibaseSerializable- Throws:
ParsedNodeException
-
serialize
public ParsedNode serialize()
- Specified by:
serializein 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_SPECIFICATIONsetting in theGlobalConfiguration.- Returns:
trueif the object types should include the catalog name in their specification, otherwisefalse.
-
-