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 are Table, PrimaryKey and Column.

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:
  • Method Details

    • 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 this DatabaseObject.
      Returns:
      the Set of all attribute names
    • getAttribute

      <T> T getAttribute(String attribute, Class<T> type)
      Retrieves the value of a DatabaseObject'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 retrieved
      type - 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 a DatabaseObject'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 retrieved
      defaultValue - 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 attribute
      value - value to be set
      Returns:
      a reference to the same object