This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-collections.git
commit e6b8bbd08faf0f37c7d79a64117f52f6d414a98d Author: Gary Gregory <[email protected]> AuthorDate: Sun Aug 25 18:12:05 2024 -0400 Javadoc - Objects.requireNonNull() - Whitespace --- .../collections4/map/AbstractLinkedMap.java | 62 +++++++++++++++++++++- .../multimap/AbstractMultiValuedMap.java | 10 +++- .../collections4/multiset/AbstractMapMultiSet.java | 3 ++ 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractLinkedMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractLinkedMap.java index 4c4cd71c9..e4b81ec86 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractLinkedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractLinkedMap.java @@ -20,6 +20,7 @@ import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; +import java.util.Objects; import org.apache.commons.collections4.OrderedIterator; import org.apache.commons.collections4.OrderedMap; @@ -77,6 +78,11 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im protected static class EntrySetIterator<K, V> extends LinkIterator<K, V> implements OrderedIterator<Map.Entry<K, V>>, ResettableIterator<Map.Entry<K, V>> { + /** + * Constructs a new instance. + * + * @param parent The parent AbstractLinkedMap. + */ protected EntrySetIterator(final AbstractLinkedMap<K, V> parent) { super(parent); } @@ -100,6 +106,11 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im protected static class KeySetIterator<K> extends LinkIterator<K, Object> implements OrderedIterator<K>, ResettableIterator<K> { + /** + * Constructs a new instance. + * + * @param parent The parent AbstractLinkedMap. + */ @SuppressWarnings("unchecked") protected KeySetIterator(final AbstractLinkedMap<K, ?> parent) { super((AbstractLinkedMap<K, Object>) parent); @@ -157,31 +168,59 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im /** The parent map */ protected final AbstractLinkedMap<K, V> parent; + /** The current (last returned) entry */ protected LinkEntry<K, V> last; + /** The next entry */ protected LinkEntry<K, V> next; + /** The modification count expected */ protected int expectedModCount; + /** + * Constructs a new instance. + * + * @param parent The parent AbstractLinkedMap. + */ protected LinkIterator(final AbstractLinkedMap<K, V> parent) { - this.parent = parent; + this.parent = Objects.requireNonNull(parent); this.next = parent.header.after; this.expectedModCount = parent.modCount; } + /** + * Gets the current entry. + * + * @return the current entry. + */ protected LinkEntry<K, V> currentEntry() { return last; } + /** + * Tests whether there is another entry. + * + * @return whether there is another entry. + */ public boolean hasNext() { return next != parent.header; } + /** + * Tests whether there is a previous entry. + * + * @return whether there is a previous entry. + */ public boolean hasPrevious() { return next.before != parent.header; } + /** + * Gets the next entry. + * + * @return the next entry. + */ protected LinkEntry<K, V> nextEntry() { if (parent.modCount != expectedModCount) { throw new ConcurrentModificationException(); @@ -194,6 +233,11 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im return last; } + /** + * Gets the previous entry. + * + * @return the previous entry. + */ protected LinkEntry<K, V> previousEntry() { if (parent.modCount != expectedModCount) { throw new ConcurrentModificationException(); @@ -207,6 +251,9 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im return last; } + /** + * Removes the current entry. + */ public void remove() { if (last == null) { throw new IllegalStateException(REMOVE_INVALID); @@ -219,6 +266,9 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im expectedModCount = parent.modCount; } + /** + * Resets the state to the end. + */ public void reset() { last = null; next = parent.header.after; @@ -242,6 +292,11 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im protected static class LinkMapIterator<K, V> extends LinkIterator<K, V> implements OrderedMapIterator<K, V>, ResettableIterator<K> { + /** + * Constructs a new instance. + * + * @param parent The parent AbstractLinkedMap. + */ protected LinkMapIterator(final AbstractLinkedMap<K, V> parent) { super(parent); } @@ -292,6 +347,11 @@ public abstract class AbstractLinkedMap<K, V> extends AbstractHashedMap<K, V> im protected static class ValuesIterator<V> extends LinkIterator<Object, V> implements OrderedIterator<V>, ResettableIterator<V> { + /** + * Constructs a new instance. + * + * @param parent The parent AbstractLinkedMap. + */ @SuppressWarnings("unchecked") protected ValuesIterator(final AbstractLinkedMap<?, V> parent) { super((AbstractLinkedMap<Object, V>) parent); 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 27a24b020..c869f3007 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java @@ -220,11 +220,12 @@ public abstract class AbstractMultiValuedMap<K, V> implements MultiValuedMap<K, */ private final class KeysMultiSet extends AbstractMultiSet<K> { - private final class MapEntryTransformer - implements Transformer<Map.Entry<K, Collection<V>>, MultiSet.Entry<K>> { + private final class MapEntryTransformer implements Transformer<Map.Entry<K, Collection<V>>, MultiSet.Entry<K>> { + @Override public MultiSet.Entry<K> transform(final Map.Entry<K, Collection<V>> mapEntry) { return new AbstractMultiSet.AbstractEntry<K>() { + @Override public int getCount() { return mapEntry.getValue().size(); @@ -617,6 +618,11 @@ public abstract class AbstractMultiValuedMap<K, V> implements MultiValuedMap<K, return values().contains(value); } + /** + * Creates a new Collection typed for a given subclass. + * + * @return a new Collection typed for a given subclass. + */ protected abstract Collection<V> createCollection(); /** diff --git a/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java index a5e9ba259..98f81dddf 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java @@ -51,6 +51,9 @@ public abstract class AbstractMapMultiSet<E> extends AbstractMultiSet<E> { /** The parent map */ protected final AbstractMapMultiSet<E> parent; + /** + * The source Iterator. + */ protected final Iterator<Map.Entry<E, MutableInteger>> iterator; /** The last returned entry */
