Sample code for reducing null checks in java