Null Safe dereferencing in Java like ?. in Groovy using Maybe monad
- by Sathish
I'm working on a codebase ported from Objective C to Java. There are several usages of method chaining without nullchecks
dog.collar().tag().name()
I was looking for something similar to safe-dereferencing operator ?. in Groovy instead of having nullchecks
dog.collar?.tag?.name
This led to Maybe monad to have the notion of Nothing instead of…