There are situations where I can simply do not have the chance to test the value before. Eg: setStrings() is automatically invoked by some framework (like Dozer)
Could you make it look like below:
public void setStrings(List<String> value) {
this.strings = null;
if (value != null) {
List<String> draftl = this.getStrings();
draftl.addAll(value);
}
}
One workaround is to use the direct access, but if the incoming list is unmodifiable, then we are on dangerous grounds.
From my point of view the below code is not null safe. If value is null, draftl.addAll(value) will throw a NullPointerException
There are situations where I can simply do not have the chance to test the value before. Eg: setStrings() is automatically invoked by some framework (like Dozer) Could you make it look like below:
One workaround is to use the direct access, but if the incoming list is unmodifiable, then we are on dangerous grounds.