Interface Literal<T>

Type Parameters:
T - The Java type of the value wrapped by a Literal
All Superinterfaces:
Serializable

public interface Literal<T> extends Serializable
Represents a literal fixed value in an expression predicate
  • Method Details

    • of

      static Literal<Boolean> of(boolean value)
    • of

      static Literal<Integer> of(int value)
    • of

      static Literal<Long> of(long value)
    • of

      static Literal<Float> of(float value)
    • of

      static Literal<Double> of(double value)
    • of

      static Literal<CharSequence> of(CharSequence value)
    • of

      static Literal<UUID> of(UUID value)
    • of

      static Literal<ByteBuffer> of(byte[] value)
    • of

      static Literal<ByteBuffer> of(ByteBuffer value)
    • of

      static Literal<BigDecimal> of(BigDecimal value)
    • value

      T value()
      Returns the value wrapped by this literal.
    • to

      <X> Literal<X> to(Type type)
      Converts this literal to a literal of the given type.

      When a predicate is bound to a concrete data column, literals are converted to match the bound column's type. This conversion process is more narrow than a cast and is only intended for cases where substituting one type is a common mistake (e.g. 34 instead of 34L) or where this API avoids requiring a concrete class (e.g., dates).

      If conversion to a target type is not supported, this method returns null.

      This method may return Literals.aboveMax() or Literals.belowMin() when the target type is not as wide as the original type. These values indicate that the containing predicate can be simplified. For example, Integer.MAX_VALUE+1 converted to an int will result in aboveMax and can simplify a < Integer.MAX_VALUE+1 to Expressions.alwaysTrue()

      Type Parameters:
      X - The Java type of value the new literal contains
      Parameters:
      type - A primitive Type
      Returns:
      A literal of the given type or null if conversion was not valid
    • comparator

      Comparator<T> comparator()
      Return a Comparator for values.
      Returns:
      a comparator for T objects
    • toByteBuffer

      default ByteBuffer toByteBuffer()
      Serializes the value wrapped by this literal to binary using the single-value serialization format described in the Iceberg table specification.
      Returns:
      a ByteBuffer that contains the serialized literal value.