Class Overview
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
synchronizedMap(Map)
.
This class will behave in an undefined manner if
accessed by concurrent threads without synchronization.
Summary
[Expand]
Inherited Methods |
From class
java.util.AbstractMap
void
|
clear()
|
Object
|
clone()
|
boolean
|
containsKey(Object arg0)
|
boolean
|
containsValue(Object arg0)
|
abstract
Set<Entry<K, V>>
|
entrySet()
|
boolean
|
equals(Object arg0)
|
V
|
get(Object arg0)
|
int
|
hashCode()
|
boolean
|
isEmpty()
|
Set<K>
|
keySet()
|
V
|
put(K arg0, V arg1)
|
void
|
putAll(Map<? extends K, ? extends V> arg0)
|
V
|
remove(Object arg0)
|
int
|
size()
|
String
|
toString()
|
Collection<V>
|
values()
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
From interface
java.util.Map
void
|
clear()
|
boolean
|
containsKey(Object arg0)
|
boolean
|
containsValue(Object arg0)
|
Set<Entry<K, V>>
|
entrySet()
|
boolean
|
equals(Object arg0)
|
V
|
get(Object arg0)
|
int
|
hashCode()
|
boolean
|
isEmpty()
|
Set<K>
|
keySet()
|
V
|
put(K arg0, V arg1)
|
void
|
putAll(Map<? extends K, ? extends V> arg0)
|
V
|
remove(Object arg0)
|
int
|
size()
|
Collection<V>
|
values()
|
|
Public Methods
public
boolean
containsKey
(Object key)
public
boolean
isEmpty
()
public
static
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
public
V
put
(K key, V value)
public
void
putAll
(Map<? extends K, ? extends V> m)