Class ElementPropertyMap

All Implemented Interfaces:
Serializable

public class ElementPropertyMap extends AbstractPropertyMap
Map for element property values.

For internal use only. May be renamed or removed in a future release.

Since:
1.0
Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • ElementPropertyMap

      public ElementPropertyMap(StateNode node)
      Creates a new element property map for the given node.
      Parameters:
      node - the node that the map belongs to
  • Method Details

    • deferredUpdateFromClient

      public Runnable deferredUpdateFromClient(String key, Serializable value) throws PropertyChangeDeniedException
      Updates a property value from the client and returns a Runnable for firing the associated PropertyChangeEvent.
      Parameters:
      key - the key to use
      value - the value to store
      Returns:
      a runnable for firing the deferred change event
      Throws:
      PropertyChangeDeniedException - if the property change is disallowed
    • setProperty

      public void setProperty(String name, Serializable value, boolean emitChange)
      Description copied from class: AbstractPropertyMap
      Sets a property to the given value.
      Overrides:
      setProperty in class AbstractPropertyMap
      Parameters:
      name - the property name
      value - the value, must be a string, a boolean, a double or null
      emitChange - true to create a change event for the client side
    • setProperty

      public void setProperty(String name, Serializable value)
      Sets a property to the given value.
      Parameters:
      name - the property name
      value - the value, must be a string, a boolean, a double or null
      See Also:
    • addPropertyChangeListener

      public Registration addPropertyChangeListener(String name, PropertyChangeListener listener)
      Adds a property change listener.
      Parameters:
      name - the property name to add the listener for
      listener - listener to get notifications about property value changes
      Returns:
      an event registration handle for removing the listener
    • put

      protected Serializable put(String key, Serializable value, boolean emitChange)
      Description copied from class: NodeMap
      Stores a value with the given key, replacing any value previously stored with the same key.
      Overrides:
      put in class NodeMap
      Parameters:
      key - the key to use
      value - the value to store
      emitChange - true to create a change event for the client side
      Returns:
      the previous value, or null if there was no previous value
    • remove

      protected Serializable remove(String key)
      Description copied from class: NodeMap
      Removes the value stored for the given key.
      Overrides:
      remove in class NodeMap
      Parameters:
      key - the key for which to remove the value
      Returns:
      the removed value, null if no value was removed
    • mayUpdateFromClient

      protected boolean mayUpdateFromClient(String key, Serializable value)
      Description copied from class: NodeMap
      Checks whether the client is allowed to store the given value with the given key. Always returns false by default.
      Overrides:
      mayUpdateFromClient in class NodeMap
      Parameters:
      key - the key to use
      value - the value to store
      Returns:
      true if the value update is accepted, false if the value should not be allowed to be updated
    • producePutChange

      protected boolean producePutChange(String key, boolean hadValueEarlier, Serializable newValue)
      Description copied from class: NodeMap
      Checks whether a MapPutChange should be produced.
      Overrides:
      producePutChange in class NodeMap
      Parameters:
      key - a key to produce a change
      hadValueEarlier - whether the value was already earlier in the map
      newValue - the new value for the key
      Returns:
    • setUpdateFromClientFilter

      public void setUpdateFromClientFilter(SerializablePredicate<String> updateFromClientFilter)
      Sets a filter that will be used by for determining whether a property maybe updated from the client. The filter is recursively inherited to child model properties.
      Parameters:
      updateFromClientFilter - the filter to set, or null to remove the current filter
    • resolveModelMap

      public ElementPropertyMap resolveModelMap(String modelPath)
      Resolves the ElementPropertyMap that the model path refers to.

      If the model path contains separate dot separated parts, any non-existing part will be created during resolving.

      Parameters:
      modelPath - the path to resolve, either a single property name or a dot separated path
      Returns:
      the resolved model map
    • resolveModelList

      public ModelList resolveModelList(String modelPath)
      Resolves the ModelList that the model path refers to.

      If the model path contains separate dot separated parts, any non-existing part will be created during resolving.

      Parameters:
      modelPath - the path to resolve, either a single property name or a dot separated path
      Returns:
      the resolved model list
    • getModel

      public static ElementPropertyMap getModel(StateNode node)
      Gets the model map for the given node.

      Throws an exception if the node does not have a model map.

      Parameters:
      node - the node which has a model map
      Returns:
      the model map for the node