mergers

Paul Sandoz paul.sandoz at oracle.com
Thu Apr 18 01:35:28 PDT 2013


On Apr 18, 2013, at 3:21 AM, Brian Goetz <brian.goetz at Oracle.COM> wrote:

> Collectors defines three merge functions:
> 
>  throwingMerger -- always throws
>  firstWinsMerger -- takes first
>  lastWinsMerger -- takes last
> 
> These are plain old BinaryOperators that can be used for Map.merge as well as the toMap collectors.
> 
> Someone commented that these look a little out of place in Collectors, and they are certainly not Collector-specific.  Is there a better place for them?
> 

Someone also commented (separately from a survey) that  method refs could be used instead? e.g. like using Integer::sum.

e.g. Objects::first, Objects::second, Objects:throwing

But i thought that might make it harder to correlate with map merging. 

They tend to read well when used with toMap code, but perhaps make more sense as static methods on Map due to Map.merge being present?

Paul.





More information about the lambda-libs-spec-experts mailing list