Record Class PushdownTarget

java.lang.Object
java.lang.Record
com.darkcollective.relix.function.PushdownTarget
Record Components:
family - the backend family, lower-cased and never blank
variant - the dialect within that family, lower-cased; empty when the family has only one

public record PushdownTarget(String family, String variant) extends Record
The backend a call is being rendered for, named in a way the SPI can carry without knowing anything about query planning.

A target is a family plus a variant: ("sql", "postgres"), ("sql", "mysql"), ("mongo", ""). The family says what shape of text is wanted — SQL expression syntax, a MongoDB aggregation expression — and the variant distinguishes dialects within it. A spelling that is the same everywhere in a family can ignore the variant; one that is not switches on it.

Both parts are matched lower-cased, and an absent variant is the empty string rather than null.

  • Field Details

  • Constructor Details

    • PushdownTarget

      public PushdownTarget(String family, String variant)
      Creates an instance of a PushdownTarget record class.
      Parameters:
      family - the value for the family record component
      variant - the value for the variant record component
  • Method Details

    • sql

      public static PushdownTarget sql(String dialect)
      A SQL target for the named dialect.
      Parameters:
      dialect - the dialect name, e.g. "postgres"; may be empty for dialect-neutral SQL
      Returns:
      the target
    • mongo

      public static PushdownTarget mongo()
      The MongoDB aggregation-expression target.
      Returns:
      the target
    • isFamily

      public boolean isFamily(String candidate)
      Parameters:
      candidate - a family name, in any case
      Returns:
      true when this target belongs to that family
    • isVariant

      public boolean isVariant(String candidate)
      Parameters:
      candidate - a variant name, in any case
      Returns:
      true when this target's variant is candidate
    • 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.
    • family

      public String family()
      Returns the value of the family record component.
      Returns:
      the value of the family record component
    • variant

      public String variant()
      Returns the value of the variant record component.
      Returns:
      the value of the variant record component