Class NodeMap
java.lang.Object
com.vaadin.flow.internal.nodefeature.NodeFeature
com.vaadin.flow.internal.nodefeature.NodeMap
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AbstractPropertyMap
,ElementAttributeMap
,ElementData
,ElementListenerMap
,LoadingIndicatorConfigurationMap
,PollConfigurationMap
,PolymerEventListenerMap
,PushConfigurationMap
,PushConfigurationMap.PushConfigurationParametersMap
,ReconnectDialogConfigurationMap
A state node feature that structures data as a map.
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
clear()
Removes the values for all stored keys.void
collectChanges
(Consumer<NodeChange> collector) Collects all changes that are recorded for this feature.protected boolean
Checks whether a value is stored for the given key.void
forEachChild
(Consumer<StateNode> action) Passes each child node instance to the given consumer.void
Generates all changes that would be needed to take this node from its initial empty state to its current state.protected Serializable
Gets the value corresponding to the given key.protected boolean
getOrDefault
(String key, boolean defaultValue) Gets the value corresponding to the given key, or the given default value if no value is stored for the given key or the value is null.protected int
getOrDefault
(String key, int defaultValue) Gets the value corresponding to the given key, or the given default value if no value is stored for the given key or the value is null.protected String
getOrDefault
(String key, String defaultValue) Gets the value corresponding to the given key, or the given default value if no value is stored for the given key or the value is null.keySet()
Gets the defined keys.protected boolean
mayUpdateFromClient
(String key, Serializable value) Checks whether the client is allowed to store the given value with the given key.protected boolean
producePutChange
(String key, boolean hadValueEarlier, Serializable newValue) Checks whether aMapPutChange
should be produced.protected void
put
(String key, Serializable value) Stores a value with the given key, replacing any value previously stored with the same key.protected Serializable
put
(String key, Serializable value, boolean emitChange) Stores a value with the given key, replacing any value previously stored with the same key.protected Serializable
Removes the value stored for the given key.void
updateFromClient
(String key, Serializable value) Receives a value update from the client.Methods inherited from class com.vaadin.flow.internal.nodefeature.NodeFeature
allowsChanges, attachPotentialChild, detatchPotentialChild, getNode, onAttach, onDetach
-
Constructor Details
-
NodeMap
Creates a new map feature for the given node.- Parameters:
node
- the node that the feature belongs to
-
-
Method Details
-
put
Stores a value with the given key, replacing any value previously stored with the same key.- Parameters:
key
- the key to usevalue
- the value to store
-
put
Stores a value with the given key, replacing any value previously stored with the same key.- Parameters:
key
- the key to usevalue
- the value to storeemitChange
- true to create a change event for the client side- Returns:
- the previous value, or
null
if there was no previous value
-
get
Gets the value corresponding to the given key.- Parameters:
key
- the key to get a value for- Returns:
- the value corresponding to the key;
null
if there is no value stored, or ifnull
is stored as a value
-
getOrDefault
Gets the value corresponding to the given key, or the given default value if no value is stored for the given key or the value is null.- Parameters:
key
- the key to get a value fordefaultValue
- the value to return if no value is stored for the given key- Returns:
- the value corresponding to the key or the given
defaultValue
if no value is stored for the key or the stored value is null
-
getOrDefault
Gets the value corresponding to the given key, or the given default value if no value is stored for the given key or the value is null.- Parameters:
key
- the key to get a value fordefaultValue
- the value to return if no value is stored for the given key- Returns:
- the value corresponding to the key or the given
defaultValue
if no value is stored for the key or the stored value is null
-
getOrDefault
Gets the value corresponding to the given key, or the given default value if no value is stored for the given key or the value is null.- Parameters:
key
- the key to get a value fordefaultValue
- the value to return if no value is stored for the given key- Returns:
- the value corresponding to the key or the given
defaultValue
if no value is stored for the key or the stored value is null
-
keySet
Gets the defined keys.- Returns:
- a set containing all the defined keys
-
contains
Checks whether a value is stored for the given key.- Parameters:
key
- the key to check- Returns:
true
if there is a value stored;false
if no value is stored
-
remove
Removes the value stored for the given key.- Parameters:
key
- the key for which to remove the value- Returns:
- the removed value,
null
if no value was removed
-
clear
protected void clear()Removes the values for all stored keys. -
collectChanges
Description copied from class:NodeFeature
Collects all changes that are recorded for this feature.- Specified by:
collectChanges
in classNodeFeature
- Parameters:
collector
- a consumer accepting node changes
-
generateChangesFromEmpty
public void generateChangesFromEmpty()Description copied from class:NodeFeature
Generates all changes that would be needed to take this node from its initial empty state to its current state.- Specified by:
generateChangesFromEmpty
in classNodeFeature
-
forEachChild
Description copied from class:NodeFeature
Passes each child node instance to the given consumer.- Specified by:
forEachChild
in classNodeFeature
- Parameters:
action
- the consumer that accepts each child
-
updateFromClient
Receives a value update from the client. The map value is updated without creating a change record since the client already knows the current value. The value is only updated ifmayUpdateFromClient(String, Serializable)
has been overridden to accept the value.- Parameters:
key
- the key to usevalue
- the value to store
-
mayUpdateFromClient
Checks whether the client is allowed to store the given value with the given key. Always returnsfalse
by default.- Parameters:
key
- the key to usevalue
- the value to store- Returns:
true
if the value update is accepted,false
if the value should not be allowed to be updated
-
producePutChange
Checks whether aMapPutChange
should be produced.- Parameters:
key
- a key to produce a changehadValueEarlier
- whether the value was already earlier in the mapnewValue
- the new value for thekey
- Returns:
-