Record Class ColumnSpec

java.lang.Object
java.lang.Record
org.litebridgedb.orm.api.spec.ColumnSpec
Record Components:
name - Database column name
generator - Generator used to create a value for this column if not specified during inserts
joinColumn - Field name of the nested DTO to join on
mappedTable - In-line mapped table specification
All Implemented Interfaces:
ColumnMapping

@NullMarked public record ColumnSpec(String name, @Nullable ColumnValueGenerator generator, @Nullable String joinColumn, @Nullable TableMapping mappedTable) extends Record implements ColumnMapping
Specification of a database column, used to map DTO fields to target expressions.

This class is immutable and provides various factory methods to create instances with different configurations.

  • Constructor Details

    • ColumnSpec

      public ColumnSpec(String name, @Nullable ColumnValueGenerator generator, @Nullable String joinColumn)
      Constructs a new ColumnSpec instance with the specified name, value generator, and join column.
      Parameters:
      name - The name of the database column. This parameter is required and must not be null or empty, as it represents the column's identifier in the database.
      generator - A ColumnValueGenerator instance responsible for generating dynamic values for this column during operations like inserts. Can be null if no generator is needed.
      joinColumn - The name of the join column used when this column maps to a nested or related DTO field. Can be null if no join operation is needed.
    • ColumnSpec

      public ColumnSpec(String name, @Nullable ColumnValueGenerator generator)
      Constructs a new ColumnSpec instance with the specified name and value generator.
      Parameters:
      name - The name of the database column. This parameter is required and must not be null or empty, as it represents the column's identifier in the database.
      generator - A ColumnValueGenerator instance responsible for generating dynamic values for this column during operations like inserts. Can be null if no generator is needed.
    • ColumnSpec

      public ColumnSpec(String name)
      Constructs a new ColumnSpec instance with the specified name.
      Parameters:
      name - The name of the database column. This parameter is required and must not be null or empty, as it represents the column's identifier in the database.
    • ColumnSpec

      public ColumnSpec(String name, @Nullable ColumnValueGenerator generator, @Nullable String joinColumn, @Nullable TableMapping mappedTable)
      Creates an instance of a ColumnSpec record class.
      Parameters:
      name - the value for the name record component
      generator - the value for the generator record component
      joinColumn - the value for the joinColumn record component
      mappedTable - the value for the mappedTable record component
  • Method Details

    • 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.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • generator

      public @Nullable ColumnValueGenerator generator()
      Returns the value of the generator record component.
      Returns:
      the value of the generator record component
    • joinColumn

      public @Nullable String joinColumn()
      Returns the value of the joinColumn record component.
      Returns:
      the value of the joinColumn record component
    • mappedTable

      public @Nullable TableMapping mappedTable()
      Returns the value of the mappedTable record component.
      Returns:
      the value of the mappedTable record component