Class CollectionMap<K,V>

java.lang.Object
com.vividsolutions.jump.util.CollectionMap<K,V>
All Implemented Interfaces:
Map<K, Collection<V>>

public class CollectionMap<K,V> extends Object implements Map<K, Collection<V>>
A Map whose values are Collections.
  • Constructor Details

    • CollectionMap

      public CollectionMap(Class<? extends Map> mapClass)
      Creates a CollectionMap backed by the given Map class.
      Parameters:
      mapClass - a Class that implements Map
    • CollectionMap

      public CollectionMap(Class<? extends Map> mapClass, Class<Collection> collectionClass)
    • CollectionMap

      public CollectionMap()
      Creates a CollectionMap.
  • Method Details

    • addItem

      public void addItem(K key, V item)
      Adds the item to the Collection at the given key, creating a new Collection if necessary.
      Parameters:
      key - the key to the Collection to which the item should be added
      item - the item to add
    • removeItem

      public void removeItem(K key, V item)
    • clear

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

      public void addItems(K key, Collection<V> items)
      Adds the items to the Collection at the given key, creating a new Collection if necessary.
      Parameters:
      key - the key to the Collection to which the items should be added
      items - the items to add
    • addItems

      public void addItems(CollectionMap<K,V> other)
    • values

      public Collection<Collection<V>> values()
      Returns the values.
      Specified by:
      values in interface Map<K,V>
      Returns:
      a view of the values, backed by this CollectionMap
    • keySet

      public Set<K> keySet()
      Returns the keys.
      Specified by:
      keySet in interface Map<K,V>
      Returns:
      a view of the keys, backed by this CollectionMap
    • size

      public int size()
      Returns the number of mappings.
      Specified by:
      size in interface Map<K,V>
      Returns:
      the number of key-value pairs
    • get

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

      public Collection<V> getItems(K key)
    • remove

      public Collection<V> remove(Object key)
      Specified by:
      remove 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>
    • entrySet

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

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

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

      public void putAll(Map<? extends K, ? extends Collection<V>> map)
      Specified by:
      putAll in interface Map<K,V>
    • removeItems

      public void removeItems(K key, Collection<V> items)
    • getMap

      public Map<K, ? extends Collection<V>> getMap()