Package st.orm

Record Class Metamodel.KeyDelegate<T extends Data,E>

java.lang.Object
java.lang.Record
st.orm.Metamodel.KeyDelegate<T,E>
Type Parameters:
T - the root table type.
E - the field type.
All Implemented Interfaces:
Metamodel<T,E>, Metamodel.Key<T,E>, Navigable<T,E>
Enclosing interface:
Metamodel<T extends Data,E>

public static record Metamodel.KeyDelegate<T extends Data,E>(Metamodel<T extends Data,E> delegate) extends Record implements Metamodel.Key<T,E>
Delegating wrapper that adds the Metamodel.Key marker to an existing Metamodel instance.

Equality and hash code are delegated to the wrapped metamodel. Because AbstractMetamodel.equals(java.lang.Object) checks instanceof Metamodel, a KeyDelegate compares equal to its wrapped metamodel when the wrapped metamodel is an AbstractMetamodel.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface st.orm.Metamodel

    Metamodel.Key<T extends Data,E>, Metamodel.KeyDelegate<T extends Data,E>
  • Constructor Summary

    Constructors
    Constructor
    Description
    KeyDelegate(Metamodel<T,E> delegate)
    Creates an instance of a KeyDelegate record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the delegate record component.
    boolean
    Indicates whether some other object is "equal to" this one.
    Returns the field name.
    Returns the field type of the designated element.
    Returns a flat list of leaf metamodels for this navigable.
    @Nullable Object
    getValue(T record)
    Extracts the value from the given record as specified by this metamodel.
    int
    Returns a hash code value for this object.
    boolean
    Returns true if this navigable corresponds to a database column, false otherwise (for example the root navigable or an inline record).
    boolean
    isIdentical(T a, T b)
    Checks whether the value extracted from a is identical to the value extracted from b.
    boolean
    Returns true if this navigable corresponds to an inline record, false otherwise.
    boolean
    Returns the nullability of the underlying field.
    boolean
    isSame(T a, T b)
    Checks whether the value extracted from a is the same as the value extracted from b.
    Returns the path to the database table.
    Returns the root table type.
    Metamodel<T,? extends Data>
    Returns the table that holds the column to which this metamodel is pointing.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface st.orm.Navigable

    asMetamodel, canonical, fieldPath, tableType
  • Constructor Details

    • KeyDelegate

      public KeyDelegate(Metamodel<T,E> delegate)
      Creates an instance of a KeyDelegate record class.
      Parameters:
      delegate - the value for the delegate record component
  • Method Details

    • isColumn

      public boolean isColumn()
      Description copied from interface: Navigable
      Returns true if this navigable corresponds to a database column, false otherwise (for example the root navigable or an inline record). A foreign key column is also a column.
      Specified by:
      isColumn in interface Navigable<T extends Data,E>
      Returns:
      true if this navigable maps to a column, false otherwise.
    • isInline

      public boolean isInline()
      Description copied from interface: Navigable
      Returns true if this navigable corresponds to an inline record, false otherwise.
      Specified by:
      isInline in interface Navigable<T extends Data,E>
      Returns:
      true if this navigable maps to an inline record, false otherwise.
    • root

      public Class<T> root()
      Description copied from interface: Navigable
      Returns the root table type. This is typically the table specified in the FROM clause of a query.
      Specified by:
      root in interface Navigable<T extends Data,E>
      Returns:
      the root table type.
    • table

      public Metamodel<T,? extends Data> table()
      Description copied from interface: Metamodel
      Returns the table that holds the column to which this metamodel is pointing. If the metamodel points to an inline record, the table is the parent table of the inline record. If the metamodel is a root metamodel, the root table is returned.
      Specified by:
      table in interface Metamodel<T extends Data,E>
      Specified by:
      table in interface Navigable<T extends Data,E>
      Returns:
      the table that holds the column to which this metamodel is pointing.
    • path

      public String path()
      Description copied from interface: Navigable
      Returns the path to the database table.
      Specified by:
      path in interface Navigable<T extends Data,E>
      Returns:
      path to the database table.
    • fieldType

      public Class<E> fieldType()
      Description copied from interface: Navigable
      Returns the field type of the designated element.
      Specified by:
      fieldType in interface Navigable<T extends Data,E>
      Returns:
      the field type of the designated element.
    • field

      public String field()
      Description copied from interface: Navigable
      Returns the field name.
      Specified by:
      field in interface Navigable<T extends Data,E>
      Returns:
      field name.
    • getValue

      public @Nullable Object getValue(T record)
      Description copied from interface: Metamodel
      Extracts the value from the given record as specified by this metamodel.

      The returned value may be null if this metamodel represents a nullable field or if any parent metamodel in the access path resolves to null (for example, when navigating through an optional or nullable nested record).

      Implementations may return a non-null value, but callers must not rely on that unless they statically know they are using a non-null metamodel variant.

      Specified by:
      getValue in interface Metamodel<T extends Data,E>
      Parameters:
      record - the root record from which the value is extracted.
      Returns:
      the extracted value, or null if the value cannot be resolved.
    • isIdentical

      public boolean isIdentical(T a, T b)
      Description copied from interface: Metamodel
      Checks whether the value extracted from a is identical to the value extracted from b.

      Semantics: This method performs an identity comparison on the extracted field value. It returns true if and only if both extracted values refer to the same object instance.

      This operation is only meaningful for reference-typed fields. It is not defined for primitive-typed fields.

      Performance guarantees:

      • No boxing or unboxing is performed.
      • No value coercion or conversion is performed.
      • No equals(...) or comparator logic is used.
      Specified by:
      isIdentical in interface Metamodel<T extends Data,E>
      Parameters:
      a - the instance from which the left-hand value is extracted, must not be null.
      b - the instance from which the right-hand value is extracted, must not be null.
      Returns:
      true if both extracted values are the same object instance.
    • isSame

      public boolean isSame(T a, T b)
      Description copied from interface: Metamodel
      Checks whether the value extracted from a is the same as the value extracted from b.

      Semantics: This method performs a value comparison on the extracted field value. The comparison is defined by the field type:

      • For primitive-typed fields, values are compared using ==.
      • For reference-typed fields, values are compared using their defined value semantics (for example equals(...) or an equivalent comparator).

      Performance guarantees:

      • No boxing or unboxing is performed.
      • No identity comparison is performed.
      • The comparison operates directly on the extracted values.
      Specified by:
      isSame in interface Metamodel<T extends Data,E>
      Parameters:
      a - the instance from which the left-hand value is extracted, must not be null.
      b - the instance from which the right-hand value is extracted, must not be null.
      Returns:
      true if both extracted values are equal by value.
    • flatten

      public List<Metamodel<T,?>> flatten()
      Description copied from interface: Navigable
      Returns a flat list of leaf metamodels for this navigable. An inline record is recursively expanded into its individual column metamodels; any other navigable returns a singleton list, because it names its own column(s): an entity node names the foreign key column(s) that reference it, and a scalar names its column. The returned metamodels keep their position in the graph, so they are not canonical.

      The query builder's groupBy and orderBy metamodel overloads do not use this expansion: they resolve a path to the same columns a predicate on that path would use, so a multi-column path (a compound foreign key, an inline record) expands during column resolution rather than here.

      Specified by:
      flatten in interface Navigable<T extends Data,E>
      Returns:
      a list of leaf metamodels.
    • isNullable

      public boolean isNullable()
      Returns the nullability of the underlying field. A delegate around a Metamodel.Key answers through that key; any other delegate derives the answer from the record field the metamodel designates, so a nullable field wrapped by Metamodel.key(Metamodel) is still rejected as a keyset pagination cursor.
      Specified by:
      isNullable in interface Metamodel.Key<T extends Data,E>
      Returns:
      true if this key allows duplicate NULLs (nullable with nullsDistinct = true), false otherwise.
      See Also:
    • equals

      public 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.
    • hashCode

      public 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
    • toString

      public 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
    • delegate

      public Metamodel<T,E> delegate()
      Returns the value of the delegate record component.
      Returns:
      the value of the delegate record component