Record Class Database

java.lang.Object
java.lang.Record
io.bloviate.db.Database
Record Components:
product - the database product name (e.g., "PostgreSQL", "MySQL")
productVersion - the version string of the database product
catalog - the catalog name, may be null for databases that don't use catalogs
schema - the schema name, may be null for databases that don't use schemas
tables - the list of tables contained in this database

public record Database(String product, String productVersion, String catalog, String schema, List<Table> tables) extends Record
Represents a database instance with its metadata and contained tables.

This immutable record encapsulates database-level information including the database product name, version, catalog, schema, and all tables within the database. It provides convenient access to tables by name with case-insensitive lookup.

Database instances are typically created by DatabaseUtils when analyzing database metadata through JDBC.

Author:
Tim Veil
See Also:
  • Constructor Details

    • Database

      public Database(String product, String productVersion, String catalog, String schema, List<Table> tables)
      Creates an instance of a Database record class.
      Parameters:
      product - the value for the product record component
      productVersion - the value for the productVersion record component
      catalog - the value for the catalog record component
      schema - the value for the schema record component
      tables - the value for the tables record component
  • Method Details

    • getTable

      public Table getTable(String tableName)
      Retrieves a table by name using case-insensitive comparison.
      Parameters:
      tableName - the name of the table to find
      Returns:
      the table with the specified name
      Throws:
      IllegalArgumentException - if no table with the given name exists
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • product

      public String product()
      Returns the value of the product record component.
      Returns:
      the value of the product record component
    • productVersion

      public String productVersion()
      Returns the value of the productVersion record component.
      Returns:
      the value of the productVersion record component
    • catalog

      public String catalog()
      Returns the value of the catalog record component.
      Returns:
      the value of the catalog record component
    • schema

      public String schema()
      Returns the value of the schema record component.
      Returns:
      the value of the schema record component
    • tables

      public List<Table> tables()
      Returns the value of the tables record component.
      Returns:
      the value of the tables record component