List of usage examples for java.util Collection addAll
boolean addAll(Collection<? extends E> c);
From source file:dhbw.clippinggorilla.external.solr.SOLR.java
/** * adds documents to solr//from ww w .j ava 2 s .c o m * * @param documents */ public static void addDocument(SolrInputDocument... documents) { Collection<SolrInputDocument> docs = new ArrayList<>(); if (client == null) { setServer(); } docs.addAll(Arrays.asList(documents)); try { client.add(docs); client.commit(); } catch (SolrServerException | IOException e) { Log.error("Solr: Can't add or commit", e); } }
From source file:Main.java
public static <T> boolean addAll(Collection<T> collection, Collection<? extends T> toAdd) { int size = toAdd.size(); boolean result = false; if (size > 0) { if (size < 10) for (T element : toAdd) result |= collection.add(element); else// w w w .java2s .c o m result = collection.addAll(toAdd); } return result; }
From source file:Main.java
public static Collection<Node> search_nodes_by_name(Node root, String name) { Collection<Node> result = new LinkedList<Node>(); if (root.getNodeName().equals(name)) result.add(root);/* www . ja va 2s. c om*/ NodeList list = root.getChildNodes(); for (int i = 0; i < list.getLength(); ++i) { Node child = list.item(i); Collection<Node> ret = search_nodes_by_name(child, name); result.addAll(ret); } return result; }
From source file:Main.java
public static <T> Collection<T> merge(Collection<T> c1, Collection<T> c2) { if (c1 == null || c1.size() == 0) { return c2; }//ww w . j a v a 2s . c om if (c2 == null || c2.size() == 0) { return c1; } Collection<T> all = (c1 instanceof List ? new ArrayList<T>(c1.size() + c2.size()) : new HashSet<T>(c1.size() + c2.size())); all.addAll(c1); all.addAll(c2); return all; }
From source file:de.dhke.projects.cutil.collections.MultiMapUtil.java
public static <V> Collection<V> getTransitive(final MultiMap<V, V> multiMap, final V key, final Collection<V> targetSet) { Collection<V> keyValues = multiMap.get(key); if (keyValues != null) { for (V keyValue : keyValues) { if (!targetSet.contains(keyValue)) { targetSet.add(keyValue); targetSet.addAll(getTransitive(multiMap, keyValue, targetSet)); }/*from ww w. j av a 2s .c o m*/ } } return targetSet; }
From source file:br.msf.commons.netbeans.util.ProjectUtils.java
public static Collection<FileObject> getProjectFiles(final Project project, final FileType... types) { Collection<FileObject> fileObjects = new ArrayList<FileObject>(); Sources srcs = org.netbeans.api.project.ProjectUtils.getSources(project); SourceGroup[] srcGrps = srcs.getSourceGroups(Sources.TYPE_GENERIC); for (SourceGroup srcGrp : srcGrps) { fileObjects.addAll(FileObjectUtils.getFiles(srcGrp.getRootFolder(), true, types)); }//from w ww .j ava 2 s. c om return fileObjects; }
From source file:org.biopax.psidev.ontology_manager.impl.OntologyManagerImpl.java
/** * Collect all available names in the given collection of OntologyAccess terms. * @param terms the terms for which we want the names. * @return a non null collection of names. *//*from w w w .ja va 2s. c o m*/ protected static Collection<String> getTermNames(Collection<OntologyTermI> terms) { if (terms == null) { return Collections.emptyList(); } Collection<String> names = new ArrayList<String>(terms.size()); for (OntologyTermI term : terms) { names.add(term.getPreferredName()); names.addAll(term.getNameSynonyms()); } return names; }
From source file:com.kylinolap.query.routing.QueryRouter.java
private static Collection<TblColRef> getDimensionColumns(OLAPContext olapContext) { Collection<TblColRef> dimensionColumns = new HashSet<TblColRef>(); dimensionColumns.addAll(olapContext.allColumns); for (TblColRef measureColumn : olapContext.metricsColumns) { dimensionColumns.remove(measureColumn); }/* w w w . java2 s . c om*/ return dimensionColumns; }
From source file:Main.java
/** * Appends value to collection. If value is collection all elements are added, if value is object it is simply * added. If skipDuplicates is set to true, objects already contained in the collection are not added again. Note * that element would be type casted to collection type. * /* w w w . j a v a 2 s .c om*/ * @param data * is the collection to update - set, list, etc. Should be modifiable * @param value * is value of type T or {@link Collection} of elements of type T * @param skipDuplicates * whether to treat data as {@link Set}. Note if data is already {@link Set} parameter does not affect * the result. Note if data already contains duplicate elements they are not affected. * @return the updated data collection */ @SuppressWarnings("unchecked") public static <T> Collection<T> addValue(Collection<T> data, Object value, boolean skipDuplicates) { if (value instanceof Collection) { Collection<T> toBeAdded = (Collection<T>) value; if (skipDuplicates && !(data instanceof Set)) { Set<T> nonDuplicates = new LinkedHashSet<>(toBeAdded); nonDuplicates.removeAll(data); data.addAll(nonDuplicates); } else { data.addAll(toBeAdded); } } else if (value != null) { if (skipDuplicates && !(data instanceof Set) && data.contains(value)) { return data; } data.add((T) value); } return data; }
From source file:com.wolvereness.overmapped.lib.WellOrdered.java
private static <T> void addToAsLinkedList(final T token, final Map<T, Collection<T>> map, final Collection<T> tokens) { Collection<T> c = map.get(token); if (c == null) { map.put(token, c = newLinkedList()); }//from ww w. j a v a 2 s . c om c.addAll(tokens); }