Class TableMetaData

java.lang.Object
org.litebridgedb.db.spi.TableMetaData

public final class TableMetaData extends Object
Metadata for a database table, including its primary keys and columns.

It extends the Table class and provides additional information about the table's columns, primary key, and column mappings.

This class is immutable and thread-safe.

  • Constructor Details

    • TableMetaData

      public TableMetaData(Table table, List<String> primaryKey, List<ColumnMetaData> columns)
      Construct a TableMetaData instance using the provided table, primary key, and column metadata.
      Parameters:
      table - the Table object representing the database table; must not be null
      primaryKey - a list of column names representing the primary key of the table; must not be null
      columns - a list of ColumnMetaData objects representing the columns of the table; must not be null
      Throws:
      IllegalArgumentException - if any primary key column metadata is not found in the provided column metadata
    • TableMetaData

      public TableMetaData(String catalog, String schema, String table, List<String> primaryKey, List<ColumnMetaData> columns)
      Construct a TableMetaData object representing metadata for a database table.
      Parameters:
      catalog - the catalog name of the table; may be null if not applicable
      schema - the schema name of the table; may be null if not applicable
      table - the name of the table; must not be null
      primaryKey - a list of column names representing the primary key of the table; must not be null
      columns - a list of ColumnMetaData objects representing the columns of the table; must not be null
      Throws:
      IllegalArgumentException - if any primary key column metadata is not found in the provided column metadata
  • Method Details

    • catalog

      public String catalog()
    • schema

      public String schema()
    • name

      public String name()
    • primaryKey

      public List<ColumnMetaData> primaryKey()
      Retrieve the primary key columns' metadata for the table.
      Returns:
      a list of ColumnMetaData objects representing the metadata of the primary key columns in the table.
    • columns

      public List<ColumnMetaData> columns()
      Retrieve a list of metadata for the columns in the table.
      Returns:
      a list of ColumnMetaData objects representing the metadata of all columns in the table.
    • column

      public ColumnMetaData column(String columnName)
      Retrieve the metadata for a specific column given its name.

      If the column does not exist, an IllegalArgumentException is thrown.

      Parameters:
      columnName - the name of the column whose metadata is to be retrieved
      Returns:
      the ColumnMetaData object associated with the specified column name
      Throws:
      IllegalArgumentException - if the column is not found or if the provided name is null
    • hasColumn

      public boolean hasColumn(String columnName)
      Check if the specified column name exists in the table.
      Parameters:
      columnName - the name of the column to check for existence
      Returns:
      true if the column exists, false otherwise
    • toTable

      public Table toTable()
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object