|
Groovy 2.2.0 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovy.util.ObservableMap
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
Bound properties
Nested Class Summary | |
---|---|
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 | |
---|---|
static String |
CLEARED_PROPERTY
|
static String |
CONTENT_PROPERTY
|
static String |
SIZE_PROPERTY
|
Constructor Summary | |
ObservableMap()
|
|
ObservableMap(Closure test)
|
|
ObservableMap(Map delegate)
|
|
ObservableMap(Map delegate, Closure test)
|
Methods inherited from 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 events)
protected void fireMultiPropertyEvent(ObservableMap.PropertyEvent[] events)
protected void firePropertyAddedEvent(Object key, Object value)
protected void firePropertyClearedEvent(Map values)
protected void firePropertyEvent(ObservableMap.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()
Copyright © 2003-2013 The Codehaus. All rights reserved.