Consider member variable:
String foo;
I only want to call setFoo
if foo
has not previously been set or currently is empty.
For this purpose, I am not sure if this is sufficient:
if(foo==null || foo.isEmpty()) {
setFoo(foo);
}
Or is it safer to also check for null on the other side of the OR condition:
if(foo==null || (foo!=null && foo.isEmpty())) {
setFoo(foo);
}