An implementation of the
java.util.Set
interface that has a serialized form consistent in all virtual machines.
ConsistentSet
instances are unmodifiable. All mutator methods, such as
add
and
remove
, throw
UnsupportedOperationException
. This class permits the
null
element.
Although instances of this class are unmodifiable, they are not necessarily immutable. If a client retrieves a mutable object contained in a ConsistentSet
and mutates that object, the client in effect mutates the state of the ConsistentSet
. In this case, the serialized form of the ConsistentSet
will also most likely have been mutated. A ConsistentSet
that contains only immutable objects will maintain a consistent serialized form indefinitely. But a ConsistentSet
that contains mutable objects will maintain a consistent serialized form only so long as the mutable objects are not mutated.
@author Bill Venners