Record Class ConvertSpec<T>

java.lang.Object
java.lang.Record
org.litebridge.orm.expression.intent.ConvertSpec<T>
Type Parameters:
T - The target Java type for conversion.
All Implemented Interfaces:
ExpressionSpec, Resolvable, TypeOverride<T>, TypeOverrideExpressionSpec<T>

public record ConvertSpec<T>(ExpressionSpec target, Class<T> returnType) extends Record implements TypeOverrideExpressionSpec<T>, Resolvable
Converts a database result into the specified Java type.

This uses Litebridge's registered type converter to perform the conversion; it is not a database operation.

  • Constructor Details

    • ConvertSpec

      public ConvertSpec(ExpressionSpec target, Class<T> returnType)
      Constructs a ConvertSpec with the specified target expression and return type.
      Parameters:
      target - the target expression to convert
      returnType - the class of the target Java type
  • Method Details

    • target

      public ExpressionSpec target()
      Gets the target expression for conversion.
      Returns:
      the target expression
    • column

      public String column()
      Description copied from interface: Resolvable
      Returns the target column name for this expression.
      Specified by:
      column in interface Resolvable
      Returns:
      the target column name.
    • type

      public Class<? extends ExpressionSpec> type()
      Description copied from interface: Resolvable
      Returns the type of ExpressionSpec that this Resolvable can resolve to.
      Specified by:
      type in interface Resolvable
      Returns:
      the type of ExpressionSpec that this Resolvable can resolve to.
    • replaceTarget

      public ConvertSpec<T> replaceTarget(ExpressionSpec resolvedExpressionSpec)
      Creates a new ConvertSpec with a replaced target expression.
      Parameters:
      resolvedExpressionSpec - the new target expression
      Returns:
      a new ConvertSpec instance
    • 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 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
    • returnType

      public Class<T> returnType()
      Returns the value of the returnType record component.
      Specified by:
      returnType in interface TypeOverride<T>
      Returns:
      the value of the returnType record component