Package liquibase.structure
Interface DatabaseObject
-
- All Superinterfaces:
Comparable
,LiquibaseSerializable
- All Known Implementing Classes:
AbstractDatabaseObject
,Catalog
,Column
,Data
,ForeignKey
,Index
,LiquibaseColumn
,PrimaryKey
,Relation
,Schema
,Sequence
,StoredDatabaseLogic
,StoredProcedure
,Table
,UniqueConstraint
,View
public interface DatabaseObject extends Comparable, LiquibaseSerializable
Interface 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 using this interface areTable
,PrimaryKey
andColumn
.The most important abilities of every DatabaseObject are:
- Maintaining a list of attributes (key/value combinations representing the properties of a DatabaseObject) and methods to manipulate them
- Storing the full name of the object ([catalog and/or schema], object name etc.) to store the object in the database and retrieve it
- See Also:
AbstractDatabaseObject
-
-
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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <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
.DatabaseObject[]
getContainingObjects()
String
getName()
String
getObjectTypeName()
Schema
getSchema()
String
getSnapshotId()
DatabaseObject
setAttribute(String attribute, Object value)
Sets a given attribute for this object to the specified value.DatabaseObject
setName(String name)
Sets the name for the database object.void
setSnapshotId(String id)
boolean
snapshotByDefault()
-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface liquibase.serializer.LiquibaseSerializable
getSerializableFieldNamespace, getSerializableFields, getSerializableFieldType, getSerializableFieldValue, getSerializedObjectName, getSerializedObjectNamespace, load, serialize
-
-
-
-
Method Detail
-
getSnapshotId
String getSnapshotId()
-
setSnapshotId
void setSnapshotId(String id)
-
getContainingObjects
DatabaseObject[] getContainingObjects()
-
getObjectTypeName
String getObjectTypeName()
-
getName
String getName()
-
setName
DatabaseObject setName(String name)
Sets the name for the database object.- Parameters:
name
- the new name for the database object- Returns:
- a reference to the same object (implementing classes are expected to return a reference to the same object).
-
getSchema
Schema getSchema()
-
snapshotByDefault
boolean snapshotByDefault()
-
getAttributes
Set<String> getAttributes()
Returns the name of all attributes currently stored for thisDatabaseObject
.- Returns:
- the Set of all attribute names
-
getAttribute
<T> T getAttribute(String attribute, Class<T> type)
Retrieves the value of aDatabaseObject
's attributes and cast it into the desired type.- 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
<T> T getAttribute(String attribute, T defaultValue)
Retrieves the value of aDatabaseObject
's attributes and cast it into the desired type.- 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
DatabaseObject setAttribute(String attribute, Object value)
Sets a given attribute for this object to the specified value.- Parameters:
attribute
- case-sensitive name of the attributevalue
- value to be set- Returns:
- a reference to the same object
-
-