Record Class FieldColumnSpec

java.lang.Object
java.lang.Record
org.litebridgedb.orm.api.spec.FieldColumnSpec
Record Components:
field - The FieldSpec representing the DTO field or property being mapped.
column - The ColumnMapping representing the database mapping for the field.

public record FieldColumnSpec(FieldSpec field, ColumnMapping column) extends Record
Represents the mapping between a specific field in a Data Transfer Object (DTO) and its corresponding database column specification.

This record combines a FieldSpec that defines the characteristics of the field or property being mapped with a ColumnMapping that defines how the field maps to the database representation. It is a core component of the ORM framework for defining field-to-column mappings in a concise, type-safe manner.

The FieldColumnSpec record provides a utility method to retrieve the column specification as a ColumnSpec, which is useful for direct column mappings.

  • Constructor Details

    • FieldColumnSpec

      public FieldColumnSpec(FieldSpec field, ColumnMapping column)
      Creates an instance of a FieldColumnSpec record class.
      Parameters:
      field - the value for the field record component
      column - the value for the column record component
  • Method Details

    • columnSpec

      public ColumnSpec columnSpec()
      Retrieves the database column specification as a ColumnSpec.

      This method provides a type-safe way to access the column mapping for the associated field in the form of a ColumnSpec, which represents the configuration and metadata of the target database column.

      Returns:
      The ColumnSpec representing the column mapping for the field in the DTO.
      Throws:
      IllegalArgumentException - if the provided column mapping is not an instance of ColumnSpec.
    • 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.
    • field

      public FieldSpec field()
      Returns the value of the field record component.
      Returns:
      the value of the field record component
    • column

      public ColumnMapping column()
      Returns the value of the column record component.
      Returns:
      the value of the column record component