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 023f497842a9311d6c52fe2cd95756f85a9f8e13 Author: Claude Warren <[email protected]> AuthorDate: Mon Oct 21 14:36:57 2024 +0100 changes as per review --- .../collections4/iterators/ExtendedIterator.java | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/iterators/ExtendedIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ExtendedIterator.java index b794958fb..7b6733543 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/ExtendedIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/ExtendedIterator.java @@ -26,18 +26,17 @@ import java.util.stream.Stream; /** - * A ExtendedIterator is an Iterator wrapping around a plain - * (or presented as plain) Iterator. The wrapping allows the usual - * operations found on streams (filtering, concatenating, mapping) to be done on an Iterator derived - * from some other source. It also provides convenience methods for common operations. + * Extends Iterator functionality to include operations commonly found on streams (e.g. filtering, concatenating, mapping). + * It also provides convenience methods for common operations. * @param <T> The type of object returned from the iterator. + * @since 4.5.0-M3 */ public final class ExtendedIterator<T> implements Iterator<T> { /** * Set to <code>true</code> if this wrapping doesn't permit the use of * {@link #remove()}, otherwise removal is delegated to the base iterator. */ - private final boolean removeDenied; + private final boolean throwOnRemove; /** * Creates an ExtendedIterator wrapped round <code>it</code>, @@ -109,11 +108,11 @@ public final class ExtendedIterator<T> implements Iterator<T> { /** * Initialise this wrapping with the given base iterator and remove-control. * @param base the base iterator that this iterator wraps - * @param removeDenied true if .remove() must throw an exception + * @param throwOnRemove true if .remove() must throw an exception */ - private ExtendedIterator(final Iterator<? extends T> base, final boolean removeDenied) { + private ExtendedIterator(final Iterator<? extends T> base, final boolean throwOnRemove) { this.base = base; - this.removeDenied = removeDenied; + this.throwOnRemove = throwOnRemove; } @Override @@ -133,7 +132,7 @@ public final class ExtendedIterator<T> implements Iterator<T> { @Override public void remove() { - if (removeDenied) { + if (throwOnRemove) { throw new UnsupportedOperationException(); } base.remove(); @@ -160,7 +159,7 @@ public final class ExtendedIterator<T> implements Iterator<T> { ((IteratorChain<T>) base).addIterator(other); return this; } - return new ExtendedIterator<T>(new IteratorChain<T>(this.base, other), this.removeDenied); + return new ExtendedIterator<T>(new IteratorChain<T>(this.base, other), this.throwOnRemove); } /** @@ -170,7 +169,7 @@ public final class ExtendedIterator<T> implements Iterator<T> { * @return An iterator filtered by the predicate. */ public ExtendedIterator<T> filter(final Predicate<T> predicate) { - return new ExtendedIterator<T>(new FilterIterator<>(this, predicate::test), this.removeDenied); + return new ExtendedIterator<T>(new FilterIterator<>(this, predicate::test), this.throwOnRemove); } /**
