Class BasicTable

All Implemented Interfaces:
HasColumns, TableElement
Direct Known Subclasses:
ReadOnlyTable, Table

public abstract class BasicTable extends DataGrainElement implements TableElement
Super class for Table and ReadOnlyTable that encompasses common logic for both table types.
Since:
2019-07-14
Author:
Pavel Perminov (packpaul@mail.ru)
  • Method Details

    • getColumns

      public Map<String,Column<?>> getColumns()
      Unmodified list of table columns.
      Specified by:
      getColumns in interface HasColumns
      Specified by:
      getColumns in interface TableElement
      Returns:
    • getColumn

      public final Column<?> getColumn(String colName) throws ParseException
      Description copied from interface: TableElement
      Returns a column by its name or throws an exception with a message that the column is not found.
      Specified by:
      getColumn in interface TableElement
      Parameters:
      colName - column name
      Returns:
      Throws:
      ParseException - if a column with the specified name is not found in the table
    • getPrimaryKey

      public final Map<String,Column<?>> getPrimaryKey()
      Description copied from interface: TableElement
      Returns unmodified map of primary key columns.
      Specified by:
      getPrimaryKey in interface TableElement
      Returns:
      map of column name -> column
    • addColumn

      public void addColumn(Column<?> column) throws ParseException
      Adds a column to the table.
      Specified by:
      addColumn in interface TableElement
      Parameters:
      column - new column
      Throws:
      ParseException - if a column with the same name is already defined
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • setPK

      public void setPK(String... columnNames) throws ParseException
      Sets primary key on the table in a form of array of columns. It is used for dynamic metadata management.
      Parameters:
      columnNames - array of columns
      Throws:
      ParseException - in case when an empty array is passed in
    • removeColumn

      public final void removeColumn(Column<?> column) throws ParseException
      Description copied from interface: TableElement
      Removes a column from the table.
      Specified by:
      removeColumn in interface TableElement
      Parameters:
      column - existing column
      Throws:
      ParseException - if the column couldn't be removed
    • finalizePK

      public void finalizePK() throws ParseException
      Finalizes the creation of the primary key.
      Throws:
      ParseException - if the primary key is empty.
    • getForeignKeys

      public Set<ForeignKey> getForeignKeys()
      Returns a set of foreign keys for the table.
      Returns:
    • getIndices

      public Set<Index> getIndices()
      Returns a set of indices for the table.
      Returns:
    • getPkConstraintName

      public final String getPkConstraintName()
      Description copied from interface: TableElement
      Returns PK constraint name.
      Specified by:
      getPkConstraintName in interface TableElement
      Returns:
    • setPkConstraintName

      public void setPkConstraintName(String pkConstraintName) throws ParseException
      Sets the name of constraint for the primary key.
      Parameters:
      pkConstraintName - PK constraint name
      Throws:
      ParseException - incorrect name
    • isAutoUpdate

      public boolean isAutoUpdate()
      Whether autoupdate is on/off.

      false value indicates that the table was created with the option WITH NO STRUCTURE UPDATE and it won't take part in the DB autoupdate. Default is true.
      Returns:
    • setAutoUpdate

      public void setAutoUpdate(boolean autoUpdate)
      Sets or clears the option WITH NO STRUCTURE UPDATE.
      Parameters:
      autoUpdate - true if the table is updated automatically, false - in the opposite case.
    • getColumnIndex

      public final int getColumnIndex(String name)
      Description copied from interface: HasColumns
      Column index in the list of columns.
      Specified by:
      getColumnIndex in interface HasColumns
      Parameters:
      name - column name.
    • hasMaterializedViews

      public boolean hasMaterializedViews()
      Returns true in case there are materialized views built on top of this table.
    • getAutoincrementedColumn

      public Optional<IntegerColumn> getAutoincrementedColumn()
      Returns the integer column with default value provided by a sequence (or empty Optional if such column does not exists).
    • getImplements

      public List<String> getImplements()
      Returns interfaces that are implemented by the cursor (values of 'implements' property) for this table.
      Returns: