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
public abstract class NodeMap extends NodeFeature
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:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidclear()Removes the values for all stored keys.voidcollectChanges(Consumer<NodeChange> collector)Collects all changes that are recorded for this feature.protected booleancontains(String key)Checks whether a value is stored for the given key.voidforEachChild(Consumer<StateNode> action)Passes each child node instance to the given consumer.voidgenerateChangesFromEmpty()Generates all changes that would be needed to take this node from its initial empty state to its current state.protected Serializableget(String key)Gets 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.protected Set<String>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 Serializableremove(String key)Removes 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 Detail
-
NodeMap
public NodeMap(StateNode node)
Creates a new map feature for the given node.- Parameters:
node- the node that the feature belongs to
-
-
Method Detail
-
put
protected void put(String key, Serializable value)
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
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.- 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
protected Serializable get(String key)
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
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.- 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
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.- 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
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.- 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
protected Set<String> keySet()
Gets the defined keys.- Returns:
- a set containing all the defined keys
-
contains
protected boolean contains(String key)
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
protected Serializable remove(String key)
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
public void collectChanges(Consumer<NodeChange> collector)
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
public void forEachChild(Consumer<StateNode> action)
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
public void updateFromClient(String key, Serializable value)
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
protected boolean mayUpdateFromClient(String key, Serializable value)
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
protected boolean producePutChange(String key, boolean hadValueEarlier, Serializable newValue)
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:
-
-