Package com.vividsolutions.jump.util
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 Summary
Constructors Constructor Description CollectionMap()Creates a CollectionMap.CollectionMap(Class<? extends Map> mapClass)Creates a CollectionMap backed by the given Map class.CollectionMap(Class<? extends Map> mapClass, Class<Collection> collectionClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddItem(K key, V item)Adds the item to the Collection at the given key, creating a new Collection if necessary.voidaddItems(CollectionMap<K,V> other)voidaddItems(K key, Collection<V> items)Adds the items to the Collection at the given key, creating a new Collection if necessary.voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,Collection<V>>>entrySet()Collection<V>get(Object key)Collection<V>getItems(K key)Map<K,? extends Collection<V>>getMap()booleanisEmpty()Set<K>keySet()Returns the keys.Collection<V>put(K key, Collection<V> value)voidputAll(Map<? extends K,? extends Collection<V>> map)Collection<V>remove(Object key)voidremoveItem(K key, V item)voidremoveItems(K key, Collection<V> items)intsize()Returns the number of mappings.Collection<Collection<V>>values()Returns the values.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
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 Detail
-
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 addeditem- the item to add
-
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 addeditems- the items to add
-
addItems
public void addItems(CollectionMap<K,V> other)
-
values
public Collection<Collection<V>> values()
Returns the values.
-
size
public int size()
Returns the number of mappings.
-
getItems
public Collection<V> getItems(K key)
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>
-
entrySet
public Set<Map.Entry<K,Collection<V>>> entrySet()
-
put
public Collection<V> put(K key, Collection<V> value)
-
putAll
public void putAll(Map<? extends K,? extends Collection<V>> map)
-
removeItems
public void removeItems(K key, Collection<V> items)
-
getMap
public Map<K,? extends Collection<V>> getMap()
-
-