Class NodeFeature
java.lang.Object
com.vaadin.flow.internal.nodefeature.NodeFeature
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
NodeList,NodeMap,NodeValue,ServerSideFeature
A node feature represents a group of related values and functionality in a
state node.
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif the underlying node may report its changes.protected voidattachPotentialChild(Object child) Attaches an object if it is aStateNode.abstract voidcollectChanges(Consumer<NodeChange> collector) Collects all changes that are recorded for this feature.protected voiddetatchPotentialChild(Object child) Detaches an object if it is aStateNode.abstract voidforEachChild(Consumer<StateNode> action) Passes each child node instance to the given consumer.abstract voidGenerates all changes that would be needed to take this node from its initial empty state to its current state.getNode()Gets the node that this feature belongs to.voidonAttach(boolean initialAttach) Called when the state node has been attached to the state tree.voidonDetach()Called when the state node has been detached from the state tree.
-
Constructor Details
-
NodeFeature
Creates a new feature for the given node.- Parameters:
node- the node which supports the feature
-
-
Method Details
-
getNode
Gets the node that this feature belongs to.- Returns:
- the node
-
collectChanges
Collects all changes that are recorded for this feature.- Parameters:
collector- a consumer accepting node changes
-
generateChangesFromEmpty
public abstract void generateChangesFromEmpty()Generates all changes that would be needed to take this node from its initial empty state to its current state. -
attachPotentialChild
Attaches an object if it is aStateNode.- Parameters:
child- the instance to maybe attach
-
detatchPotentialChild
Detaches an object if it is aStateNode.- Parameters:
child- the instance to maybe detach
-
forEachChild
Passes each child node instance to the given consumer.- Parameters:
action- the consumer that accepts each child
-
onAttach
public void onAttach(boolean initialAttach) Called when the state node has been attached to the state tree.- Parameters:
initialAttach-trueif this is the first time the node is attached to aStateTree,falseotherwise
-
onDetach
public void onDetach()Called when the state node has been detached from the state tree. -
allowsChanges
public boolean allowsChanges()Returnstrueif the underlying node may report its changes.If its return value is
falsethen 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.- Returns:
trueif the feature allows changes for the node,falseotherwise- See Also:
-