Round 2 feedback

Michael Nascimento misterm at
Wed Feb 13 06:25:19 PST 2013

On Sat, Feb 9, 2013 at 11:41 PM, Sam Pullara <sam at> wrote:
> On Sat, Feb 9, 2013 at 4:34 PM, Michael Nascimento <misterm at> wrote:
>> - We use many Maps here, with many transformations. It is still painful to
>> do operations like transformValues, because it usually involves using other
>> lambdas and then type inference fails, still requiring specificying the
>> actual type parameters - and this might require many parameters sometimes;

Ok, NetBeans is actually to blame here, sorry for that:

>> - At least here, even simple transformations such as
>> myCollection.parallelStream().map(Functions.string()).collect(Collectors.<String>toList())
>> requires the explicit types;

Same issue as above.

>> - groupingBy that returns a Map keyed by the Stream type is completely
>> unintuitive. If not by the suggestion from the mailing list, I would never
>> think of it as being applicable to my use case. A better name is certainly
>> desirable;

Sorry again, I meant joiningWith... I wrote this without having access
to the actual code I've written...

>> - It seems odd to have collect and collectUnordered when some Collectors
>> are naturally unordered, such as toSet. Can't it be changed to be a
>> property of the Collector somehow?;
> I think this is something that you need to tell it for the case where
> you don't care. You might be able to optimize those cases where it is
> obvious but this mostly if you don't care about the ordering of an
> ordered one.

Please correct me if I am wrong, but the toSet collector is not
order-preserving for an ordered stream, right? That's why I think
having collectUnordered as a different method feels odd. Some
collectors are order-preserving, some are not and with some you can
choose, but I think the choice should be made as you create the
collector, not in the method call in Stream.

>> - computeIfAbsent is useful, but for most Guava cases I wanted to lambdify
>> I actually needed a method that returns an Optional instead. Can it be
>> added?;
> This works:
>         numbers.computeIfAbsent("six", (k) -> null);
>         assertFalse(numbers.containsKey("six"));
> From the javadoc:
> "If the function returns {@code null} no mapping is recorded."
> Is that sufficient?

No, what I want is something like:


You need something this concise to use maps in lambda expressions.


More information about the lambda-dev mailing list