package eu.dnetlib.miscutils.collections; import java.util.List; import com.google.common.collect.Lists; /** * Utility class which checks ensures that a given collection is not null. * *

* CXF for example cannot distinguish from nulls. This helper allows you write: *

* *
 * for(String bla : EnsureCollection.list(somecode())) {....}
 * 
* * @author marko * */ public class EnsureCollection { /** * returns the argument or a new list if the argument is null. * * @param a type * @param aList a list * @return passthrough or empty list */ public static List list(final List aList) { if (aList == null) return Lists.newArrayList(); return aList; } /** * Alias for static imports. * * @param a type * @param aList a list * @return passthrough or empty list */ public static List notNullList(final List aList) { return list(aList); } }