Details
-
Wish
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
Description
Would it be possible to add methods to CollectionUtils that return an empty collection if given a null? e.g.
public static <T> List<T> emptyIfNull(List<T> list) { return list == null ? Collections.<T>emptyList() : list; } public static <T> Set<T> emptyIfNull(Set<T> set) { return set == null ? Collections.<T>emptySet() : set; } public static <K,V> Map<K,V> emptyIfNull(Map<K,V> map) { return map == null ? Collections.<K,V>emptyMap() : map; }