Java tutorial
//package com.java2s; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Set; public class Main { public static <T> List<T> safe(List<T> l) { if (l == null) { return Collections.emptyList(); } return l; } public static <T> Set<T> safe(Set<T> l) { if (l == null) { return Collections.emptySet(); } return l; } public static <T> Collection<T> safe(Collection<T> l) { if (l == null) { return Collections.emptyList(); } return l; } }