com.atlassian.confluence.util.collections
Class CompositeMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
com.atlassian.confluence.util.collections.CompositeMap<K,V>
- All Implemented Interfaces:
- java.util.Map<K,V>
@NotThreadSafe
public class CompositeMap<K,V>
- extends java.util.AbstractMap<K,V>
- implements java.util.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 classes/interfaces inherited from class java.util.AbstractMap |
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Nested classes/interfaces inherited from interface java.util.Map |
java.util.Map.Entry<K,V> |
Method Summary |
boolean |
containsKey(java.lang.Object key)
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
|
V |
get(java.lang.Object key)
|
boolean |
isEmpty()
|
java.util.Set<K> |
keySet()
|
static
|
of(java.util.Map<K,V> one,
java.util.Map<K,V> two)
Create a new CompositeMap with two composited Map instances. |
V |
put(K key,
V value)
|
V |
remove(java.lang.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 |
of
public static <K,V> java.util.Map<K,V> of(java.util.Map<K,V> one,
java.util.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:
java.lang.IllegalArgumentException
- if there is a key collision
entrySet
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
- Specified by:
entrySet
in interface java.util.Map<K,V>
- Specified by:
entrySet
in class java.util.AbstractMap<K,V>
get
public V get(java.lang.Object key)
- Specified by:
get
in interface java.util.Map<K,V>
- Overrides:
get
in class java.util.AbstractMap<K,V>
keySet
public java.util.Set<K> keySet()
- Specified by:
keySet
in interface java.util.Map<K,V>
- Overrides:
keySet
in class java.util.AbstractMap<K,V>
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKey
in interface java.util.Map<K,V>
- Overrides:
containsKey
in class java.util.AbstractMap<K,V>
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interface java.util.Map<K,V>
- Overrides:
isEmpty
in class java.util.AbstractMap<K,V>
put
public V put(K key,
V value)
- Specified by:
put
in interface java.util.Map<K,V>
- Overrides:
put
in class java.util.AbstractMap<K,V>
remove
public V remove(java.lang.Object key)
- Specified by:
remove
in interface java.util.Map<K,V>
- Overrides:
remove
in class java.util.AbstractMap<K,V>
Copyright © 2003-2014 Atlassian. All Rights Reserved.