Class MapProperty
java.lang.Object
com.vaadin.client.flow.nodefeature.MapProperty
- All Implemented Interfaces:
ReactiveValue
A property in a node map.
- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMapProperty(String name, NodeMap map) Creates a new property.MapProperty(String name, NodeMap map, boolean forceValueUpdate) Creates a new property. -
Method Summary
Modifier and TypeMethodDescriptionelemental.events.EventRemoveraddChangeListener(MapPropertyChangeListener listener) Adds a listener that gets notified when the value of this property changes.elemental.events.EventRemoveraddReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener) Adds a listener that has a dependency to this value, and should be notified when this value changes.voidClears the previous DOM value of this property.getMap()Gets the map that this property belongs to.getName()Gets the name of this property.Returns previous DOM value of this property for detection of value modification by the user during the server round-trip.getSyncToServerCommand(Object newValue) Sets the value of this property and returns a synch to server command.getValue()Gets the property value.booleangetValueOrDefault(boolean defaultValue) Returns the value, or the given defaultValue if the property does not have a value or the property value is null.intgetValueOrDefault(int defaultValue) Returns the value, or the given defaultValue if the property does not have a value or the property value is null.getValueOrDefault(String defaultValue) Returns the value, or the given defaultValue if the property does not have a value or the property value is null.booleanhasValue()Checks whether this property has a value.voidRemoves the value of this property so thathasValue()will returnfalseandgetValue()will returnnulluntil the next timesetValue(Object)is run.voidsetPreviousDomValue(Object previousDomValue) Stores previous DOM value of this property for detection of value modification by the user during the server round-trip.voidSets the property value.voidsyncToServer(Object newValue) Sets the value of this property and synchronizes the value to the server.
-
Field Details
-
NO_OP
-
-
Constructor Details
-
MapProperty
Creates a new property.- Parameters:
name- the name of the propertymap- the map that the property belongs to
-
MapProperty
Creates a new property.- Parameters:
name- the name of the propertymap- the map that the property belongs toforceValueUpdate- whether value update fornameproperty should be applied regardless of previous value
-
-
Method Details
-
getName
Gets the name of this property.- Returns:
- the property name
-
getMap
Gets the map that this property belongs to.- Returns:
- the map
-
getValue
Gets the property value.- Returns:
- the property value
-
hasValue
public boolean hasValue()Checks whether this property has a value. A property has a value ifsetValue(Object)has been invoked after the property was created orremoveValue()was invoked.- Returns:
trueif the property has a value,falseif the property has no value.- See Also:
-
setValue
Sets the property value. Changing the value fires aMapPropertyChangeEvent.- Parameters:
value- the new property value- See Also:
-
removeValue
public void removeValue()Removes the value of this property so thathasValue()will returnfalseandgetValue()will returnnulluntil the next timesetValue(Object)is run. AMapPropertyChangeEventwill be fired if this property has a value.Once a property has been created, it can no longer be removed from its map. The same semantics as e.g.
Map.remove(Object)is instead provided by marking the value of the property as removed to distinguish it from assigningnullas the value. -
addChangeListener
Adds a listener that gets notified when the value of this property changes.- Parameters:
listener- the property change listener to add- Returns:
- an event remover for unregistering the listener
-
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
-
getValueOrDefault
public int getValueOrDefault(int defaultValue) Returns the value, or the given defaultValue if the property does not have a value or the property value is null.- Parameters:
defaultValue- the default value- Returns:
- the value of the property or the default value if the property does not have a value or the property value is null
-
getValueOrDefault
public boolean getValueOrDefault(boolean defaultValue) Returns the value, or the given defaultValue if the property does not have a value or the property value is null.- Parameters:
defaultValue- the default value- Returns:
- the value of the property or the default value if the property does not have a value or the property value is null
-
getValueOrDefault
Returns the value, or the given defaultValue if the property does not have a value or the property value is null.- Parameters:
defaultValue- the default value- Returns:
- the value of the property or the default value if the property does not have a value or the property value is null
-
syncToServer
Sets the value of this property and synchronizes the value to the server.- Parameters:
newValue- the new value to set.- See Also:
-
getSyncToServerCommand
Sets the value of this property and returns a synch to server command.- Parameters:
newValue- the new value to set.- Returns:
- a command that synchronizes the value to the server
- See Also:
-
setPreviousDomValue
Stores previous DOM value of this property for detection of value modification by the user during the server round-trip.- Parameters:
previousDomValue- DOM value of property prior to server round-trip start. Can benull;
-
getPreviousDomValue
Returns previous DOM value of this property for detection of value modification by the user during the server round-trip.- Returns:
- Optional of previous DOM value. Empty optional is returned if previous value has not been stored.
-
clearPreviousDomValue
public void clearPreviousDomValue()Clears the previous DOM value of this property.
-