toMap options

Raab, Donald Donald.Raab at gs.com
Tue Apr 9 15:56:47 PDT 2013


3 sounds good to me.  This is the only form we've supported over the years.  I don't recall anyone complaining about the lack of more sugar here.

http://www.goldmansachs.com/gs-collections/javadoc/3.0.0/com/gs/collections/api/RichIterable.html


> 1.  Leave toMap as is, add toIndexedMap (or toKeyedMap) variants.
> 
> 2.  Leave toMap as is, add a two-function version of toMap:
> 
>      <T,K,U>
>      Collector<T, Map<K,U>>
>      toMap(Function<T, K> keyMapper,
>            Function<T, U> valueMapper)
> 
> in which case the regular toMap becomes sugar for
> 
>      toMap(Function.identity(), mapper)
> 
> 3.  Get rid of the current form of toMap, and just have the two-
> function form as in (2).
> 
> 4.  Break free of the toMap naming (recall that until recently this was
> called mappedTo, and prior to that, joiningWith), and have two
> versions:
> mappedTo and mappedFrom.  This is explicit, but also doesn't address
> the use case where both key and value are functions of the stream
> elements.
> 
> Others?



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