- Type Parameters:
K
- The Class of the key for this HashMapToListV
- The Class of the Value for this HashMapToList
- All Implemented Interfaces:
- MapToList<K,V>
public class HashMapToList<K,V>
extends AbstractMapToList<K,V>
Represents a Map of objects to Lists. List management is done internally to
this class (while copies are accessible, the lists are kept private to this
class).
This class is both value-semantic and reference-semantic.
In appropriate cases (such as calling the addToListFor method), HashMapToList
will maintain a reference to the given Object. HashMapToList will not modify
any of the Objects it is passed; however, it reserves the right to return
references to Objects it contains to other Objects.
However, HashMapToList also protects its internal structure (the internal
structure is not exposed) ... when any method in which HashMapToList returns
a Collection, ownership of the Collection itself is transferred to the
calling Object, but the contents of the Collection (keys, values, etc.) are
references whose ownership should be respected. Also, when any method in
which HashMapToList receives a Collection as a parameter, the ownership of
the given Collection is not transferred to HashMapToList (in other words, the
Collection will not be modified, and no references to the Collection will be
maintain by HashMapToList). HashMapToList will obviously retain references to
the contents of any Collections it may be passed.
CAUTION: If you are not looking for the value-semantic protection of this
class (of preventing accidental modification, then this is a convenience
method and is not appropriate for use in Java 1.5 (Typed Collections are
probably more appropriate).