Class TreeScript

java.lang.Object
com.valhalla.sdk.AbstractScript
com.valhalla.sdk.tasks.tree.TreeScript
All Implemented Interfaces:
Sleepable

public abstract class TreeScript extends AbstractScript
Hierarchical first-valid-node script framework.

The root considers children in insertion order. Each branch recursively runs its first valid child, so predicates should be fast, side-effect free, and ordered from most specific to fallback behavior. A negative leaf delay requests stop.

  • Constructor Details

    • TreeScript

      public TreeScript()
  • Method Details

    • addBranches

      protected final Root addBranches(Leaf... leaves)
      Appends top-level branches or leaves in selection order.
      Parameters:
      leaves - nodes to attach beneath the root
      Returns:
      the root for additional fluent registration
    • clear

      protected final void clear()
      Removes all nodes from the root.
    • getRoot

      public final Root getRoot()
      Returns the tree root.
      Returns:
      this tree's always-valid root
    • getCurrentBranchName

      public final String getCurrentBranchName()
      Returns the most recently selected branch label.
      Returns:
      simple class name of the most recently selected branch, or empty
    • getCurrentLeafName

      public final String getCurrentLeafName()
      Returns the most recently selected leaf label.
      Returns:
      simple class name of the most recently selected leaf, or empty
    • setCurrentBranchName

      public final void setCurrentBranchName(String value)
      Updates the diagnostic branch label.
      Parameters:
      value - diagnostic branch label; null clears it
    • setCurrentLeafName

      public final void setCurrentLeafName(String value)
      Updates the diagnostic leaf label.
      Parameters:
      value - diagnostic leaf label; null clears it
    • onLoop

      public final long onLoop(ScriptContext context)
      Evaluates one first-valid path through the tree.
      Specified by:
      onLoop in class AbstractScript
      Parameters:
      context - current script context exposed to attached leaves
      Returns:
      selected leaf delay; negative leaf results are converted into a stop request