Class ObservableMap<K,V>
- java.lang.Object
-
- org.eclipse.core.databinding.observable.AbstractObservable
-
- org.eclipse.core.databinding.observable.map.ObservableMap<K,V>
-
- Type Parameters:
K- the type of the keys in this mapV- the type of the values in this map
- All Implemented Interfaces:
java.util.Map<K,V>,IObservable,IObservableMap<K,V>
- Direct Known Subclasses:
BidirectionalMap,CompositeMap,WritableMap
public class ObservableMap<K,V> extends AbstractObservable implements IObservableMap<K,V>
This class is thread safe. All state accessing methods must be invoked from the
current realm. Methods for adding and removing listeners may be invoked from any thread.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<K,V>wrappedMap
-
Constructor Summary
Constructors Constructor Description ObservableMap(java.util.Map<K,V> wrappedMap)ObservableMap(Realm realm, java.util.Map<K,V> wrappedMap)
-
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)java.util.Set<java.util.Map.Entry<K,V>>entrySet()booleanequals(java.lang.Object o)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()protected voidgetterCalled()java.lang.ObjectgetValueType()Returns the element type for thevaluesof this observable map, ornullif the values collection is untyped.inthashCode()protected booleanhasListeners()booleanisEmpty()booleanisStale()Returns the stale state.java.util.Set<K>keySet()protected voidlastListenerRemoved()Vput(K key, V value)voidputAll(java.util.Map<? extends K,? extends V> arg0)Vremove(java.lang.Object key)protected voidremoveListener(java.lang.Object listenerType, IObservablesListener listener)voidremoveMapChangeListener(IMapChangeListener<? super K,? super V> listener)voidsetStale(boolean stale)Sets the stale state.intsize()java.util.Collection<V>values()-
Methods inherited from class org.eclipse.core.databinding.observable.AbstractObservable
addChangeListener, addDisposeListener, addStaleListener, checkRealm, dispose, fireChange, fireStale, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.core.databinding.observable.IObservable
addChangeListener, addDisposeListener, addStaleListener, dispose, getRealm, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
-
-
-
-
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. - Since:
- 1.2
-
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. - Since:
- 1.2
-
getterCalled
protected void getterCalled()
-
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()
-
size
public int size()
-
values
public java.util.Collection<V> values()
-
isStale
public boolean isStale()
Returns the stale state. Must be invoked from the current realm.- Specified by:
isStalein interfaceIObservable- Returns:
- stale state
-
setStale
public void setStale(boolean stale)
Sets the stale state. Must be invoked from the current realm.- Parameters:
stale- The stale state to set. This will fire a stale event if the given boolean is true and this observable set was not already stale.
-
remove
public V remove(java.lang.Object key)
-
equals
public boolean equals(java.lang.Object o)
-
hashCode
public int hashCode()
-
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)
-
firstListenerAdded
protected void firstListenerAdded()
-
lastListenerRemoved
protected void lastListenerRemoved()
-
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
-
-