[Fwd: Code review request: 7072353 JNDI libraries do not build with javac -Xlint:all -Werror]

Rémi Forax forax at univ-mlv.fr
Thu Aug 4 18:07:54 UTC 2011


On 08/04/2011 07:39 PM, Colin Decker wrote:
> Well, Iterator doesn't have an iterator() method. It also looks like 
> you'd have to have a reference to a single Enumeration already there? 
> I was suggesting using a method reference to an Enumeration-returning 
> method so that a fresh Enumeration could be retrieved to back each 
> Iterator created by the resulting Iterable. There may be a better way 
> than I suggested... I just wanted to point out that there's no good 
> reason to create a single-use Iterable for Enumerations when method 
> references could make it easy to create a proper Iterable.
>
> -- 
> Colin

doh, sorry, right.

Rémi

>
>
> On Thu, Aug 4, 2011 at 1:03 PM, Rémi Forax <forax at univ-mlv.fr 
> <mailto:forax at univ-mlv.fr>> wrote:
>
>     On 08/04/2011 06:52 PM, Colin Decker wrote:
>>     No, that copies the Enumeration. I'm talking about something that
>>     creates lazy Iterators backed by Enumerations.
>>
>>     -- 
>>     Colin
>
>     Ok,
>     why not adding a method iterator(Enumeration) that takes an
>     Enumeration and
>     returns an Iterator and then do a method reference on the method
>     iterator.
>
>     Iterable<String> iterable =
>     #Collections.iterator(enumeration).iterator;
>
>     Rémi
>
>
>>
>>
>>     On Thu, Aug 4, 2011 at 12:34 PM, Rémi Forax <forax at univ-mlv.fr
>>     <mailto:forax at univ-mlv.fr>> wrote:
>>
>>         On 08/04/2011 06:17 PM, Colin Decker wrote:
>>
>>             One better way to handle this in Java 8 would be to have
>>             a utility method
>>             that takes a Supplier<Enumeration<E>>  SAM argument (with
>>             a no-arg method
>>             that returns an Enumeration<E>) and returns an
>>             Iterable<E>  that gets a new
>>             Enumeration from the supplier each time iterator() is
>>             called. It could then
>>             be used with method references:
>>
>>             Iterable<E>  iterable =
>>             Util.enumerationIterable(#object.getEnumeration);
>>
>>
>>         you means Collections.list().
>>
>>         Rémi
>>
>>
>
>




More information about the core-libs-dev mailing list