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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Removes all of the mappings.boolean
containsKey(Object key)
Set<Map.Entry<K,Collection<V>>>
entrySet()
Map.Entry.getValue()
always returns an unmodifiable collection.Collection<V>
get(K key)
This method never returns null.boolean
isEmpty()
Set<K>
keySet()
boolean
put(K key, V value)
boolean
putAll(K key, Collection<? extends V> values)
Collection<V>
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.int
size()
Unlike Guava'sMultimap#size()
this method returns the number of key-value mappings.Set<V>
uniqueValues()
List<V>
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 Detail
-
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:
true
if there are no key-value mappings
-
get
Collection<V> get(K key)
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
boolean put(K key, V value)
- Parameters:
key
-value
-- Returns:
true
if the the size of the collection associated with the given key increased,false
otherwise (e.g. if the collection of values doesn't allow duplicates)
-
putAll
boolean putAll(K key, Collection<? extends V> values)
- Parameters:
key
-values
-- Returns:
true
if the the size of the collection associated with the given key increased,false
otherwise (e.g. if the collection of values doesn't allow duplicates)
-
replaceValues
Collection<V> 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. If the collection of values doesn't allow duplicates, these elements are removed.- Parameters:
key
-values
-- Returns:
- the collection of replaced values
-
containsKey
boolean containsKey(Object key)
- Parameters:
key
-- Returns:
true
if the multimap contains a mapping for the given key
-
values
List<V> 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
-
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.
-
-