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:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclear()Removes the values for all stored keys.voidcollectChanges(Consumer<NodeChange> collector) Collects all changes that are recorded for this feature.protected booleanChecks whether a value is stored for the given key.voidforEachChild(Consumer<StateNode> action) Passes each child node instance to the given consumer.voidGenerates all changes that would be needed to take this node from its initial empty state to its current state.protected SerializableGets the value corresponding to the given key.protected booleangetOrDefault(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 intgetOrDefault(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 StringgetOrDefault(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 booleanmayUpdateFromClient(String key, Serializable value) Checks whether the client is allowed to store the given value with the given key.protected booleanproducePutChange(String key, boolean hadValueEarlier, Serializable newValue) Checks whether aMapPutChangeshould be produced.protected voidput(String key, Serializable value) Stores a value with the given key, replacing any value previously stored with the same key.protected Serializableput(String key, Serializable value, boolean emitChange) Stores a value with the given key, replacing any value previously stored with the same key.protected SerializableRemoves the value stored for the given key.voidupdateFromClient(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
nullif 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;
nullif there is no value stored, or ifnullis 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
defaultValueif 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
defaultValueif 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
defaultValueif 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:
trueif there is a value stored;falseif 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,
nullif no value was removed
-
clear
protected void clear()Removes the values for all stored keys. -
collectChanges
Description copied from class:NodeFeatureCollects all changes that are recorded for this feature.- Specified by:
collectChangesin classNodeFeature- Parameters:
collector- a consumer accepting node changes
-
generateChangesFromEmpty
public void generateChangesFromEmpty()Description copied from class:NodeFeatureGenerates all changes that would be needed to take this node from its initial empty state to its current state.- Specified by:
generateChangesFromEmptyin classNodeFeature
-
forEachChild
Description copied from class:NodeFeaturePasses each child node instance to the given consumer.- Specified by:
forEachChildin 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 returnsfalseby default.- Parameters:
key- the key to usevalue- the value to store- Returns:
trueif the value update is accepted,falseif the value should not be allowed to be updated
-
producePutChange
Checks whether aMapPutChangeshould 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:
trueif a change should be produced,falseotherwise
-