Package com.valhalla.sdk.tasks.tree
Class TreeScript
java.lang.Object
com.valhalla.sdk.AbstractScript
com.valhalla.sdk.tasks.tree.TreeScript
- All Implemented Interfaces:
Sleepable
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final RootaddBranches(Leaf... leaves) Appends top-level branches or leaves in selection order.protected final voidclear()Removes all nodes from the root.final StringReturns the most recently selected branch label.final StringReturns the most recently selected leaf label.final RootgetRoot()Returns the tree root.final longonLoop(ScriptContext context) Evaluates one first-valid path through the tree.final voidsetCurrentBranchName(String value) Updates the diagnostic branch label.final voidsetCurrentLeafName(String value) Updates the diagnostic leaf label.Methods inherited from class com.valhalla.sdk.AbstractScript
isStopRequested, onStart, onStop, requestStop, shouldStop, stopMethods 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
-
TreeScript
public TreeScript()
-
-
Method Details
-
addBranches
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
Returns the tree root.- Returns:
- this tree's always-valid root
-
getCurrentBranchName
Returns the most recently selected branch label.- Returns:
- simple class name of the most recently selected branch, or empty
-
getCurrentLeafName
Returns the most recently selected leaf label.- Returns:
- simple class name of the most recently selected leaf, or empty
-
setCurrentBranchName
Updates the diagnostic branch label.- Parameters:
value- diagnostic branch label;nullclears it
-
setCurrentLeafName
Updates the diagnostic leaf label.- Parameters:
value- diagnostic leaf label;nullclears it
-
onLoop
Evaluates one first-valid path through the tree.- Specified by:
onLoopin classAbstractScript- Parameters:
context- current script context exposed to attached leaves- Returns:
- selected leaf delay; negative leaf results are converted into a stop request
-