Class Column

java.lang.Object
org.litebridge.db.spi.Aliased
org.litebridge.db.spi.Column

public class Column extends Aliased
A database column that belongs to a specific table and optionally has an alias.

It extends the functionality of the Aliased class to include the concept of table association. Columns can be used to construct queries and represent database metadata.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Column(Table table, String name)
    Construct a new Column instance associated with the specified table and column name.
    Column(Table table, String name, @Nullable String alias)
    Construct a new Column instance associated with the specified table, column name, and optional column alias.
  • Method Summary

    Modifier and Type
    Method
    Description
    as(String alias)
    Assign an alias to the current Column instance and return the updated instance.
    static Column
    c(String table, String column)
    Create a new Column instance associated with the specified table and column name.
    static Column
    c(String schema, String table, String column)
    Create a new Column instance associated with the specified schema, table, and column name.
    static Column
    c(String catalog, String schema, String table, String column)
    Create a new Column instance associated with the specified catalog, schema, table, and column name.
    static Column
    c(Table table, String column)
    Create a new Column instance for the specified table and column name.
    boolean
     
    boolean
    Compares this column with another column, ignoring the alias and the table.
    boolean
    Compares this instance with another Aliased instance, ignoring their aliases.
    int
     
    Retrieve the Table instance associated with this Column.
     

    Methods inherited from class org.litebridge.db.spi.Aliased

    alias, aliasOrName, name, setAlias

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Column

      public Column(Table table, String name)
      Construct a new Column instance associated with the specified table and column name.
      Parameters:
      table - the table to which the column belongs; must not be null
      name - the name of the column; must not be null
    • Column

      public Column(Table table, String name, @Nullable String alias)
      Construct a new Column instance associated with the specified table, column name, and optional column alias.
      Parameters:
      table - the table to which the column belongs; must not be null
      name - the name of the column; must not be null
      alias - an optional alias for the column; may be null if not needed
  • Method Details

    • table

      public Table table()
      Retrieve the Table instance associated with this Column.
      Returns:
      the Table to which this column belongs
    • as

      public Column as(String alias)
      Assign an alias to the current Column instance and return the updated instance.
      Overrides:
      as in class Aliased
      Parameters:
      alias - the alias to set for this column; must not be null
      Returns:
      the updated Column instance with the specified alias
    • c

      public static Column c(Table table, String column)
      Create a new Column instance for the specified table and column name.

      This is shorthand for new Column(table, column).

      Parameters:
      table - the table to which the column belongs
      column - the name of the column
      Returns:
      a new Column instance associated with the given table and column name
    • c

      public static Column c(String table, String column)
      Create a new Column instance associated with the specified table and column name.

      This is shorthand for new Column(new Table("", "", table), column).

      Parameters:
      table - the name of the table to which the column belongs
      column - the name of the column
      Returns:
      a new Column instance associated with the specified catalog, schema, table, and column name
    • c

      public static Column c(String schema, String table, String column)
      Create a new Column instance associated with the specified schema, table, and column name.

      This is shorthand for new Column(new Table("", schema, table), column).

      Parameters:
      schema - the name of the schema to which the table belongs
      table - the name of the table to which the column belongs
      column - the name of the column
      Returns:
      a new Column instance associated with the specified catalog, schema, table, and column name
    • c

      public static Column c(String catalog, String schema, String table, String column)
      Create a new Column instance associated with the specified catalog, schema, table, and column name.

      This is shorthand for new Column(new Table(catalog, schema, table), column).

      Parameters:
      catalog - the name of the catalog to which the table belongs
      schema - the name of the schema to which the table belongs
      table - the name of the table to which the column belongs
      column - the name of the column
      Returns:
      a new Column instance associated with the specified catalog, schema, table, and column name
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Aliased
    • equalsIgnoreAlias

      public boolean equalsIgnoreAlias(Aliased aliased)
      Description copied from class: Aliased
      Compares this instance with another Aliased instance, ignoring their aliases.
      Overrides:
      equalsIgnoreAlias in class Aliased
      Parameters:
      aliased - The other instance to compare with.
      Returns:
      true if the names are equal, false otherwise.
    • equalsColumnOnlyIgnoreAlias

      public boolean equalsColumnOnlyIgnoreAlias(Column column)
      Compares this column with another column, ignoring the alias and the table. Only the column name is compared.
      Parameters:
      column - the column to compare with
      Returns:
      true if the column names are equal; false otherwise
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object