In code reviews I stumbled over this java-pattern to avoid NPE’s:
value = (null != someObject) ? someObject.someOtherMethod() : null
I doubt that this is “good style”. I rather think that it delegates the NPE (BTW this sounds similar to mapping over a Scala-Option-value or a Haskell-Maybe… )
Is it good style or not? If not, how to improve ?
Edit: Supposing it scatters your code, the code will get unreadable:
Is this already encapsulated in some libraries / API ? (apache-commons, google-coomons or similar !?)
Maybe Guava will help you.
Also see similar qustion.