Post-transform and the standard Collectors
Brian Goetz
brian.goetz at oracle.com
Wed Jun 12 16:25:13 PDT 2013
OK, we're getting distracted. I'd like to finish the discussion on the
Collectors before we devolve into the wildcard debate (because that may
never terminate.) There were a number of questions posed about the
proper set, naming, and behavior of the canned Collectors under this
model. Let's finish that before getting further distracted. Then we
can compare all of the workarounds for avoiding the question mark, and
see if any are better than the disease.
On 6/12/2013 7:16 PM, Remi Forax wrote:
> On 06/13/2013 01:09 AM, Brian Goetz wrote:
>>>> private static<T,A,R> Collector<T,A,R> wrapHelper(Collector<T,A,R> c) {
>>>> return new CollectorImpl<>(
>>>> () -> { print("hello"); return c.resultContainer(); },
>>>> ...
>>>> );
>>>> }
>>>>
>>>> static<T,R> Collector<T,?,R> wrap(Collector<T,?,R> c) { return
>> ^^^^^^^^^^^^^^^^^^
>>>> wrapHelper(c); }
>>>>
>>>> Now, what was the point of this exercise?
>>>
>>> you cheat :)
>>> the exercice is to take a Collector<T,?,R> not a Collector<T,A,R> as
>>> parameter and return value.
>>
>> Read above. The public method takes a Collector<T,?,R> and uses a
>> private helper method to give a name to the capture of ?. (See lines
>> highlighted above.) Not cheating at all!
>>
>> Now, what was the point of this exercise?
>
> You can not write it without doing a capture (like you do and like very
> few does).
>
> Rémi
>
More information about the lambda-libs-spec-observers
mailing list