Java Collection Add addIfNotNull(final Collection collection, final V value)

Here you can find the source of addIfNotNull(final Collection collection, final V value)

Description

add If Not Null

License

Apache License

Declaration

static <V> boolean addIfNotNull(final Collection<V> collection, final V value) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Collection;

public class Main {
    static <V> boolean addIfNotNull(final Collection<V> collection, final V value) {
        if (value == null) {
            return false;
        } else {/*from  ww w.  j  a  v a 2s.  c  om*/
            return collection.add(value);
        }
    }
}

Related

  1. addIfNotContains(Collection collection, T value)
  2. addIfNotEmpty(Collection c, Collection elements)
  3. addIfNotNull(Collection c, Object element)
  4. addIfNotNull(Collection coll, T value)
  5. addIfNotNull(Collection listToAddTo, T itemToAddToList, Object objectToCheckIfNull)
  6. addIgnoreNull(Collection collection, Object object)
  7. addIgnoreNull(Collection collection, T object)
  8. addIgnoreNull(final Collection collection, final T object)
  9. addInClauseToQuery(StringBuilder query, Collection l)

    HOME | Copyright © www.java2s.com 2016