Class AbstractSchema

java.lang.Object
org.pgcodekeeper.core.schema.PgStatement
org.pgcodekeeper.core.schema.AbstractSchema
All Implemented Interfaces:
IHashable, ISchema, IStatement, IStatementContainer
Direct Known Subclasses:
ChSchema, MsSchema, PgSchema

public abstract class AbstractSchema extends PgStatement implements ISchema
Abstract base class representing a database schema. Contains tables, views, functions, sequences, types and other database objects. Provides common functionality for schemas across different database types including.
  • Method Details

    • getStatementType

      public DbObjType getStatementType()
      Description copied from interface: IStatement
      Gets the type of this database object.
      Specified by:
      getStatementType in interface IStatement
      Returns:
      the database object type
    • getDatabase

      public AbstractDatabase getDatabase()
      Description copied from interface: IStatement
      Gets the database that contains this statement.
      Specified by:
      getDatabase in interface IStatement
      Returns:
      the containing database
    • getFunction

      public AbstractFunction getFunction(String signature)
      Finds function according to specified function signature.
      Specified by:
      getFunction in interface ISchema
      Parameters:
      signature - signature of the function to be searched
      Returns:
      found function or null if no such function has been found
    • getRelation

      public IRelation getRelation(String name)
      Description copied from interface: ISchema
      Gets a relation by name.
      Specified by:
      getRelation in interface ISchema
      Parameters:
      name - the relation name
      Returns:
      found relation or null if no such relation has been found
    • getFunctions

      public Collection<IFunction> getFunctions()
      Getter for functions. The list cannot be modified.
      Specified by:
      getFunctions in interface ISchema
      Returns:
      functions
    • getRelations

      public Stream<IRelation> getRelations()
      Description copied from interface: ISchema
      Gets all relations (tables, views, sequences) in this schema.
      Specified by:
      getRelations in interface ISchema
      Returns:
      a stream of relations
    • getChild

      public PgStatement getChild(String name, DbObjType type)
      Description copied from interface: IStatementContainer
      Gets a child statement by name and type.
      Specified by:
      getChild in interface IStatementContainer
      Parameters:
      name - the name of the child to find
      type - the type of the child to find
      Returns:
      the child statement, or null if not found
    • addChild

      public void addChild(IStatement st)
      Description copied from interface: IStatementContainer
      Adds a child statement to this container.
      Specified by:
      addChild in interface IStatementContainer
      Parameters:
      st - the child statement to add
    • getSequence

      public AbstractSequence getSequence(String name)
      Finds sequence according to specified sequence name.
      Parameters:
      name - name of the sequence to be searched
      Returns:
      found sequence or null if no such sequence has been found
    • getSequences

      public Collection<AbstractSequence> getSequences()
      Getter for sequences. The list cannot be modified.
      Returns:
      sequences
    • getTable

      public AbstractTable getTable(String name)
      Finds table according to specified table name.
      Parameters:
      name - name of the table to be searched
      Returns:
      found table or null if no such table has been found
    • getTables

      public Collection<AbstractTable> getTables()
      Getter for tables. The list cannot be modified.
      Returns:
      tables
    • getView

      public AbstractView getView(String name)
      Finds view according to specified view name.
      Parameters:
      name - name of the view to be searched
      Returns:
      found view or null if no such view has been found
    • getViews

      public Collection<AbstractView> getViews()
      Getter for views. The list cannot be modified.
      Returns:
      views
    • getStatementContainer

      public PgStatementContainer getStatementContainer(String name)
      Gets a statement container by name.
      Parameters:
      name - the name of the container to find
      Returns:
      the statement container with the given name, or null if not found
    • getStatementContainers

      public Stream<PgStatementContainer> getStatementContainers()
      Gets a stream of all statement containers in this schema.
      Returns:
      a stream of statement containers
    • getIndexByName

      public AbstractIndex getIndexByName(String indexName)
      Finds an index by name across all tables and views in this schema.
      Parameters:
      indexName - the name of the index to find
      Returns:
      the index with the given name, or null if not found
    • getConstraintByName

      public AbstractConstraint getConstraintByName(String constraintName)
      Finds a constraint by name across all tables and views in this schema.
      Parameters:
      constraintName - the name of the constraint to find
      Returns:
      the constraint with the given name, or null if not found
    • getType

      public AbstractType getType(String name)
      Finds type according to specified type name.
      Parameters:
      name - name of the type to be searched
      Returns:
      found type or null if no such type has been found
    • addFunction

      public void addFunction(AbstractFunction function)
      Adds a function to this schema.
      Parameters:
      function - the function to add
    • addSequence

      public void addSequence(AbstractSequence sequence)
      Adds a sequence to this schema.
      Parameters:
      sequence - the sequence to add
    • addTable

      public void addTable(AbstractTable table)
      Adds a table to this schema.
      Parameters:
      table - the table to add
    • addView

      public void addView(AbstractView view)
      Adds a view to this schema.
      Parameters:
      view - the table to add
    • addType

      public void addType(AbstractType type)
      Adds a type to this schema.
      Parameters:
      type - the table to add
    • compare

      public boolean compare(PgStatement obj)
      Description copied from class: PgStatement
      This method does not account for nested child PgStatements. Shallow version of PgStatement.equals(Object)
      Overrides:
      compare in class PgStatement
    • compareChildren

      public boolean compareChildren(PgStatement obj)
      Description copied from class: PgStatement
      Deep part of PgStatement.equals(Object). Compares all object's child PgStatements for equality.
      Overrides:
      compareChildren in class PgStatement
    • computeHash

      public void computeHash(Hasher hasher)
      Description copied from interface: IHashable
      Computes the hash of the implementing object using the provided hasher. The implementation should call appropriate put methods on the hasher for all fields that should contribute to the hash value.
      Specified by:
      computeHash in interface IHashable
      Parameters:
      hasher - the hasher instance to use for hash computation
    • shallowCopy

      public AbstractSchema shallowCopy()
      Description copied from class: PgStatement
      Copies all object properties into a new object and leaves all its children empty.
      Specified by:
      shallowCopy in class PgStatement
      Returns:
      shallow copy of a DB object.