[
https://issues.apache.org/jira/browse/COLLECTIONS-471?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13834559#comment-13834559
]
Thomas Neidhart commented on COLLECTIONS-471:
---------------------------------------------
Good question.
The AbstractIteratorDecorator defines a getIterator method, which is protected,
thus only intended to be used by derived classes, not by users. This is similar
to the collection-type decorators, where the corresponding decorated() method
is usually also protected.
For our iterator decorators it is less likely that somebody will extend them,
so there is less of a need to provide access to the underlying iterator, and I
fail to see a use-case where a user decorates an iterator and later on wants to
retrieve the decorated iterator again (and would rather design the API in a way
to prevent such usage).
That said, there are now some iterator decorators, like Unmodifiable that
provide access to the decorated iterator, and some of the newer ones, like
PeekingIterator, that dont. I would prefer to not provide access at all and
deprecate the existing getIterator() methods for future versions. There are
some weird things in the API that were added a long time ago, and I did not
want to change *everything* when doing the 4.0 release, but we can decide to
gradually improve the API and deprecate things that do not make sense anymore.
> Add a BoundedIterator which returns at most limit elements
> ----------------------------------------------------------
>
> Key: COLLECTIONS-471
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-471
> Project: Commons Collections
> Issue Type: New Feature
> Reporter: Thomas Neidhart
> Fix For: 4.0.1
>
> Attachments: BoundedIterator.java, BoundedIteratorTest.java
>
>
> It would be nice to have a decorator which bounds the number of elements
> returned by the decorated iterator.
--
This message was sent by Atlassian JIRA
(v6.1#6144)