Example usage for java.util Collection add

List of usage examples for java.util Collection add

Introduction

In this page you can find the example usage for java.util Collection add.

Prototype

boolean add(E e);

Source Link

Document

Ensures that this collection contains the specified element (optional operation).

Usage

From source file:Main.java

public static void addIfNotNull(Object item, Collection collection) {
    if (item != null) {
        collection.add(item);
    }/*from ww w .ja v  a2  s  . co  m*/
}

From source file:Main.java

public static <T> void addIfNotNull(Collection<T> col, T val) {
    if (val != null) {
        col.add(val);
    }//from   w w w.j a v  a 2 s  . c  o  m
}

From source file:Main.java

public static <T> Collection<T> merge2copy(Collection<T> collection, T obj) {
    Collection<T> newCollection = new LinkedList<T>(collection);
    newCollection.add(obj);
    return newCollection;
}

From source file:Main.java

public static <E> void addAll(Collection<E> c, E... args) {
    for (E ele : args) {
        c.add(ele);
    }/*from   w  w w .  j ava 2 s. co  m*/
}

From source file:Main.java

public static void addAll(Collection c, Iterator it) {
    while (it.hasNext()) {
        c.add(it.next());
    }
}

From source file:Main.java

public static void addIfNotNull(Collection c, Object element) {
    if (element != null) {
        c.add(element);
    }/*from  www .j a  v a 2 s  . co m*/
}

From source file:Main.java

public static <T> void add(Collection<T> collection, T item) {
    if (item != null) {
        collection.add(item);
    }/*from   ww  w.  j  a v a2 s. co  m*/
}

From source file:Main.java

public static <T> void addIfNonNull(Collection<T> collection, T item) {
    if (item != null) {
        collection.add(item);
    }/*  w  w w.  jav a  2  s  .c om*/
}

From source file:Main.java

final static public Collection<Object> createCollection(Object object) {
    Collection<Object> collection = createCollection();
    collection.add(object);
    return collection;
}

From source file:Main.java

public static <T> void addIfNotNull(Collection<T> collection, T toAdd) {
    if (toAdd != null) {
        collection.add(toAdd);
    }/*from  w  w  w  .  j a  v a2 s .  c o m*/
}