RFR(s): 8072726: add adapter to convert Enumeration to Iterator
forax at univ-mlv.fr
Mon May 18 09:19:06 UTC 2015
On 05/18/2015 10:56 AM, Daniel Fuchs wrote:
> Hi Stuart,
> That's an RFE I have often wished for :-)
> I've been wondering whether a static method
> in the class java.util.Collections would be better, since there
> already are some conversion methods there - like:
> public static <T> Enumeration<T> emptyEnumeration();
> public static <T> Enumeration<T> enumeration(final Collection<T> c);
> public static <T> ArrayList<T> list(Enumeration<T> e);
> but I see that Brian already commented in the bug that he
> preferred the default method on Iterator...
I think we should do the opposite move, move the frequently used static
methods from j.u.Collections to the interface their belong to. We have
started this by moving Collections.sort() into List.sort() and we will
soon add methods like of() to support 'collections literal' inside the
As Brian said, it's easier to find a method related to Enumeration
inside Enumeration and j.u.Collections is already to big.
so it's like we should move the code of Collections.emptyEnumeration()
into Enumeration.empty() and let's Collections.emptyEnumeration() to
> I like the examples in the API documentation of the new method.
> Looks good to me!
> best regards,
> -- daniel
> On 16/05/15 02:37, Stuart Marks wrote:
>> Hi all,
>> Please review this small API enhancement to add a default method
>> "asIterator()" to Enumeration that converts it into an Iterator.
More information about the core-libs-dev