From d9d6f2098ab3cbaba538de9e6e0b4513d27d9b22 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sun, 23 Jun 2024 08:07:48 -0400 Subject: [PATCH] Package private AbstractEmptyIterator implements ResettableIterator so subclasses don't --- src/changes/changes.xml | 3 ++- .../collections4/iterators/AbstractEmptyIterator.java | 10 ++++++++-- .../commons/collections4/iterators/EmptyIterator.java | 2 +- .../collections4/iterators/EmptyMapIterator.java | 3 +-- .../collections4/iterators/EmptyOrderedIterator.java | 3 +-- .../iterators/EmptyOrderedMapIterator.java | 3 +-- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 6cd97b55a..a1da89db0 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -24,7 +24,8 @@ - Complete bloom filter documentation #507. + Complete bloom filter documentation #507. + Package private AbstractEmptyIterator implements ResettableIterator so subclasses don't. diff --git a/src/main/java/org/apache/commons/collections4/iterators/AbstractEmptyIterator.java b/src/main/java/org/apache/commons/collections4/iterators/AbstractEmptyIterator.java index 857394277..383dcb775 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/AbstractEmptyIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/AbstractEmptyIterator.java @@ -18,12 +18,14 @@ package org.apache.commons.collections4.iterators; import java.util.NoSuchElementException; +import org.apache.commons.collections4.ResettableIterator; + /** - * Provides an implementation of an empty iterator. + * Provides an abstract implementation of an empty iterator. * * @since 3.1 */ -abstract class AbstractEmptyIterator { +abstract class AbstractEmptyIterator implements ResettableIterator { /** * Constructs a new instance. @@ -35,6 +37,7 @@ abstract class AbstractEmptyIterator { throw new UnsupportedOperationException("add() not supported for empty Iterator"); } + @Override public boolean hasNext() { return false; } @@ -43,6 +46,7 @@ abstract class AbstractEmptyIterator { return false; } + @Override public E next() { throw new NoSuchElementException("Iterator contains no elements"); } @@ -59,10 +63,12 @@ abstract class AbstractEmptyIterator { return -1; } + @Override public void remove() { throw new IllegalStateException("Iterator contains no elements"); } + @Override public void reset() { // do nothing } diff --git a/src/main/java/org/apache/commons/collections4/iterators/EmptyIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EmptyIterator.java index e75752fbc..77228f790 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/EmptyIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/EmptyIterator.java @@ -30,7 +30,7 @@ import org.apache.commons.collections4.ResettableIterator; * @param the type of elements returned by this iterator. * @since 2.1.1 and 3.1 */ -public class EmptyIterator extends AbstractEmptyIterator implements ResettableIterator { +public class EmptyIterator extends AbstractEmptyIterator { /** * Singleton instance of the iterator. diff --git a/src/main/java/org/apache/commons/collections4/iterators/EmptyMapIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EmptyMapIterator.java index 44b3354e8..3a6d78e6c 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/EmptyMapIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/EmptyMapIterator.java @@ -17,7 +17,6 @@ package org.apache.commons.collections4.iterators; import org.apache.commons.collections4.MapIterator; -import org.apache.commons.collections4.ResettableIterator; /** * Provides an implementation of an empty map iterator. @@ -27,7 +26,7 @@ import org.apache.commons.collections4.ResettableIterator; * @since 3.1 */ public class EmptyMapIterator extends AbstractEmptyMapIterator implements - MapIterator, ResettableIterator { + MapIterator { /** * Singleton instance of the iterator. diff --git a/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedIterator.java index f4982f76d..066b3c74d 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedIterator.java @@ -17,7 +17,6 @@ package org.apache.commons.collections4.iterators; import org.apache.commons.collections4.OrderedIterator; -import org.apache.commons.collections4.ResettableIterator; /** * Provides an implementation of an empty ordered iterator. @@ -26,7 +25,7 @@ import org.apache.commons.collections4.ResettableIterator; * @since 3.1 */ public class EmptyOrderedIterator extends AbstractEmptyIterator - implements OrderedIterator, ResettableIterator { + implements OrderedIterator { /** * Singleton instance of the iterator. diff --git a/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedMapIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedMapIterator.java index e70ce6758..6c3ba3f4d 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedMapIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedMapIterator.java @@ -17,7 +17,6 @@ package org.apache.commons.collections4.iterators; import org.apache.commons.collections4.OrderedMapIterator; -import org.apache.commons.collections4.ResettableIterator; /** * Provides an implementation of an empty ordered map iterator. @@ -27,7 +26,7 @@ import org.apache.commons.collections4.ResettableIterator; * @since 3.1 */ public class EmptyOrderedMapIterator extends AbstractEmptyMapIterator - implements OrderedMapIterator, ResettableIterator { + implements OrderedMapIterator { /** * Singleton instance of the iterator.