Class DecoratingObservableMap<K,V>
- java.lang.Object
-
- org.eclipse.core.databinding.observable.AbstractObservable
-
- org.eclipse.core.databinding.observable.DecoratingObservable
-
- org.eclipse.core.databinding.observable.map.DecoratingObservableMap<K,V>
-
- Type Parameters:
K- type of the keys to the mapV- type of the values in the map
- All Implemented Interfaces:
java.util.Map<K,V>,IDecoratingObservable,IObservable,IObservableMap<K,V>
- Direct Known Subclasses:
BidiObservableMap
public class DecoratingObservableMap<K,V> extends DecoratingObservable implements IObservableMap<K,V>
An observable map which decorates another observable map.- Since:
- 1.2
- Implementation Note:
- If methods are added to the interface which this class implements then implementations of those methods must be added to this class.
-
-
Constructor Summary
Constructors Constructor Description DecoratingObservableMap(IObservableMap<K,V> decorated, boolean disposeDecoratedOnDispose)Constructs a DecoratingObservableMap which decorates the given observable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddListener(java.lang.Object listenerType, IObservablesListener listener)voidaddMapChangeListener(IMapChangeListener<? super K,? super V> listener)voidclear()protected java.lang.Objectclone()booleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.Object value)voiddispose()Disposes of this observable object, removing all listeners registered with this object, and all listeners this object might have registered on other objects.java.util.Set<java.util.Map.Entry<K,V>>entrySet()booleanequals(java.lang.Object obj)protected voidfireChange()protected voidfireEvent(ObservableEvent event)protected voidfireMapChange(MapDiff<K,V> diff)protected voidfirstListenerAdded()Vget(java.lang.Object key)java.lang.ObjectgetKeyType()Returns the element type for thekeysetof this observable map, ornullif the keyset is untyped.RealmgetRealm()java.lang.ObjectgetValueType()Returns the element type for thevaluesof this observable map, ornullif the values collection is untyped.protected voidhandleMapChange(MapChangeEvent<? extends K,? extends V> event)Called whenever a MapChangeEvent is received from the decorated observable.inthashCode()protected booleanhasListeners()booleanisEmpty()java.util.Set<K>keySet()protected voidlastListenerRemoved()Vput(K key, V value)voidputAll(java.util.Map<? extends K,? extends V> m)Vremove(java.lang.Object key)protected voidremoveListener(java.lang.Object listenerType, IObservablesListener listener)voidremoveMapChangeListener(IMapChangeListener<? super K,? super V> listener)intsize()java.lang.StringtoString()java.util.Collection<V>values()-
Methods inherited from class org.eclipse.core.databinding.observable.DecoratingObservable
getDecorated, getterCalled, handleStaleEvent, isStale
-
Methods inherited from class org.eclipse.core.databinding.observable.AbstractObservable
addChangeListener, addDisposeListener, addStaleListener, checkRealm, fireStale, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.core.databinding.observable.IObservable
addChangeListener, addDisposeListener, addStaleListener, getRealm, isDisposed, isStale, removeChangeListener, removeDisposeListener, removeStaleListener
-
-
-
-
Constructor Detail
-
DecoratingObservableMap
public DecoratingObservableMap(IObservableMap<K,V> decorated, boolean disposeDecoratedOnDispose)
Constructs a DecoratingObservableMap which decorates the given observable.- Parameters:
decorated- the observable map being decorateddisposeDecoratedOnDispose- whether the decorated observable should be disposed when the decorator is disposed
-
-
Method Detail
-
addMapChangeListener
public void addMapChangeListener(IMapChangeListener<? super K,? super V> listener)
- Specified by:
addMapChangeListenerin interfaceIObservableMap<K,V>- Parameters:
listener- the change listener to add; notnull
-
removeMapChangeListener
public void removeMapChangeListener(IMapChangeListener<? super K,? super V> listener)
- Specified by:
removeMapChangeListenerin interfaceIObservableMap<K,V>- Parameters:
listener- the change listener to remove; notnull
-
getKeyType
public java.lang.Object getKeyType()
Description copied from interface:IObservableMapReturns the element type for thekeysetof this observable map, ornullif the keyset is untyped.- Specified by:
getKeyTypein interfaceIObservableMap<K,V>- Returns:
- the element type for the
keysetof this observable map, ornullif the keyset is untyped.
-
getValueType
public java.lang.Object getValueType()
Description copied from interface:IObservableMapReturns the element type for thevaluesof this observable map, ornullif the values collection is untyped.- Specified by:
getValueTypein interfaceIObservableMap<K,V>- Returns:
- the element type for the
valuesof this observable map, ornullif the values collection is untyped.
-
fireChange
protected void fireChange()
- Overrides:
fireChangein classAbstractObservable
-
firstListenerAdded
protected void firstListenerAdded()
- Overrides:
firstListenerAddedin classDecoratingObservable
-
lastListenerRemoved
protected void lastListenerRemoved()
- Overrides:
lastListenerRemovedin classDecoratingObservable
-
handleMapChange
protected void handleMapChange(MapChangeEvent<? extends K,? extends V> event)
Called whenever a MapChangeEvent is received from the decorated observable. By default, this method fires the map change event again, with the decorating observable as the event source. Subclasses may override to provide different behavior.- Parameters:
event- the change event received from the decorated observable
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKeyin interfaceIObservableMap<K,V>- Specified by:
containsKeyin interfacejava.util.Map<K,V>
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValuein interfaceIObservableMap<K,V>- Specified by:
containsValuein interfacejava.util.Map<K,V>
-
get
public V get(java.lang.Object key)
-
isEmpty
public boolean isEmpty()
-
keySet
public java.util.Set<K> keySet()
-
remove
public V remove(java.lang.Object key)
-
size
public int size()
-
values
public java.util.Collection<V> values()
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfaceIObservableMap<K,V>- Specified by:
equalsin interfacejava.util.Map<K,V>- Overrides:
equalsin classDecoratingObservable
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceIObservableMap<K,V>- Specified by:
hashCodein interfacejava.util.Map<K,V>- Overrides:
hashCodein classDecoratingObservable
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
dispose
public void dispose()
Description copied from interface:IObservableDisposes of this observable object, removing all listeners registered with this object, and all listeners this object might have registered on other objects.- Specified by:
disposein interfaceIObservable- Overrides:
disposein classDecoratingObservable
-
addListener
protected void addListener(java.lang.Object listenerType, IObservablesListener listener)- Parameters:
listenerType- arbitrary object to identify a type of the listenerlistener- the listener to add; notnull
-
removeListener
protected void removeListener(java.lang.Object listenerType, IObservablesListener listener)- Parameters:
listenerType- arbitrary object to identify a type of the listenerlistener- the listener to remove; notnull
-
hasListeners
protected boolean hasListeners()
-
fireEvent
protected void fireEvent(ObservableEvent event)
-
getRealm
public Realm getRealm()
- Returns:
- Returns the realm.
-
clone
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-