public class Multimaps extends Object
| Modifier and Type | Method and Description |
|---|---|
static <K,V> SetMultimap<K,V> |
newSetMultimap(Map<K,Collection<V>> map,
Supplier<? extends Set<V>> factory)
Creates a new
SetMultimap that uses the provided map and factory. |
public static <K,V> SetMultimap<K,V> newSetMultimap(Map<K,Collection<V>> map, Supplier<? extends Set<V>> factory)
SetMultimap that uses the provided map and factory.
It can generate a multimap based on arbitrary Map and Set
classes.
The factory-generated and map classes determine the
multimap iteration order. They also specify the behavior of the equals, hashCode, and toString methods for the multimap
and its returned views. However, the multimap's get method returns
instances of a different class than factory.get() does.
The multimap is serializable if map, factory, the sets
generated by factory, and the multimap contents are all
serializable.
The multimap is not threadsafe when any concurrent operations update the
multimap, even if map and the instances generated by factory are. Concurrent read operations will work correctly. To allow
concurrent update operations, wrap the multimap with a call to
#synchronizedSetMultimap.
Call this method only when the simpler methods HashMultimap#create(),
LinkedHashMultimap#create(), TreeMultimap#create(), and
TreeMultimap#create(Comparator, Comparator) won't suffice.
Note: the multimap assumes complete ownership over of map and the
sets returned by factory. Those objects should not be manually
updated and they should not use soft, weak, or phantom references.map - place to store the mapping from each key to its corresponding
valuesfactory - supplier of new, empty sets that will each hold all values
for a given keyIllegalArgumentException - if map is not emptyCopyright © 2013. All Rights Reserved.