Class EventProducingMap<K,V>

java.lang.Object
org.djutils.event.LocalEventProducer
org.djutils.event.collection.EventProducingMap<K,V>
Type Parameters:
K - the key type
V - the value type
All Implemented Interfaces:
Serializable, Remote, Map<K,V>, EventProducer

public class EventProducingMap<K,V> extends LocalEventProducer implements Map<K,V>, Serializable
The Event producing map provides a map to which one can subscribe interest in entry changes. This class does not keep track of changes which take place indirectly. One is for example not notified on map.iterator.remove(). A listener must subscribe to the iterator, key set, etc. individually.

Copyright (c) 2002-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html. This class was originally part of the DSOL project, see https://simulation.tudelft.nl/dsol/manual.

Author:
Peter Jacobs , Alexander Verbraeck
See Also:
  • Field Details

    • OBJECT_ADDED_EVENT

      public static final EventType OBJECT_ADDED_EVENT
      OBJECT_ADDED_EVENT is fired on new entries.
    • OBJECT_REMOVED_EVENT

      public static final EventType OBJECT_REMOVED_EVENT
      OBJECT_REMOVED_EVENT is fired on removal of entries.
    • OBJECT_CHANGED_EVENT

      public static final EventType OBJECT_CHANGED_EVENT
      OBJECT_CHANGED_EVENT is fired on change of one or more entries.
  • Constructor Details

    • EventProducingMap

      public EventProducingMap(Map<K,V> wrappedMap)
      constructs a new EventProducingMap.
      Parameters:
      wrappedMap - Map<K,V>; the embedded map.
  • Method Details

    • 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>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue 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> map)
      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>
    • values

      public Collection<V> values()
      Specified by:
      values in interface Map<K,V>
    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Specified by:
      entrySet in interface Map<K,V>