List of usage examples for java.util Collection add
boolean add(E e);
From source file:Main.java
public static Collection intersection(Collection a, Collection b) { Collection results = new HashSet(); for (Iterator i = a.iterator(); i.hasNext();) { Object o = i.next();// w ww .ja v a 2 s . c o m if (b.contains(o)) { results.add(o); } } return results; }
From source file:Main.java
public static <T> void nullFill(final Collection<T> coll, @Nonnegative final int size) { checkNotNull(coll);//from www . j a v a2s . c o m checkArgument(size >= 0, "size is negative"); while (coll.size() < size) { coll.add(null); } }
From source file:Main.java
public static <T> Collection<T> subtract(Collection<T> list1, Collection<T> list2, Comparator<? super T> comp) { Collection<T> removedList = new ArrayList<T>(); for (T item1 : list1) { for (T item2 : list2) { if (comp.compare(item1, item2) == 0) { removedList.add(item1); }/* w w w.java 2 s.com*/ } } list1.removeAll(removedList); return list1; }
From source file:org.mashti.jetson.AbstractTest.java
@Parameterized.Parameters(name = "{index} - client:{0}, server: {1}") public static Collection<Object[]> getParameters() { final Collection<Object[]> parameters = new ArrayList<Object[]>(); parameters.add(new Object[] { LEAN_CLIENT_FACTORY, LEAN_SERVER_FACTORY }); parameters.add(new Object[] { JSON_CLIENT_FACTORY, JSON_SERVER_FACTORY }); return parameters; }
From source file:com.adito.httpunit.HttpTestParser.java
static Collection<HttpTestContainer> generateTests(String[] paths) throws IOException { Collection<HttpTestContainer> tests = new HashSet<HttpTestContainer>(paths.length); for (String path : paths) { tests.add(generateTests(path)); }//w ww . j a v a 2s. c o m return tests; }
From source file:com.enonic.cms.domain.structure.menuitem.section.SectionContentKey.java
public static Collection<SectionContentKey> converToList(int[] array) { if ((array == null) || (array.length == 0)) { return new ArrayList<SectionContentKey>(); }/*from ww w . j a va 2s .c o m*/ Collection<SectionContentKey> list = new ArrayList<SectionContentKey>(array.length); for (int value : array) { list.add(new SectionContentKey(value)); } return list; }
From source file:Main.java
/** * Adds all elements in the iteration to the given collection. * //from w w w . j a v a2 s . c om * @param collection * the collection to add to * @param iterator * the iterator of elements to add, may not be null * @throws NullPointerException * if the collection or iterator is null */ public static void addAll(Collection collection, Iterator iterator) { while (iterator.hasNext()) { collection.add(iterator.next()); } }
From source file:com.projity.grouping.core.model.NodeModelUtil.java
private static void extractNodeList(NodeModel nodeModel, Node parent, Collection result) { if (parent != null) result.add(parent); Collection children = nodeModel.getChildren(parent); if (children != null) { Iterator i = children.iterator(); while (i.hasNext()) { Node n = (Node) i.next(); extractNodeList(nodeModel, n, result); }//from w w w .j a va 2 s. c o m } }
From source file:com.enonic.cms.domain.structure.page.template.PageTemplateKey.java
public static Collection<PageTemplateKey> converToList(int[] array) { if ((array == null) || (array.length == 0)) { return new ArrayList<PageTemplateKey>(); }/*from www . ja v a 2 s . co m*/ Collection<PageTemplateKey> list = new ArrayList<PageTemplateKey>(array.length); for (int value : array) { list.add(new PageTemplateKey(value)); } return list; }
From source file:Main.java
/** * Add a value to a map collection, initializing the key's collection if needed * //from w w w .j a v a 2 s . c o m * @param key Key whose value collection should be added to * @param valueToAdd Vale to add to the key's collection * @param map Map holding collections */ public static <K, V> void addToCollectionMap(K key, V valueToAdd, Map<K, Collection<V>> map) { if (key == null || valueToAdd == null || map == null) { return; } Collection<V> collection = map.get(key); if (collection == null) { collection = Lists.newArrayList(); map.put(key, collection); } collection.add(valueToAdd); }