Package org.jboss.weld.util.collections
Class SetMultimap<K,V>
- java.lang.Object
-
- org.jboss.weld.util.collections.SetMultimap<K,V>
-
- Type Parameters:
K- The key typeV- The value type
- All Implemented Interfaces:
Serializable,Multimap<K,V>
public class SetMultimap<K,V> extends Object
- Author:
- Martin Kouba
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all of the mappings.booleancontainsKey(Object key)Set<Map.Entry<K,Collection<V>>>entrySet()Map.Entry.getValue()always returns an unmodifiable collection.Cget(K key)This method never returns null.booleanisEmpty()Set<K>keySet()static <K,V>
SetMultimap<K,V>newConcurrentSetMultimap()Creates a new instance backed by aConcurrentHashMapand synchronizedHashSet.static <K,V>
SetMultimap<K,V>newConcurrentSetMultimap(Supplier<Set<V>> valueSupplier)Creates a new instance backed by aConcurrentHashMapand synchronizedHashSet.static <K,V>
SetMultimap<K,V>newSetMultimap()static <K,V>
SetMultimap<K,V>newSetMultimap(Multimap<K,V> multimap)booleanput(K key, V value)booleanputAll(K key, Collection<? extends V> values)CreplaceValues(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.StringtoString()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.
-
-
-
Field Detail
-
supplier
protected final Supplier<C extends Collection<V>> supplier
-
-
Method Detail
-
newSetMultimap
public static <K,V> SetMultimap<K,V> newSetMultimap()
-
newSetMultimap
public static <K,V> SetMultimap<K,V> newSetMultimap(Multimap<K,V> multimap)
Creates a new instance backed by aHashMapandHashSet. All key-value mappings are copied from the input multimap. If any collection of values in the input multimap contains duplicate elements, these are removed in the constructed multimap.- Parameters:
multimap-
-
newConcurrentSetMultimap
public static <K,V> SetMultimap<K,V> newConcurrentSetMultimap()
Creates a new instance backed by aConcurrentHashMapand synchronizedHashSet.
-
newConcurrentSetMultimap
public static <K,V> SetMultimap<K,V> newConcurrentSetMultimap(Supplier<Set<V>> valueSupplier)
Creates a new instance backed by aConcurrentHashMapand synchronizedHashSet.
-
size
public int size()
Description copied from interface:MultimapUnlike Guava'sMultimap#size()this method returns the number of key-value mappings.
-
isEmpty
public boolean isEmpty()
-
get
public C get(K key)
Description copied from interface:MultimapThis method never returns null. If no collection of values for a given key exists a new value collection is initialized.
-
put
public boolean put(K key, V value)
-
putAll
public boolean putAll(K key, Collection<? extends V> values)
-
replaceValues
public C replaceValues(K key, Iterable<? extends V> values)Description copied from interface:MultimapNote 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.- Specified by:
replaceValuesin interfaceMultimap<K,V>- Returns:
- the collection of replaced values
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMultimap<K,V>- Returns:
trueif the multimap contains a mapping for the given key
-
keySet
public Set<K> keySet()
-
values
public List<V> values()
Description copied from interface:MultimapThe 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.
-
uniqueValues
public Set<V> uniqueValues()
- Specified by:
uniqueValuesin interfaceMultimap<K,V>- Returns:
- an immutable set of all the values in the multimap
-
entrySet
public Set<Map.Entry<K,Collection<V>>> entrySet()
Description copied from interface:MultimapMap.Entry.getValue()always returns an unmodifiable collection.Map.Entry.setValue(Object)operation is not supported.
-
clear
public void clear()
Description copied from interface:MultimapRemoves all of the mappings.
-
-