I am facing a challenge where my use case is :
OrderItem orderItem = ServicesUtil.getOrderItemValue(drawStore.getOrderItem().getItem(), "Item1");
if(null==orderItem){
orderItem = ServicesUtil.getOrderItemValue(drawStore.getOrderItem().getItem(), "Item2");
}
Here, as per the key with "Item1" if not found, my order item will be null, so I had checked for "Item2", and subsequent I can get the whole payload in case, key "Item1" is not found.
But this brings a term, where, my order item is now getting a reference to null which should never be dereferenced/accessed.
In this case, how can I filter based on the key and not really go for checking order item as null to avoid Null pointers dereferencing issue?