A suggestion: Map.checkAndGet

Doug Lea dl at cs.oswego.edu
Wed Oct 31 06:53:13 PDT 2012

On 10/31/12 07:44, David Holmes wrote:
> Boaz pointed out to me that my suggestion assumes Maps with no null values.

As an aside, ConcurrentHashMap has never allowed null keys or values,
which allows "null" to consistently always mean "nothing there".
This initially made atomicity guarantees possible (no need for
separate calls to containsKey), and has made it much easier to
make JDK8 version lambda-friendly, including computeIfAbsent,
getValueOrDefault, etc methods, plus bulk operations, without ever
relying on "Optional" (which is another way of saying "nothing there").
For preview release API (that has not yet been fully integrated with
Streams), see:



More information about the lambda-dev mailing list