public static <T, K> List<K> map(final List<T> target, final Mapper<T, K> mapper) { if (target == null) { return null; } final List<K> list = new ArrayList<K>(); for (T item : target) { final K mappedItem = mapper.apply(item); if (mappedItem != null) { list.add(mappedItem); } } return (list.size() == 0 ? null : list); }