Package com.valhalla.sdk.tasks.tree
Class Leaf
java.lang.Object
com.valhalla.sdk.tasks.tree.Leaf
- All Implemented Interfaces:
Sleepable
- Direct Known Subclasses:
Branch
Executable decision-tree node with access to its attached
TreeScript.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final ScriptContextReturns the context for the current tree loop.final BranchReturns this node's parent.getTree()Returns the owning tree.abstract booleanisValid()Tests whether this node is eligible for selection.abstract longonLoop()Executes one unit of leaf work.voidAttaches or detaches this node.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.valhalla.sdk.api.util.Sleepable
sleep, sleep, sleepUntil, sleepUntil, sleepUntil, sleepWhile, sleepWhile, sleepWhile
-
Constructor Details
-
Leaf
public Leaf()
-
-
Method Details
-
isValid
public abstract boolean isValid()Tests whether this node is eligible for selection.- Returns:
truewhen 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
Returns this node's parent.- Returns:
- parent branch, or
nullwhile detached
-
setParent
Attaches or detaches this node.- Parameters:
value- parent branch, ornullto detach
-
getTree
Returns the owning tree.- Returns:
- owning tree, or
nullwhile detached
-
getContext
Returns the context for the current tree loop.- Returns:
- current script context
- Throws:
IllegalStateException- when detached or evaluated outside a running tree loop
-