Class CheckBehavior
BindableTreeNode trees.
The four building-block methods form an ordered pipeline:
propagateDown(BindableTreeNode, Set)—PROPAGATEdownward propagation (reads old node states)applyCheckedSet(BindableTreeNode, Set)— seedCHECKED/UNCHECKEDon every nodederiveBehaviorStates(BindableTreeNode)— deriveINDETERMINATEbottom-upcollectChecked(BindableTreeNode)— collect the finalCHECKEDset
Two convenience methods compose common subsets of this pipeline:
applyFromRawChecked(BindableTreeNode, Set)— full pipeline (steps 1–4), for user interactionseedAndDerive(BindableTreeNode, Set)— steps 2–3, for programmatic updates
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidapplyCheckedSet(BindableTreeNode<T> node, Set<BindableTreeNode<T>> checked) SeedsBindableTreeNode.CheckBoxState.CHECKEDorBindableTreeNode.CheckBoxState.UNCHECKEDonto every node in the subtree rooted atnodebased on membership inchecked.static <T> Set<BindableTreeNode<T>> applyFromRawChecked(BindableTreeNode<T> root, Set<BindableTreeNode<T>> rawChecked) Full derivation pipeline for user interaction: propagatesPROPAGATEdownward, seedsCHECKED/UNCHECKEDon all nodes, derivesINDETERMINATEbottom-up, and returns the final set ofCHECKEDnodes.static <T> Set<BindableTreeNode<T>> collectChecked(BindableTreeNode<T> root) Returns a new set containing all nodes whoseBindableTreeNode.CheckBoxStateisCHECKED.static <T> voidderiveBehaviorStates(BindableTreeNode<T> node) Derives the state ofBindableTreeNode.CheckBoxBehavior.PROPAGATEandBindableTreeNode.CheckBoxBehavior.PROPAGATE_UP_ONLYnodes bottom-up from their children, writing results directly into each node'sBindableTreeNode.CheckBoxState.static <T> voidpropagateDown(BindableTreeNode<T> node, Set<BindableTreeNode<T>> current) Propagates check state downward forBindableTreeNode.CheckBoxBehavior.PROPAGATEnodes.static <T> voidseedAndDerive(BindableTreeNode<T> root, Set<BindableTreeNode<T>> checkedSet) Seeds CHECKED/UNCHECKED on all nodes based on set membership, then derives INDETERMINATE bottom-up.
-
Constructor Details
-
CheckBehavior
public CheckBehavior()
-
-
Method Details
-
propagateDown
Propagates check state downward forBindableTreeNode.CheckBoxBehavior.PROPAGATEnodes. If aPROPAGATEnode is newly checked (present incurrentbut was not previouslyBindableTreeNode.CheckBoxState.CHECKED), all its descendants are added tocurrent. If newly unchecked, all descendants are removed.PROPAGATE_UP_ONLYandDEFAULTnodes are skipped.Ordering contract: must be called before
applyCheckedSet(BindableTreeNode, Set)so that each node'scheckBoxStatestill reflects the previous state when this method reads it. -
applyCheckedSet
SeedsBindableTreeNode.CheckBoxState.CHECKEDorBindableTreeNode.CheckBoxState.UNCHECKEDonto every node in the subtree rooted atnodebased on membership inchecked. NoBindableTreeNode.CheckBoxState.INDETERMINATEis assigned here — that is computed byderiveBehaviorStates(BindableTreeNode)afterward.Must be called after
propagateDown(BindableTreeNode, Set)and beforederiveBehaviorStates(BindableTreeNode). -
deriveBehaviorStates
Derives the state ofBindableTreeNode.CheckBoxBehavior.PROPAGATEandBindableTreeNode.CheckBoxBehavior.PROPAGATE_UP_ONLYnodes bottom-up from their children, writing results directly into each node'sBindableTreeNode.CheckBoxState.PROPAGATE: all children checked →
CHECKED; any child checked or indeterminate →INDETERMINATE; none →UNCHECKED.PROPAGATE_UP_ONLY: if already
CHECKED→ staysCHECKED; else if any child isCHECKEDorINDETERMINATE→INDETERMINATE; elseUNCHECKED. Never auto-promoted toCHECKED.Must be called after
applyCheckedSet(BindableTreeNode, Set)so that leaf states are already seeded. -
collectChecked
Returns a new set containing all nodes whoseBindableTreeNode.CheckBoxStateisCHECKED. -
applyFromRawChecked
public static <T> Set<BindableTreeNode<T>> applyFromRawChecked(BindableTreeNode<T> root, Set<BindableTreeNode<T>> rawChecked) Full derivation pipeline for user interaction: propagatesPROPAGATEdownward, seedsCHECKED/UNCHECKEDon all nodes, derivesINDETERMINATEbottom-up, and returns the final set ofCHECKEDnodes.- Parameters:
root- the tree rootrawChecked- checked nodes before derivation is applied; this set is mutated- Returns:
- the set of nodes whose state is
CHECKEDafter derivation
-
seedAndDerive
Seeds CHECKED/UNCHECKED on all nodes based on set membership, then derives INDETERMINATE bottom-up. Use for programmatic updates and lazy-load paths where node states need to be initialized from a known checked set.- Parameters:
root- the tree rootcheckedSet- the set of nodes that should be CHECKED
-