org.jboss.webbeans.util.collections.multi
Class ListHashMultiMap<K,V>

java.lang.Object
  extended by org.jboss.webbeans.util.collections.ForwardingObject
      extended by org.jboss.webbeans.util.collections.ForwardingMap<K,java.util.List<V>>
          extended by org.jboss.webbeans.util.collections.multi.ListHashMultiMap<K,V>
All Implemented Interfaces:
java.util.Map<K,java.util.List<V>>, ListMultiMap<K,V>

public class ListHashMultiMap<K,V>
extends ForwardingMap<K,java.util.List<V>>
implements ListMultiMap<K,V>

An multimap which is internally backed by a HashMap and a ArrayList

Author:
Pete Muir

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
ListHashMultiMap()
          Constructor.
 
Method Summary
 void deepPutAll(java.util.Map<? extends K,? extends java.util.List<V>> map)
          Put all the data in the map into this map, copying each multi-value, not just attaching the existing multi-value
protected  java.util.Map<K,java.util.List<V>> delegate()
          Returns the backing delegate instance that methods are forwarded to.
 java.util.List<V> get(java.lang.Object key)
          Gets the list of values for a given key
 void put(K key, V value)
          Adds an value for a given key Implicitly creates a new list if there is none for the key.
 
Methods inherited from class org.jboss.webbeans.util.collections.ForwardingMap
clear, containsKey, containsValue, createEntrySet, createKeySet, createValues, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class org.jboss.webbeans.util.collections.ForwardingObject
toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

ListHashMultiMap

public ListHashMultiMap()
Constructor.

Method Detail

delegate

protected java.util.Map<K,java.util.List<V>> delegate()
Description copied from class: ForwardingObject
Returns the backing delegate instance that methods are forwarded to. Abstract subclasses generally override the ForwardingObject method with an abstract method that has a more specific return type, such as ForwardingSet.delegate(). Concrete subclasses override this method to supply the instance being decorated.

Specified by:
delegate in class ForwardingMap<K,java.util.List<V>>

deepPutAll

public void deepPutAll(java.util.Map<? extends K,? extends java.util.List<V>> map)
Description copied from interface: ListMultiMap
Put all the data in the map into this map, copying each multi-value, not just attaching the existing multi-value

Specified by:
deepPutAll in interface ListMultiMap<K,V>
Parameters:
map - the map to copy

get

public java.util.List<V> get(java.lang.Object key)
Gets the list of values for a given key

Specified by:
get in interface java.util.Map<K,java.util.List<V>>
Overrides:
get in class ForwardingMap<K,java.util.List<V>>
Parameters:
key - the key
Returns:
The list of values. An empty list is returned if there are no matches.

put

public void put(K key,
                V value)
Adds an value for a given key Implicitly creates a new list if there is none for the key. Only adds the value if it is not already present

Specified by:
put in interface ListMultiMap<K,V>
Parameters:
key - the key
value - the value


Copyright © 2011. All Rights Reserved.