public class MapProperty extends Object implements ReactiveValue
| Constructor and Description |
|---|
MapProperty(String name,
NodeMap map)
Creates a new property.
|
| Modifier and Type | Method and Description |
|---|---|
elemental.events.EventRemover |
addChangeListener(MapPropertyChangeListener listener)
Adds a listener that gets notified when the value of this property
changes.
|
elemental.events.EventRemover |
addReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener)
Adds a listener that has a dependency to this value, and should be
notified when this value changes.
|
NodeMap |
getMap()
Gets the map that this property belongs to.
|
String |
getName()
Gets the name of this property.
|
Runnable |
getSyncToServerCommand(Object newValue)
Sets the value of this property and returns a synch to server command.
|
Object |
getValue()
Gets the property value.
|
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.
|
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.
|
String |
getValueOrDefault(String defaultValue)
Returns the value, or the given defaultValue if the property does not
have a value or the property value is null.
|
boolean |
hasValue()
Checks whether this property has a value.
|
void |
removeValue()
Removes the value of this property so that
hasValue() will
return false and getValue() will return
null until the next time setValue(Object) is run. |
void |
setValue(Object value)
Sets the property value.
|
void |
syncToServer(Object newValue)
Sets the value of this property and synchronizes the value to the server.
|
public String getName()
public NodeMap getMap()
public Object getValue()
public boolean hasValue()
setValue(Object) has been invoked after the property was created
or removeValue() was invoked.true if the property has a value, false
if the property has no value.removeValue()public void setValue(Object value)
MapPropertyChangeEvent.value - the new property valueaddChangeListener(MapPropertyChangeListener)public void removeValue()
hasValue() will
return false and getValue() will return
null until the next time setValue(Object) is run. A
MapPropertyChangeEvent will 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 assigning null as the value.
public elemental.events.EventRemover addChangeListener(MapPropertyChangeListener listener)
listener - the property change listener to addpublic elemental.events.EventRemover addReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener)
ReactiveValueaddReactiveValueChangeListener in interface ReactiveValuereactiveValueChangeListener - the listener to addpublic int getValueOrDefault(int defaultValue)
defaultValue - the default valuepublic boolean getValueOrDefault(boolean defaultValue)
defaultValue - the default valuepublic String getValueOrDefault(String defaultValue)
defaultValue - the default valuepublic void syncToServer(Object newValue)
newValue - the new value to set.getSyncToServerCommand(Object)public Runnable getSyncToServerCommand(Object newValue)
newValue - the new value to set.syncToServer(Object)Copyright © 2000–2020 Vaadin Ltd. All rights reserved.