Module jakarta.data

Interface ComparableLiteral<V extends Comparable<?>>

Type Parameters:
V - entity attribute type.
All Superinterfaces:
ComparableExpression<Object,V>, Expression<Object,V>, Literal<V>
All Known Subinterfaces:
BooleanLiteral, NumericLiteral<N>, StringLiteral, TemporalLiteral<V>

public interface ComparableLiteral<V extends Comparable<?>> extends ComparableExpression<Object,V>, Literal<V>

A literal expression for a sortable value, such as a Boolean, Character, enumerated, or UUID value.

Since:
1.1
  • Method Details

    • of

      static <V extends Comparable<?>> ComparableLiteral<V> of(V value)

      Creates a ComparableLiteral or subtype of ComparableLiteral that represents the given value.

      The most specific subtype of ComparableLiteral, such as NumericLiteral, StringLiteral, or TemporalLiteral, should be used instead wherever possible.

      Type Parameters:
      V - entity attribute type.
      Parameters:
      value - an immutable value or a mutable value that must never be modified after it is supplied to this method. Must never be null.
      Returns:
      a ComparableLiteral representing the value.
      Throws:
      NullPointerException - if the value is null.
    • of

      static ComparableLiteral<Character> of(char value)
      Create a ComparableLiteral representing the given char.
    • of

      static ComparableLiteral<UUID> of(UUID value)
      Create a ComparableLiteral representing the given UUID.
    • toString

      String toString()

      Returns a String representing the literal value.

      Subtypes of ComparableLiteral override this method to define more specific formats that more closely align with query language.

      If the value is of type Boolean, this method outputs TRUE for Boolean.TRUE and FALSE for Boolean.FALSE.

      If the value is of type Character, this method outputs a String that consists of the character enclosed in single quotes. If the character is the single quote character, an additional single quote character is included to escape it.

      If the value is an enumeration type, this method outputs the fully qualified class name of the type, followed by the . character, followed by the name of the enumeration element to which the value is assigned.

      For all other types, this method outputs a String that begins with an opening curly brace and ends with a closing curly brace. Between the braces are 3 terms delimited by a space character. The first term is ComparableLiteral. The second term is the fully qualified class name of the value's type. The third term is the toString() output of the value, enclosed in single quotes.

      For example, the output of ComparableLiteral.of(Month.MAY).toString() is

       java.time.Month.MAY
       

      For example, the output of ComparableLiteral.of('D').toString() is

       'D'
       

      The output of ComparableLiteral.of(UUID.fromString("73d518c4-b7f6-4c3b-9f63-60a045a43bb8")).toString() is

       {ComparableLiteral java.util.UUID '73d518c4-b7f6-4c3b-9f63-60a045a43bb8'}
       
      Specified by:
      toString in interface Literal<V extends Comparable<?>>
      Overrides:
      toString in class Object
      Returns:
      a String representing the literal value.