public abstract class NodeFeature extends Object implements Serializable
Constructor and Description |
---|
NodeFeature(StateNode node)
Creates a new feature for the given node.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allowsChanges()
Returns
true if the underlying node may report its changes. |
protected void |
attachPotentialChild(Object child)
Attaches an object if it is a
StateNode . |
abstract void |
collectChanges(Consumer<NodeChange> collector)
Collects all changes that are recorded for this feature.
|
protected void |
detatchPotentialChild(Object child)
Detaches an object if it is a
StateNode . |
abstract void |
forEachChild(Consumer<StateNode> action)
Passes each child node instance to the given consumer.
|
abstract void |
generateChangesFromEmpty()
Generates all changes that would be needed to take this node from its
initial empty state to its current state.
|
StateNode |
getNode()
Gets the node that this feature belongs to.
|
void |
onAttach(boolean initialAttach)
Called when the state node has been attached to the state tree.
|
void |
onDetach()
Called when the state node has been detached from the state tree.
|
public NodeFeature(StateNode node)
node
- the node which supports the featurepublic StateNode getNode()
public abstract void collectChanges(Consumer<NodeChange> collector)
collector
- a consumer accepting node changespublic abstract void generateChangesFromEmpty()
protected void attachPotentialChild(Object child)
StateNode
.child
- the instance to maybe attachprotected void detatchPotentialChild(Object child)
StateNode
.child
- the instance to maybe detachpublic abstract void forEachChild(Consumer<StateNode> action)
action
- the consumer that accepts each childpublic void onAttach(boolean initialAttach)
initialAttach
- true
if this is the first time the node is
attached to a StateTree
, false
otherwisepublic void onDetach()
public boolean allowsChanges()
true
if the underlying node may report its changes.
If its return value is false
then this node should be considered
as "inactive" and should not send any changes to the client side at all
or only changes for features that disallow the changes.
Normally features don't control the node behavior so the default
implementation returns true
. The feature which wants to control
the node behavior should override this method.
true
if the feature allows changes for the node,
false
otherwiseStateNode.updateActiveState()
Copyright © 2019. All rights reserved.