org.jboss.weld.extensions.util.collections
Class Multimaps

java.lang.Object
  extended by org.jboss.weld.extensions.util.collections.Multimaps

public class Multimaps
extends Object


Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newSetMultimap

public 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. 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.

Parameters:
map - place to store the mapping from each key to its corresponding values
factory - supplier of new, empty sets that will each hold all values for a given key
Throws:
IllegalArgumentException - if map is not empty


Copyright © 2008-2010 Seam Framework. All Rights Reserved.