Package: groovy.util

## [Java] Class ObservableMap

- groovy.util.ObservableMap

- All Implemented Interfaces and Traits:
    Map

      public class ObservableMap
      extends Object

  Map decorator that will trigger PropertyChangeEvents when a value changes.
  An optional Closure may be specified and will work as a filter, if it returns true the property will trigger an event (if the value indeed changed), otherwise it won't. The Closure may receive 1 or 2 parameters, the single one being the value, the other one both the key and value, for example:

       // skip all properties whose value is a closure
       def map = new ObservableMap( {!(it instanceof Closure)} )

       // skip all properties whose name matches a regex
       def map = new ObservableMap( { name, value -> !(name =~ /[A-Z+]/) } )

  The current implementation will trigger specialized events in the following scenarios, you need not register a different listener as those events extend from PropertyChangeEvent
  - ObservableMap.PropertyAddedEvent - a new property is added to the map
  - ObservableMap.PropertyRemovedEvent - a property is removed from the map
  - ObservableMap.PropertyUpdatedEvent - a property changes value (same as regular PropertyChangeEvent)
  - ObservableMap.PropertyClearedEvent - all properties have been removed from the map
  - ObservableMap.MultiPropertyEvent - triggered by calling map.putAll(), contains Added|Updated events

  Bound properties

  - `content` - read-only.
  - `size` - read-only.

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `enum` | `ObservableMap.ChangeType` |
    `static class` | `ObservableMap.MultiPropertyEvent` |
    `static class` | `ObservableMap.PropertyAddedEvent` |
    `static class` | `ObservableMap.PropertyClearedEvent` |
    `static class` | `ObservableMap.PropertyEvent` |
    `static class` | `ObservableMap.PropertyRemovedEvent` |
    `static class` | `ObservableMap.PropertyUpdatedEvent` |

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static String` | `CLEARED_PROPERTY` |
    `static String` | `CONTENT_PROPERTY` |
    `static String` | `SIZE_PROPERTY` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ObservableMap ()`
    `ObservableMap (Closure test)`
    `ObservableMap (Map delegate)`
    `ObservableMap (Map delegate, Closure test)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `void` | `addPropertyChangeListener(PropertyChangeListener listener)`
    `` | `void` | `addPropertyChangeListener(String propertyName, PropertyChangeListener listener)`
    `` | `void` | `clear()`
    `` | `boolean` | `containsKey(Object key)`
    `` | `boolean` | `containsValue(Object value)`
    `` | `Set` | `entrySet()`
    `` | `boolean` | `equals(Object o)`
    `` | `protected void` | `fireMultiPropertyEvent(List<PropertyEvent> events)`
    `` | `protected void` | `fireMultiPropertyEvent(PropertyEvent[] events)`
    `` | `protected void` | `firePropertyAddedEvent(Object key, Object value)`
    `` | `protected void` | `firePropertyClearedEvent(Map values)`
    `` | `protected void` | `firePropertyEvent(PropertyEvent event)`
    `` | `protected void` | `firePropertyRemovedEvent(Object key, Object value)`
    `` | `protected void` | `firePropertyUpdatedEvent(Object key, Object oldValue, Object newValue)`
    `` | `protected void` | `fireSizeChangedEvent(int oldValue, int newValue)`
    `` | `Object` | `get(Object key)`
    `` | `Map` | `getContent()`
    `` | `protected Map` | `getMapDelegate()`
    `` | `PropertyChangeListener[]` | `getPropertyChangeListeners()`
    `` | `PropertyChangeListener[]` | `getPropertyChangeListeners(String propertyName)`
    `` | `int` | `getSize()`
    `` | `protected Closure` | `getTest()`
    `` | `boolean` | `hasListeners(String propertyName)`
    `` | `int` | `hashCode()`
    `` | `boolean` | `isEmpty()`
    `` | `Set` | `keySet()`
    `` | `Object` | `put(Object key, Object value)`
    `` | `void` | `putAll(Map map)`
    `` | `Object` | `remove(Object key)`
    `` | `void` | `removePropertyChangeListener(PropertyChangeListener listener)`
    `` | `void` | `removePropertyChangeListener(String propertyName, PropertyChangeListener listener)`
    `` | `int` | `size()`
    `` | `Collection` | `values()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Field Detail

    - #### public static final String CLEARED_PROPERTY

    - #### public static final String CONTENT_PROPERTY

    - #### public static final String SIZE_PROPERTY

  - ### Constructor Detail

    - #### public ObservableMap()

    - #### public ObservableMap(Closure test)

    - #### public ObservableMap(Map delegate)

    - #### public ObservableMap(Map delegate, Closure test)

  - ### Method Detail

    - #### public void addPropertyChangeListener(PropertyChangeListener listener)

    - #### public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)

    - #### public void clear()

    - #### public boolean containsKey(Object key)

    - #### public boolean containsValue(Object value)

    - #### public Set entrySet()

    - #### public boolean equals(Object o)

    - #### protected void fireMultiPropertyEvent(List<PropertyEvent> events)

    - #### protected void fireMultiPropertyEvent(PropertyEvent[] events)

    - #### protected void firePropertyAddedEvent(Object key, Object value)

    - #### protected void firePropertyClearedEvent(Map values)

    - #### protected void firePropertyEvent(PropertyEvent event)

    - #### protected void firePropertyRemovedEvent(Object key, Object value)

    - #### protected void firePropertyUpdatedEvent(Object key, Object oldValue, Object newValue)

    - #### protected void fireSizeChangedEvent(int oldValue, int newValue)

    - #### public Object get(Object key)

    - #### public Map getContent()

    - #### protected Map getMapDelegate()

    - #### public PropertyChangeListener[] getPropertyChangeListeners()

    - #### public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)

    - #### public int getSize()

    - #### protected Closure getTest()

    - #### public boolean hasListeners(String propertyName)

    - #### public int hashCode()

    - #### public boolean isEmpty()

    - #### public Set keySet()

    - #### public Object put(Object key, Object value)

    - #### public void putAll(Map map)

    - #### public Object remove(Object key)

    - #### public void removePropertyChangeListener(PropertyChangeListener listener)

    - #### public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)

    - #### public int size()

    - #### public Collection values()