Class Leaf

java.lang.Object
com.valhalla.sdk.tasks.tree.Leaf
All Implemented Interfaces:
Sleepable
Direct Known Subclasses:
Branch

public abstract class Leaf extends Object implements Sleepable
Executable decision-tree node with access to its attached TreeScript.
  • Constructor Details

    • Leaf

      public Leaf()
  • Method Details

    • isValid

      public abstract boolean isValid()
      Tests whether this node is eligible for selection.
      Returns:
      true when this node should be selected in the current tree state
    • onLoop

      public abstract long onLoop()
      Executes one unit of leaf work.
      Returns:
      requested delay after one bounded unit of work; negative requests stop
    • getParent

      public final Branch getParent()
      Returns this node's parent.
      Returns:
      parent branch, or null while detached
    • setParent

      public void setParent(Branch value)
      Attaches or detaches this node.
      Parameters:
      value - parent branch, or null to detach
    • getTree

      public TreeScript getTree()
      Returns the owning tree.
      Returns:
      owning tree, or null while detached
    • getContext

      protected final ScriptContext getContext()
      Returns the context for the current tree loop.
      Returns:
      current script context
      Throws:
      IllegalStateException - when detached or evaluated outside a running tree loop