Class MapModel<K,​V>

    • Constructor Detail

      • MapModel

        public MapModel()
    • Method Detail

      • addMapListener

        public void addMapListener​(IMapListener<K,​V> listener)
        Description copied from interface: IMap
        Adds the map listener.
        Specified by:
        addMapListener in interface IMap<K,​V>
        Parameters:
        listener - the listener to add.
      • removeMapListener

        public void removeMapListener​(IMapListener<K,​V> listener)
        Description copied from interface: IMap
        Removes the map listener.
        Specified by:
        removeMapListener in interface IMap<K,​V>
        Parameters:
        listener - the listener to add.
      • discard

        public void discard()
        Description copied from interface: IModel
        Discards the changes stored in the model buffer since last IModel.commit() operation.
        Specified by:
        discard in interface IModel
        Overrides:
        discard in class Model
      • isEqual

        public boolean isEqual​(Map<K,​V> other)
        Description copied from interface: IMap
        Checks the map for equality with the current stored map.
        Specified by:
        isEqual in interface IMap<K,​V>
        Parameters:
        other - the other map to check.
        Returns:
        true if other map is equal to this map, false otherwise.
      • size

        public int size()
        Specified by:
        size in interface Map<K,​V>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Map<K,​V>
      • containsKey

        public boolean containsKey​(Object key)
        Specified by:
        containsKey in interface Map<K,​V>
      • get

        public V get​(Object key)
        Specified by:
        get in interface Map<K,​V>
      • put

        public V put​(K key,
                     V value)
        Specified by:
        put in interface Map<K,​V>
      • remove

        public V remove​(Object key)
        Specified by:
        remove in interface Map<K,​V>
      • putAll

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

        public void clear()
        Specified by:
        clear in interface Map<K,​V>
      • keySet

        public Set<K> keySet()
        Specified by:
        keySet in interface Map<K,​V>
      • fill

        public void fill​(Map<? extends K,​? extends V> map)
        Description copied from interface: IMap
        Clears the current stored map and adds all elements of the given map to the stored one.
        Specified by:
        fill in interface IMap<K,​V>
        Parameters:
        map - the map to add.
      • queueNotifyMapChanged

        protected final void queueNotifyMapChanged()
        Queues the runnable that notifies the listeners about a change of this map. In fact it queues a runnable that performs notifyMapChanged(ChangeOrigin).
      • getCommittedMap

        protected final Map<K,​V> getCommittedMap()
        Returns:
        the committed list, under normal conditions it should be in sync with data source.
      • getUncommittedMap

        protected final Map<K,​V> getUncommittedMap()
        Returns:
        the buffered but yet uncommitted list.
      • setCommittedMap

        protected final void setCommittedMap​(Map<K,​V> map)
        Sets the committed with the new value.
        Parameters:
        map - the new committed map to set.
      • setUncommitedMap

        protected final void setUncommitedMap​(Map<K,​V> map)
        Sets the uncommitted with the new value.
        Parameters:
        map - the new uncommitted map to set.
      • setMap

        protected final void setMap​(Map<K,​V> map)
        Makes copies of the given map and sets both committed and uncommitted maps at the same time.
        Parameters:
        map - the map to set.
      • notifyMapChanged

        protected final void notifyMapChanged​(ChangeOrigin changeOrigin)
        Notifies the listeners about a change of this map.
      • isElementEqual

        protected boolean isElementEqual​(V e1,
                                         V e2)
        Checks the equality of the two values of the map.
        Parameters:
        e1 - the first value
        e2 - the second value
        Returns:
        true if the values are equals, otherwise - false.
      • fromCollection

        public static <K,​V> Map<K,​V> fromCollection​(Collection<Map.Entry<K,​V>> collection)
        Returns the newly created map from entry collection.
        Parameters:
        collection - the collection of map entries.
        Returns:
        the map