Java Collection Add addAllIfNotNull(final Collection collection, final Collection values)

Here you can find the source of addAllIfNotNull(final Collection collection, final Collection values)

Description

add All If Not Null

License

Apache License

Declaration

static <V> void addAllIfNotNull(final Collection<V> collection, final Collection<V> values) 

Method Source Code


//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);
            }
        }
    }
}

Related

  1. addAll(S collection, T... values)
  2. addAll(T coll, Collection other)
  3. addAll(T[] lhs, Collection rhs)
  4. addAllFirst(Collection col, Deque deque)
  5. addAllIfNotNull(final Collection collection, final Collection c)
  6. addAllIfSet(Collection target, Collection c)
  7. addAllIgnoreNull(Collection c, T... elements)
  8. addAllIgnoreNull(final Collection target, final Collection source)
  9. addAllNotNull(final Collection c, final E... elements)