Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Collections; import java.util.Map; public class Main { public static void filterNull(Collection<?> collection) { if (isNotEmpty(collection)) { collection.removeAll(Collections.singleton(null)); } } public static boolean isNotEmpty(Collection<?> collection) { return !isEmpty(collection); } public static boolean isNotEmpty(Object[] objects) { return !isEmpty(objects); } public static boolean isNotEmpty(Map<?, ?> map) { return !isEmpty(map); } public static boolean isEmpty(Collection<?> collection) { return collection == null || collection.isEmpty(); } public static boolean isEmpty(Object[] objects) { return objects == null || objects.length == 0; } public static boolean isEmpty(Map<?, ?> map) { return map == null || map.isEmpty(); } }