com.atlassian.jira.util.collect
Class CompositeMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
com.atlassian.jira.util.collect.CompositeMap<K,V>
- All Implemented Interfaces:
- Map<K,V>
@NotThreadSafe
public class CompositeMap<K,V>
- extends AbstractMap<K,V>
Provides a union view of two maps.
Restrictions:
- The supplied maps become the property of the new map.
They should not be accessed directly in any way after the
composite map is created. The result of such access is
left undefined.
- The mutability of this map depends on that of the first map.
For efficiency reasons, this class uses the first map to hold
updated state. If the first map is immutable,
then this map will be, too. The second map in never modified
by this class.
- 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 undefined manner if
accessed by concurrent threads without synchronization.
Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
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, or one itself if two is empty
- Throws:
IllegalArgumentException
- if either map is null
keySet
public Set<K> keySet()
- Specified by:
keySet
in interface Map<K,V>
- Overrides:
keySet
in class AbstractMap<K,V>
entrySet
public Set<Map.Entry<K,V>> entrySet()
- Specified by:
entrySet
in interface Map<K,V>
- Specified by:
entrySet
in class AbstractMap<K,V>
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interface Map<K,V>
- Overrides:
isEmpty
in class AbstractMap<K,V>
size
public int size()
- Specified by:
size
in interface Map<K,V>
- Overrides:
size
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>
get
public V get(Object key)
- Specified by:
get
in interface Map<K,V>
- Overrides:
get
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>
putAll
public void putAll(Map<? extends K,? extends V> m)
- Specified by:
putAll
in interface Map<K,V>
- Overrides:
putAll
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>
clear
public void clear()
- Specified by:
clear
in interface Map<K,V>
- Overrides:
clear
in class AbstractMap<K,V>
Copyright © 2002-2013 Atlassian. All Rights Reserved.