List of usage examples for java.util Collection add
boolean add(E e);
From source file:Main.java
public static <E> Collection<E> including(Collection<E> collection, E object) throws Exception { collection.add(object); return collection; }
From source file:Main.java
public static <T> void addIfNotExist(T item, Collection<T> col) { if (!col.contains(item)) { col.add(item); }/* w ww. jav a 2 s.c om*/ }
From source file:Main.java
public static <T> void addItemSafely(Collection<T> collection, T item) { if (item != null) { collection.add(item); }/*from w ww.j a v a 2s .c o m*/ }
From source file:Main.java
public static <T> Collection<T> collectionEnumerationElements(Enumeration<T> source, Collection<T> target) { while (source.hasMoreElements()) { target.add(source.nextElement()); }//w w w . j a va 2s . c om return target; }
From source file:Main.java
public static <T> void add_new(Collection<T> target, T element) { if (!(target.contains(element))) target.add(element); }
From source file:Main.java
protected static void fillAllDescendants(Container c, Class findClass, boolean deep, Collection results) { if (findClass.isInstance(c)) { results.add(c); if (!deep) return; }/*w w w.j ava 2 s . c om*/ for (int i = 0; i < c.getComponentCount(); i++) { Component comp = c.getComponent(i); if (comp instanceof Container) fillAllDescendants((Container) comp, findClass, deep, results); } }
From source file:Main.java
public static <T> void copy(Collection<T> dest, Collection<? extends T> src) { for (T t : src) { dest.add(t); }/*from ww w. ja v a 2 s.com*/ }
From source file:Main.java
final static public Collection createCollection(Object object) { Collection collection = createCollection(); collection.add(object); return collection; }
From source file:Main.java
public static <T> void addIfNotNull(final Collection<T> collection, final T item) { if (item != null) { collection.add(item); }//from w w w.ja v a 2 s. c o m }
From source file:Main.java
public static <T> Collection<T> union(Collection<T> set1, Collection<T> set2) { Collection<T> union = new ArrayList<T>(); for (T t : set1) { union.add(t); }// w ww . ja va 2 s . c o m for (T t : set2) { union.add(t); } return union; }