Stores the contents of a multimap in an output stream, as part of serialization. It does not support concurrent multimaps whose content may change while the method is running. The Multimap#asMap view determines the ordering in which data is written to the stream. The serialized output co
(Multimap<K, V> multimap, ObjectOutputStream stream)
| 150 | */ |
| 151 | |
| 152 | static <K, V> void writeMultimap(Multimap<K, V> multimap, ObjectOutputStream stream) throws IOException { |
| 153 | stream.writeInt(multimap.asMap().size()); |
| 154 | for (Map.Entry<K, Collection<V>> entry : multimap.asMap().entrySet()) { |
| 155 | stream.writeObject(entry.getKey()); |
| 156 | stream.writeInt(entry.getValue().size()); |
| 157 | for (V value : entry.getValue()) { |
| 158 | stream.writeObject(value); |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Populates a multimap by reading an input stream, as part of |
no test coverage detected