Post-transform and the standard Collectors

Remi Forax forax at univ-mlv.fr
Wed Jun 12 17:14:43 PDT 2013


On 06/13/2013 01:25 AM, Brian Goetz wrote:
> 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.

Ok,
making the accumulator a bi-consumer instead of a bi-function (thus 
removing STRICTLY_MUTATIVE) is something enough important to postpone 
this discussion.

Rémi

>
> 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-experts mailing list