Here you can find the source of addAllIfNotNull(final Collection
static <V> void addAllIfNotNull(final Collection<V> collection, final Collection<V> values)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { static <V> void addAllIfNotNull(final Collection<V> collection, final Collection<V> values) { if (collection != null && values != null) { collection.addAll(values);/*from w ww .ja v a 2 s. co m*/ } } static <V> void addAll(final Collection<V> collection, final Iterable<V> values) { if (values != null) { for (final V value : values) { collection.add(value); } } } }