com.artima.lookup.util
Class ConsistentMap
java.lang.Object
java.util.AbstractMap
com.artima.lookup.util.ConsistentMap
- All Implemented Interfaces:
- Serializable, Map
public class ConsistentMap
- extends AbstractMap
- implements Serializable
An implementation of the java.util.Map
interface that has
a serialized form consistent in all virtual machines. ConsistentMap
instances are unmodifiable. All mutator methods, such as add
and
remove
, throw UnsupportedOperationException
.
This class permits null
values and the null
key.
Although instances of this class are unmodifiable, they are not necessarily
immutable. If a client retrieves a mutable object (either a key or value) contained in a
ConsistentMap
and mutates that object, the client in effect
mutates the state of the ConsistentMap
. In this case, the
serialized form of the ConsistentMap
will most likely also
have been mutated. A ConsistentMap
that contains only immutable
objects will maintain a consistent serialized form indefinitely. But a
ConsistentMap
that contains mutable objects will maintain a
consistent serialized form only so long as the mutable objects are not
mutated.
- Author:
- Bill Venners
- See Also:
- Serialized Form
Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
Constructor Summary |
ConsistentMap()
Constructs a new, empty ConsistentMap . |
ConsistentMap(Map init)
Constructs a new ConsistentMap containing the elements
in the passed collection. |
Method Summary |
Set |
entrySet()
Returns a set view of the mappings contained in this
ConsistentMap . |
Methods inherited from class java.util.AbstractMap |
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
entrySet
private Set entrySet
ConsistentMap
public ConsistentMap()
- Constructs a new, empty
ConsistentMap
. All instances
of ConsistentMap
are unmodifiable.
ConsistentMap
public ConsistentMap(Map init)
- Constructs a new
ConsistentMap
containing the elements
in the passed collection. All instances of ConsistentMap
are unmodifiable.
- Parameters:
init
- the map whose elements are to be placed into this map.
- Throws:
NullPointerException
- if the passed init
reference
is null
entrySet
public Set entrySet()
- Returns a set view of the mappings contained in this
ConsistentMap
. Each element in the returned
set is a Map.Entry
- Specified by:
entrySet
in interface Map
- Specified by:
entrySet
in class AbstractMap
- Returns:
- a set view of the mappings contained in this
ConsistentMap
.
Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.