john.r.rose at oracle.com
Thu Apr 18 19:06:41 PDT 2013
On Apr 18, 2013, at 6:56 PM, Jed Wesley-Smith <jed at wesleysmith.io> wrote:
> myMap.getAsOptional(myKey).map((Map.Entry<K, V> e) -> e.getValue()).orElse(() -> z)
I also considered Map.getEntryAsOptional: Since (hypothetical) getEntry cannot return null, Optional<Entry> is good.
But the use cases are verbose, partly because you need to declare a temp of type Optional<Entry<K,V>>. And/or you need some funky methods on Optional (as above). (New default methods on Entry won't seem to help, alas.) Either way the use cases are not very ... usable.
More information about the lambda-dev