Class NodeMap
- java.lang.Object
-
- com.vaadin.client.flow.nodefeature.NodeFeature
-
- com.vaadin.client.flow.nodefeature.NodeMap
-
- All Implemented Interfaces:
ReactiveValue
public class NodeMap extends NodeFeature implements ReactiveValue
A state node feature that structures data as a map.The feature works as a reactive value with regards to the set of available properties. A
Computationwill get a dependency on this feature by iterating the properties. Accessing a property by name does not create a dependency. TheComputationis invalidated when a property is added (properties are never removed). It is not invalidated when the value of a property changes since the property is a reactive values of its own.- Since:
- 1.0
- Author:
- Vaadin Ltd
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description elemental.events.EventRemoveraddPropertyAddListener(MapPropertyAddListener listener)Adds a listener that is informed whenever a new property is added to this map.elemental.events.EventRemoveraddReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener)Adds a listener that has a dependency to this value, and should be notified when this value changes.elemental.json.JsonValueconvert(Function<Object,elemental.json.JsonValue> converter)Convert the feature values into aJsonValueusing providedconverterfor the values stored in the feature (i.e.voidforEachProperty(JsMap.ForEachCallback<String,MapProperty> callback)Iterates all properties in this map.elemental.json.JsonValuegetDebugJson()Gets a JSON object representing the contents of this feature.MapPropertygetProperty(String name)Gets the property with a given name, creating it if necessary.JsArray<String>getPropertyNames()Gets all property names in this map.booleanhasPropertyValue(String name)Checks if the given property is present and has a value.-
Methods inherited from class com.vaadin.client.flow.nodefeature.NodeFeature
getAsDebugJson, getId, getNode
-
-
-
-
Constructor Detail
-
NodeMap
public NodeMap(int id, StateNode node)Creates a new map feature.- Parameters:
id- the id of the featurenode- the node of the feature
-
-
Method Detail
-
getProperty
public MapProperty getProperty(String name)
Gets the property with a given name, creating it if necessary.A
MapPropertyAddEventis fired if a new property instance is created.- Parameters:
name- the name of the property- Returns:
- the property instance
-
hasPropertyValue
public boolean hasPropertyValue(String name)
Checks if the given property is present and has a value.- Parameters:
name- the name of the property to check- Returns:
- true if the property exists and has a value, false otherwise
-
forEachProperty
public void forEachProperty(JsMap.ForEachCallback<String,MapProperty> callback)
Iterates all properties in this map.- Parameters:
callback- the callback to invoke for each property
-
getPropertyNames
public JsArray<String> getPropertyNames()
Gets all property names in this map.- Returns:
- a list with the property names, never
null
-
getDebugJson
public elemental.json.JsonValue getDebugJson()
Description copied from class:NodeFeatureGets a JSON object representing the contents of this feature. Only intended for debugging purposes.- Specified by:
getDebugJsonin classNodeFeature- Returns:
- a JSON representation
-
convert
public elemental.json.JsonValue convert(Function<Object,elemental.json.JsonValue> converter)
Description copied from class:NodeFeatureConvert the feature values into aJsonValueusing providedconverterfor the values stored in the feature (i.e. primitive types, StateNodes).- Specified by:
convertin classNodeFeature- Parameters:
converter- converter to convert values stored in the feature- Returns:
- resulting converted value
-
addReactiveValueChangeListener
public elemental.events.EventRemover addReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener)
Description copied from interface:ReactiveValueAdds a listener that has a dependency to this value, and should be notified when this value changes.- Specified by:
addReactiveValueChangeListenerin interfaceReactiveValue- Parameters:
reactiveValueChangeListener- the listener to add- Returns:
- an event remover that can be used for removing the added listener
-
addPropertyAddListener
public elemental.events.EventRemover addPropertyAddListener(MapPropertyAddListener listener)
Adds a listener that is informed whenever a new property is added to this map.- Parameters:
listener- the property add listener- Returns:
- an event remover that can be used for removing the added listener
-
-