Here you can find the source of addIgnoreNull(Collection super T> collection, T object)
Parameter | Description |
---|---|
collection | the collection to add to, must not be null |
object | the object to add, if null it will not be added |
Parameter | Description |
---|---|
NullPointerException | if the collection is null |
private static <T> boolean addIgnoreNull(Collection<? super T> collection, T object)
//package com.java2s; // Distributed under the OSI-approved BSD 3-Clause License. import java.util.Collection; public class Main { /**/*from www .j a va 2 s.co m*/ * From Apache commons-collection. * * Adds an element to the collection unless the element is null. * * @param collection the collection to add to, must not be null * @param object the object to add, if null it will not be added * @return true if the collection changed * @throws NullPointerException if the collection is null * @since Commons Collections 3.2 */ private static <T> boolean addIgnoreNull(Collection<? super T> collection, T object) { return (object == null ? false : collection.add(object)); } }