DevoxxUK Lambdas Lab

Brian Goetz brian.goetz at oracle.com
Wed Apr 3 05:31:34 PDT 2013


> ACTION:
> Add a static method to Map.Entry:
> public static <K, V> Entry<K, V> of(K key, V value) {
>    return new AbstractMap.SimpleImmutableEntry<K, V>(key, value);
> }

Been down this rathole, and we retreated.  While you can make a stream 
out of Map.Entry, doing anything more than simple filtering and 
forEaching is unlikely to result in a happy outcome.  If it hurts, don't 
do it.

> ACTION:
> Add a much better way to convert a stream of Entry to a Map. Perhaps:
>   .collect(Collectors.toMap(entry -> getKey(), entry -> entry.getValue()));

Or better yet, don't encourage people to make streams of Map.Entry.

> ACTION:
> Can there be some kind of reducingSum() method? It feels like a common
> use case, and might provide the source code for people to look at
> providing the example code for them to then learn and write more
> advanced reducers themselves.

Do you mean something like:

   <T> Collector<T, Integer> counting() {
     return reducing((T t) -> 1, Integer::sum);
   }

?


More information about the lambda-dev mailing list