I need a generic way for null check. I came up with a requirement. This is my setter method for a class:
placeHolderValues.setCurrentAddressCountry(communicationSO.getApplicationDetailSO().getApplicantDetails().get(0).getAddressDetail().get(0).getCountry());
I want to set values in placeHolderValues.setCurrentAddressCountry()
only when value is present. If any of the getApplicationDetailSO()
or getApplicantDetails()
or getAddressDetail()
or getCountry()
is NULL then I have to set NULL in placeHolderValues.setCurrentAddressCountry()
. I have almost 30 such types of setter.
I need a common method to achieve the same.