All Implemented Interfaces:
NamedWriteable, Writeable, Resolvable

public class Literal extends LeafExpression
Literal or constant.
  • Field Details

  • Constructor Details

  • Method Details

    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Throws:
      IOException
    • getWriteableName

      public String getWriteableName()
    • info

      protected NodeInfo<? extends Literal> info()
      Description copied from class: Node
      Return the information about this node.

      Normally, you want to use one of the static create methods to implement this.

      For QueryPlans, it is very important that the properties contain all of the expressions and references relevant to this node, and that all of the properties are used in the provided constructor; otherwise query plan transformations like QueryPlan#transformExpressionsOnly(Function) will not have an effect.

      Specified by:
      info in class Node<Expression>
    • value

      public Object value()
    • foldable

      public boolean foldable()
      Description copied from class: Expression
      Whether the expression can be evaluated statically, aka "folded", or not.
      Overrides:
      foldable in class Expression
    • nullable

      public Nullability nullable()
      Specified by:
      nullable in class Expression
    • dataType

      public DataType dataType()
      Description copied from class: Expression
      The DataType returned by executing the tree rooted at this expression. If Expression.typeResolved() returns an error then the behavior of this method is undefined. It may return a valid type. Or it may throw an exception. Or it may return a totally nonsensical type.
      Specified by:
      dataType in class Expression
    • resolved

      public boolean resolved()
      Specified by:
      resolved in interface Resolvable
      Overrides:
      resolved in class Expression
    • fold

      public Object fold(FoldContext ctx)
      Description copied from class: Expression
      Evaluate this expression statically to a constant. It is an error to call this if Expression.foldable() returns false.
      Overrides:
      fold in class Expression
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Node<Expression>
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Node<Expression>
    • toString

      public String toString()
      Overrides:
      toString in class Expression
    • nodeString

      public String nodeString()
      Overrides:
      nodeString in class Node<Expression>
    • of

      public static Literal of(FoldContext ctx, Expression foldable)
      Utility method for creating a literal out of a foldable expression. Throws an exception if the expression is not foldable.
    • of

      public static Literal of(Expression source, Object value)