Class Node<T extends Node<T>>

java.lang.Object
org.elasticsearch.xpack.esql.core.tree.Node<T>
Type Parameters:
T - node type
All Implemented Interfaces:
NamedWriteable, Writeable
Direct Known Subclasses:
Expression

public abstract class Node<T extends Node<T>> extends Object implements NamedWriteable
Immutable tree structure. The traversal is done depth-first, pre-order (first the node then its children), that is seeks up and then goes down. Alternative method for post-order (children first, then node) is also offered, that is seeks down and then goes up. Allows transformation which returns the same tree (if no change has been performed) or a new tree otherwise. While it tries as much as possible to use functional Java, due to lack of parallelism, the use of streams and iterators is not really useful and brings too much baggage which might be used incorrectly.
  • Constructor Details

  • Method Details

    • source

      public Source source()
    • sourceLocation

      public Location sourceLocation()
    • sourceText

      public String sourceText()
    • children

      public List<T> children()
    • forEachDown

      public void forEachDown(Consumer<? super T> action)
    • forEachDown

      public <E extends T> void forEachDown(Class<E> typeToken, Consumer<? super E> action)
    • forEachUp

      public void forEachUp(Consumer<? super T> action)
    • forEachUp

      public <E extends T> void forEachUp(Class<E> typeToken, Consumer<? super E> action)
    • forEachPropertyOnly

      public <E> void forEachPropertyOnly(Class<E> typeToken, Consumer<? super E> rule)
    • forEachPropertyDown

      public <E> void forEachPropertyDown(Class<E> typeToken, Consumer<? super E> rule)
    • forEachPropertyUp

      public <E> void forEachPropertyUp(Class<E> typeToken, Consumer<? super E> rule)
    • forEachProperty

      protected <E> void forEachProperty(Class<E> typeToken, Consumer<? super E> rule)
    • anyMatch

      public boolean anyMatch(Predicate<? super T> predicate)
    • collect

      public List<T> collect(Predicate<? super T> predicate)
    • collectLeaves

      public List<T> collectLeaves()
    • collectFirstChildren

      public List<T> collectFirstChildren(Predicate<? super T> predicate)
    • doCollectFirst

      protected void doCollectFirst(Predicate<? super T> predicate, List<T> matches)
    • transformDown

      public T transformDown(Function<? super T,? extends T> rule)
    • transformDown

      public <E extends T> T transformDown(Class<E> typeToken, Function<E,? extends T> rule)
    • transformUp

      public T transformUp(Function<? super T,? extends T> rule)
    • transformUp

      public <E extends T> T transformUp(Class<E> typeToken, Function<E,? extends T> rule)
    • transformChildren

      protected <R extends Function<? super T, ? extends T>> T transformChildren(Function<T,? extends T> traversalOperation)
    • replaceChildrenSameSize

      public final T replaceChildrenSameSize(List<T> newChildren)
    • replaceChildren

      public abstract T replaceChildren(List<T> newChildren)
    • transformPropertiesOnly

      public <E> T transformPropertiesOnly(Class<E> typeToken, Function<? super E,? extends E> rule)
    • transformPropertiesDown

      public <E> T transformPropertiesDown(Class<E> typeToken, Function<? super E,? extends E> rule)
    • transformPropertiesUp

      public <E> T transformPropertiesUp(Class<E> typeToken, Function<? super E,? extends E> rule)
    • transformNodeProps

      protected final <E> T transformNodeProps(Class<E> typeToken, Function<? super E,? extends E> rule)
      Transform this node's properties.

      This always returns something of the same type as the current node but since Node doesn't have a SelfT parameter we return the closest thing we do have: T, which is the root of the hierarchy for this node.

    • info

      protected abstract NodeInfo<? extends T> info()
      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.

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • nodeName

      public String nodeName()
    • nodeProperties

      public List<Object> nodeProperties()
      The values of all the properties that are important to this Node.
    • nodeString

      public String nodeString()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • propertiesToString

      public String propertiesToString(boolean skipIfChild)
      Render the properties of this Node one by one like foo bar baz. These go inside the [ and ] of the output of treeString(java.lang.StringBuilder, int, java.util.BitSet).