com.atlassian.jira.util.collect
Class CompositeMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by com.atlassian.jira.util.collect.CompositeMap<K,V>
All Implemented Interfaces:
Map<K,V>

@NotThreadSafe
public class CompositeMap<K,V>
extends AbstractMap<K,V>
implements Map<K,V>

Provides a union view of two maps.

Changes made to this map will only be made on the first map.

Note that CompositeMap is not synchronized and is not thread-safe. If you wish to use this map from multiple threads concurrently, you must use appropriate synchronization. The simplest approach is to wrap this map using Collections.synchronizedMap(Map). This class will behave in an unspecified manner if accessed by concurrent threads without synchronization.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Method Summary
 boolean containsKey(Object key)
           
 Set<Map.Entry<K,V>> entrySet()
           
 V get(Object key)
           
 boolean isEmpty()
           
 Set<K> keySet()
           
static
<K,V> Map<K,V>
of(Map<K,V> one, Map<K,V> two)
          Create a new CompositeMap with two composited Map instances.
 V put(K key, V value)
           
 V remove(Object key)
           
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, equals, hashCode, putAll, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
clear, containsValue, equals, hashCode, putAll, size, values
 

Method Detail

of

public static <K,V> Map<K,V> of(Map<K,V> one,
                                Map<K,V> two)
Create a new CompositeMap with two composited Map instances.

Parameters:
one - the first Map to be composited, values here override values in the second.
two - the second Map to be composited
Returns:
the CompositeMap
Throws:
IllegalArgumentException - if there is a key collision

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V>
Specified by:
entrySet in class AbstractMap<K,V>

get

public V get(Object key)
Specified by:
get in interface Map<K,V>
Overrides:
get in class AbstractMap<K,V>

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K,V>
Overrides:
keySet in class AbstractMap<K,V>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<K,V>
Overrides:
containsKey in class AbstractMap<K,V>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<K,V>
Overrides:
isEmpty in class AbstractMap<K,V>

put

public V put(K key,
             V value)
Specified by:
put in interface Map<K,V>
Overrides:
put in class AbstractMap<K,V>

remove

public V remove(Object key)
Specified by:
remove in interface Map<K,V>
Overrides:
remove in class AbstractMap<K,V>


Copyright © 2002-2011 Atlassian. All Rights Reserved.