* A map iterator is an efficient way of iterating over maps. There is no need to access the entries collection or use {@code Map.Entry} objects. *
+ *+ * The iterator visits one key-value mapping at a time, so a key with several values is returned once per value. The implementations in this + * library do not support {@link MapIterator#setValue(Object)} and throw an {@link UnsupportedOperationException} from it; to replace a value, + * remove the mapping, with {@link MapIterator#remove()} or {@link #removeMapping(Object, Object)}, and {@link #put(Object, Object) put} the new one. + *
* * @return A map iterator. */ diff --git a/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java b/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java index 7973e378a0..d3213bc3f3 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java @@ -344,6 +344,14 @@ public void remove() { it.remove(); } + /** + * Always throws {@link UnsupportedOperationException}, as the entries of a multivalued map are read-only. + * + * @param value Ignored. + * @return Never returns normally. + * @throws IllegalStateException if {@link #next()} has not been called yet. + * @throws UnsupportedOperationException Always thrown otherwise. + */ @Override public V setValue(final V value) { if (current == null) { @@ -747,6 +755,13 @@ public Set+ * The returned iterator does not support {@link MapIterator#setValue(Object)}: the entries it iterates are read-only, so {@code setValue} + * throws an {@link UnsupportedOperationException}. + *
+ */ @Override public MapIterator