Package com.vaadin.client.flow
Class StateNode
java.lang.Object
com.vaadin.client.flow.StateNode
A client-side representation of a server-side state node.
- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionelemental.events.EventRemoveraddDomNodeSetListener(Function<StateNode, Boolean> listener) Adds a listener to get a notification when the DOM Node is set for thisStateNode.elemental.events.EventRemoveraddUnregisterListener(NodeUnregisterListener listener) Adds a listener that will be notified when this node is unregistered.<T> voidclearNodeData(T object) Removes theobjectfrom the stored data.voidforEachFeature(JsMap.ForEachCallback<Double, NodeFeature> callback) Iterates all features in this node.elemental.json.JsonObjectGets a JSON object representing the contents of this node.elemental.dom.NodeGets the DOM node associated with this state node.intgetId()Gets the id of this state node.getList(int id) Gets the node list with the given id.getMap(int id) Gets the node map with the given id.<T> TgetNodeData(Class<T> clazz) Gets the object previously stored by thesetNodeData(Object)by its type.Get the parentStateNodeif set.getTree()Gets the state tree that this node belongs to.booleanhasFeature(int id) Checks whether this node has a feature with the given id.booleanChecks whether this node has been unregistered.voidsetDomNode(elemental.dom.Node node) Sets the DOM node associated with this state node.<T> voidsetNodeData(T object) Stores theobjectin theStateNodeinstance.voidSet the parentStateNodefor this node.voidUnregisters this node, causing all registered node unregister listeners to be notified.
-
Constructor Details
-
StateNode
Creates a new state node.- Parameters:
id- the id of the nodetree- the state tree that the node belongs to
-
-
Method Details
-
getTree
Gets the state tree that this node belongs to.- Returns:
- the state tree
-
getId
public int getId()Gets the id of this state node.- Returns:
- the id
-
getList
Gets the node list with the given id. Creates a new node list if one doesn't already exist.- Parameters:
id- the id of the list- Returns:
- the list with the given id
-
getMap
Gets the node map with the given id. Creates a new map if one doesn't already exist.- Parameters:
id- the id of the map- Returns:
- the map with the given id
-
hasFeature
public boolean hasFeature(int id) Checks whether this node has a feature with the given id.- Parameters:
id- the id of the feature- Returns:
trueif this node has the given feature; otherwisefalse
-
forEachFeature
Iterates all features in this node.- Parameters:
callback- the callback to invoke for each feature
-
getDebugJson
public elemental.json.JsonObject getDebugJson()Gets a JSON object representing the contents of this node. Only intended for debugging purposes.- Returns:
- a JSON representation
-
isUnregistered
public boolean isUnregistered()Checks whether this node has been unregistered.- Returns:
trueif this node has been unregistered;falseif the node is still registered- See Also:
-
unregister
public void unregister()Unregisters this node, causing all registered node unregister listeners to be notified.- See Also:
-
addUnregisterListener
Adds a listener that will be notified when this node is unregistered.- Parameters:
listener- the node unregister listener to add- Returns:
- an event remover that can be used for removing the added listener
-
getDomNode
public elemental.dom.Node getDomNode()Gets the DOM node associated with this state node.- Returns:
- the DOM node, or
nullif no DOM node has been associated with this state node
-
setDomNode
public void setDomNode(elemental.dom.Node node) Sets the DOM node associated with this state node.- Parameters:
node- the associated DOM node
-
addDomNodeSetListener
Adds a listener to get a notification when the DOM Node is set for thisStateNode.The listener return value is used to decide whether the listener should be removed immediately if it returns
true.- Parameters:
listener- listener to add- Returns:
- an event remover that can be used for removing the added listener
-
getParent
Get the parentStateNodeif set.- Returns:
- parent state node
-
setParent
Set the parentStateNodefor this node.- Parameters:
parent- the parent state node
-
setNodeData
public <T> void setNodeData(T object) Stores theobjectin theStateNodeinstance.The
objectmay represent any kind of data. This data can be retrieved later on via thegetNodeData(Class)providing the class of the object. So make sure you are using some custom type for your data to avoid clash with other types.- Type Parameters:
T- the type of the node data to set- Parameters:
object- the object to store- See Also:
-
getNodeData
Gets the object previously stored by thesetNodeData(Object)by its type.If there is no stored object with the given type then the method returns
null.- Type Parameters:
T- the type of the node data to get- Parameters:
clazz- the type of the object to get- Returns:
- the object by its
clazz
-
clearNodeData
public <T> void clearNodeData(T object) Removes theobjectfrom the stored data.- Type Parameters:
T- the type of the object to remove- Parameters:
object- the object to remove
-