I was refactoring some old code of mine that I\'ve written and I stumbeled on this code:
List fullImagePool = new ArrayList<>();
Just write a small utility method:
public static void addAllIfNotNull(List list, Collection extends E> c) {
if (c != null) {
list.addAll(c);
}
}
so that you can write:
List fullImagePool = new ArrayList<>();
addAllIfNotNull(fullImagePool, style.getTestMH());
addAllIfNotNull(fullImagePool, style.getTrousers());
addAllIfNotNull(fullImagePool, style.getDetailRevers());
// ...etc