Package org.pgcodekeeper.core.schema
Class AbstractSchema
java.lang.Object
org.pgcodekeeper.core.schema.PgStatement
org.pgcodekeeper.core.schema.AbstractSchema
- All Implemented Interfaces:
IHashable,ISchema,IStatement,IStatementContainer
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.
-
Field Summary
Fields inherited from class org.pgcodekeeper.core.schema.PgStatement
GO -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(IStatement st) Adds a child statement to this container.voidaddFunction(AbstractFunction function) Adds a function to this schema.voidaddSequence(AbstractSequence sequence) Adds a sequence to this schema.voidaddTable(AbstractTable table) Adds a table to this schema.voidaddType(AbstractType type) Adds a type to this schema.voidaddView(AbstractView view) Adds a view to this schema.booleancompare(PgStatement obj) This method does not account for nested child PgStatements.booleanDeep part ofPgStatement.equals(Object).voidcomputeHash(Hasher hasher) Computes the hash of the implementing object using the provided hasher.Gets a child statement by name and type.getConstraintByName(String constraintName) Finds a constraint by name across all tables and views in this schema.Gets the database that contains this statement.getFunction(String signature) Finds function according to specified functionsignature.Getter forfunctions.getIndexByName(String indexName) Finds an index by name across all tables and views in this schema.getRelation(String name) Gets a relation by name.Gets all relations (tables, views, sequences) in this schema.getSequence(String name) Finds sequence according to specified sequencename.Getter forsequences.getStatementContainer(String name) Gets a statement container by name.Gets a stream of all statement containers in this schema.Gets the type of this database object.Finds table according to specified tablename.Getter fortables.Finds type according to specified typename.Finds view according to specified viewname.getViews()Getter forviews.Copies all object properties into a new object and leaves all its children empty.Methods inherited from class org.pgcodekeeper.core.schema.PgStatement
addAllDeps, addDep, addPrivilege, appendAlterComments, appendAlterSQL, appendComments, appendOwnerSQL, canDrop, canDropBeforeCreate, checkComments, clearPrivileges, deepCopy, equals, getAuthor, getBareName, getChildren, getComment, getCreationSQL, getDbType, getDeps, getDescendants, getDropSQL, getDropSQL, getLibName, getLocation, getName, getObjectState, getObjectState, getOwner, getParent, getPrivileges, getQualifiedName, getSQL, getTwin, getTypeName, hasChildren, hashCode, isLib, isOwned, isSubElement, setAuthor, setComment, setLibName, setLocation, setOwner, setParent, toStringMethods inherited from interface org.pgcodekeeper.core.schema.IStatement
getBareName, getComment, getName, getParent, getQualifiedName
-
Method Details
-
getStatementType
Description copied from interface:IStatementGets the type of this database object.- Specified by:
getStatementTypein interfaceIStatement- Returns:
- the database object type
-
getDatabase
Description copied from interface:IStatementGets the database that contains this statement.- Specified by:
getDatabasein interfaceIStatement- Returns:
- the containing database
-
getFunction
Finds function according to specified functionsignature.- Specified by:
getFunctionin interfaceISchema- Parameters:
signature- signature of the function to be searched- Returns:
- found function or null if no such function has been found
-
getRelation
Description copied from interface:ISchemaGets a relation by name.- Specified by:
getRelationin interfaceISchema- Parameters:
name- the relation name- Returns:
- found relation or null if no such relation has been found
-
getFunctions
Getter forfunctions. The list cannot be modified.- Specified by:
getFunctionsin interfaceISchema- Returns:
functions
-
getRelations
Description copied from interface:ISchemaGets all relations (tables, views, sequences) in this schema.- Specified by:
getRelationsin interfaceISchema- Returns:
- a stream of relations
-
getChild
Description copied from interface:IStatementContainerGets a child statement by name and type.- Specified by:
getChildin interfaceIStatementContainer- Parameters:
name- the name of the child to findtype- the type of the child to find- Returns:
- the child statement, or null if not found
-
addChild
Description copied from interface:IStatementContainerAdds a child statement to this container.- Specified by:
addChildin interfaceIStatementContainer- Parameters:
st- the child statement to add
-
getSequence
Finds sequence according to specified sequencename.- Parameters:
name- name of the sequence to be searched- Returns:
- found sequence or null if no such sequence has been found
-
getSequences
Getter forsequences. The list cannot be modified.- Returns:
sequences
-
getTable
Finds table according to specified tablename.- Parameters:
name- name of the table to be searched- Returns:
- found table or null if no such table has been found
-
getTables
Getter fortables. The list cannot be modified.- Returns:
tables
-
getView
Finds view according to specified viewname.- Parameters:
name- name of the view to be searched- Returns:
- found view or null if no such view has been found
-
getViews
Getter forviews. The list cannot be modified.- Returns:
views
-
getStatementContainer
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
Gets a stream of all statement containers in this schema.- Returns:
- a stream of statement containers
-
getIndexByName
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
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
Finds type according to specified typename.- Parameters:
name- name of the type to be searched- Returns:
- found type or null if no such type has been found
-
addFunction
Adds a function to this schema.- Parameters:
function- the function to add
-
addSequence
Adds a sequence to this schema.- Parameters:
sequence- the sequence to add
-
addTable
Adds a table to this schema.- Parameters:
table- the table to add
-
addView
Adds a view to this schema.- Parameters:
view- the table to add
-
addType
Adds a type to this schema.- Parameters:
type- the table to add
-
compare
Description copied from class:PgStatementThis method does not account for nested child PgStatements. Shallow version ofPgStatement.equals(Object)- Overrides:
comparein classPgStatement
-
compareChildren
Description copied from class:PgStatementDeep part ofPgStatement.equals(Object). Compares all object's child PgStatements for equality.- Overrides:
compareChildrenin classPgStatement
-
computeHash
Description copied from interface:IHashableComputes the hash of the implementing object using the provided hasher. The implementation should call appropriateputmethods on the hasher for all fields that should contribute to the hash value.- Specified by:
computeHashin interfaceIHashable- Parameters:
hasher- the hasher instance to use for hash computation
-
shallowCopy
Description copied from class:PgStatementCopies all object properties into a new object and leaves all its children empty.- Specified by:
shallowCopyin classPgStatement- Returns:
- shallow copy of a DB object.
-