Class DecoratingObservableMap<K,​V>

  • Type Parameters:
    K - type of the keys to the map
    V - 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 Detail

      • DecoratingObservableMap

        public DecoratingObservableMap​(IObservableMap<K,​V> decorated,
                                       boolean disposeDecoratedOnDispose)
        Constructs a DecoratingObservableMap which decorates the given observable.
        Parameters:
        decorated - the observable map being decorated
        disposeDecoratedOnDispose - whether the decorated observable should be disposed when the decorator is disposed
    • Method Detail

      • getKeyType

        public java.lang.Object getKeyType()
        Description copied from interface: IObservableMap
        Returns the element type for the keyset of this observable map, or null if the keyset is untyped.
        Specified by:
        getKeyType in interface IObservableMap<K,​V>
        Returns:
        the element type for the keyset of this observable map, or null if the keyset is untyped.
      • getValueType

        public java.lang.Object getValueType()
        Description copied from interface: IObservableMap
        Returns the element type for the values of this observable map, or null if the values collection is untyped.
        Specified by:
        getValueType in interface IObservableMap<K,​V>
        Returns:
        the element type for the values of this observable map, or null if the values collection is untyped.
      • fireMapChange

        protected void fireMapChange​(MapDiff<K,​V> diff)
      • 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
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,​V>
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface IObservableMap<K,​V>
        Specified by:
        containsKey in interface java.util.Map<K,​V>
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface IObservableMap<K,​V>
        Specified by:
        containsValue in interface java.util.Map<K,​V>
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface IObservableMap<K,​V>
        Specified by:
        entrySet in interface java.util.Map<K,​V>
      • get

        public V get​(java.lang.Object key)
        Specified by:
        get in interface IObservableMap<K,​V>
        Specified by:
        get in interface java.util.Map<K,​V>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface IObservableMap<K,​V>
        Specified by:
        isEmpty in interface java.util.Map<K,​V>
      • keySet

        public java.util.Set<K> keySet()
        Specified by:
        keySet in interface IObservableMap<K,​V>
        Specified by:
        keySet in interface java.util.Map<K,​V>
      • put

        public V put​(K key,
                     V value)
        Specified by:
        put in interface IObservableMap<K,​V>
        Specified by:
        put in interface java.util.Map<K,​V>
      • putAll

        public void putAll​(java.util.Map<? extends K,​? extends V> m)
        Specified by:
        putAll in interface java.util.Map<K,​V>
      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in interface IObservableMap<K,​V>
        Specified by:
        remove in interface java.util.Map<K,​V>
      • size

        public int size()
        Specified by:
        size in interface IObservableMap<K,​V>
        Specified by:
        size in interface java.util.Map<K,​V>
      • values

        public java.util.Collection<V> values()
        Specified by:
        values in interface IObservableMap<K,​V>
        Specified by:
        values in interface java.util.Map<K,​V>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • dispose

        public void dispose()
        Description copied from interface: IObservable
        Disposes of this observable object, removing all listeners registered with this object, and all listeners this object might have registered on other objects.
        Specified by:
        dispose in interface IObservable
        Overrides:
        dispose in class DecoratingObservable
      • addListener

        protected void addListener​(java.lang.Object listenerType,
                                   IObservablesListener listener)
        Parameters:
        listenerType - arbitrary object to identify a type of the listener
        listener - the listener to add; not null
      • removeListener

        protected void removeListener​(java.lang.Object listenerType,
                                      IObservablesListener listener)
        Parameters:
        listenerType - arbitrary object to identify a type of the listener
        listener - the listener to remove; not null
      • hasListeners

        protected boolean hasListeners()
      • getRealm

        public Realm getRealm()
        Returns:
        Returns the realm.
      • clone

        protected java.lang.Object clone()
                                  throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException