Package org.jboss.weld.util.collections
Interface Multimap<K,V>
- Type Parameters:
K- The keyV- The value
- All Known Implementing Classes:
ListMultimap,SetMultimap
public interface Multimap<K,V>
A collection-like structure that maps keys to collections of values.
- Author:
- Martin Kouba
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all of the mappings.booleancontainsKey(Object key) Set<Map.Entry<K,Collection<V>>> entrySet()Map.Entry.getValue()always returns an unmodifiable collection.This method never returns null.booleanisEmpty()keySet()booleanbooleanputAll(K key, Collection<? extends V> values) replaceValues(K key, Iterable<? extends V> values) Note that the original collection of values is completely replaced by a new collection which contains all elements from the given iterable.intsize()Unlike Guava'sMultimap#size()this method returns the number of key-value mappings.values()The list may include the same value multiple times if it occurs in multiple mappings or if the collection of values for the mapping allows duplicate elements.
-
Method Details
-
size
int size()Unlike Guava'sMultimap#size()this method returns the number of key-value mappings.- Returns:
- the number of key-value mappings
-
isEmpty
boolean isEmpty()- Returns:
trueif there are no key-value mappings
-
get
This method never returns null. If no collection of values for a given key exists a new value collection is initialized.- Parameters:
key-- Returns:
- the collection of values for the given key
-
put
- Parameters:
key-value-- Returns:
trueif the the size of the collection associated with the given key increased,falseotherwise (e.g. if the collection of values doesn't allow duplicates)
-
putAll
- Parameters:
key-values-- Returns:
trueif the the size of the collection associated with the given key increased,falseotherwise (e.g. if the collection of values doesn't allow duplicates)
-
replaceValues
Note that the original collection of values is completely replaced by a new collection which contains all elements from the given iterable. If the collection of values doesn't allow duplicates, these elements are removed.- Parameters:
key-values-- Returns:
- the collection of replaced values
-
containsKey
- Parameters:
key-- Returns:
trueif the multimap contains a mapping for the given key
-
keySet
- Returns:
- an immutable set of keys
-
values
The list may include the same value multiple times if it occurs in multiple mappings or if the collection of values for the mapping allows duplicate elements.- Returns:
- an immutable list of all the values in the multimap
-
uniqueValues
- Returns:
- an immutable set of all the values in the multimap
-
entrySet
Set<Map.Entry<K,Collection<V>>> entrySet()Map.Entry.getValue()always returns an unmodifiable collection.Map.Entry.setValue(Object)operation is not supported.- Returns:
- an immutable set of all key-value pairs
-
clear
void clear()Removes all of the mappings.
-