I have a class, which has lots of string fields. In the setter methods of all those field I have to do a check like this (As the data may be null):
public void setAddress1(String address1)
{
this.address1 = Contract.checkNull(address1, "");
}
The class Contract is as follows:
public class Contract
{
public static checkNull(String input, String output)
{
return (null == input) ? output : input;
}
}
I have several of fields like 'address1' above. Is there any good method other than the above , to avoid the null? I have read avoiding != null, but is that applicable here ?