Is there an analogous method to StringUtils.defaultString for collections, so you can avoid checking for null value, since in most cases, the desired effect is the same as if it were an empty list?
e.g. to replace
if (list != null) {
for (String item: list) {
// ...
}
}
with something like
for (String item: ListUtils.defaultList(list)) {
// ...
}
Using the ternary operator is pretty ugly and cause unchecked casting errors:
List<String> safelista = (List<String>) (list != null ? list : Collections.emptyList());
List<String> safelistb = (list != null ? list : Collections.EMPTY_LIST);
Putting it inline is even uglier.