Tabnine Logo
Collection.addAll
Code IndexAdd Tabnine to your IDE (free)

How to use
addAll
method
in
java.util.Collection

Best Java code snippets using java.util.Collection.addAll (Showing top 20 results out of 27,333)

Refine searchRefine arrow

  • Collection.add
  • Collection.size
  • Iterator.hasNext
  • Iterator.next
  • Arrays.asList
  • Collection.isEmpty
  • Collection.iterator
  • Collection.clear
origin: apache/incubator-druid

protected void addSizedFiles(Collection<File> files)
{
 if (files == null || files.isEmpty()) {
  return;
 }
 long size = 0L;
 for (File file : files) {
  size += file.length();
 }
 this.files.addAll(files);
 this.size += size;
}
origin: hibernate/hibernate-orm

protected void addQuerySpaces(Serializable... spaces) {
  if ( spaces != null ) {
    if ( querySpaces == null ) {
      querySpaces = new ArrayList<>();
    }
    querySpaces.addAll( Arrays.asList( (String[]) spaces ) );
  }
}
origin: spring-projects/spring-framework

/**
 * Determine the cache operation(s) for the given {@link CacheOperationProvider}.
 * <p>This implementation delegates to configured
 * {@link CacheAnnotationParser CacheAnnotationParsers}
 * for parsing known annotations into Spring's metadata attribute class.
 * <p>Can be overridden to support custom annotations that carry caching metadata.
 * @param provider the cache operation provider to use
 * @return the configured caching operations, or {@code null} if none found
 */
@Nullable
protected Collection<CacheOperation> determineCacheOperations(CacheOperationProvider provider) {
  Collection<CacheOperation> ops = null;
  for (CacheAnnotationParser annotationParser : this.annotationParsers) {
    Collection<CacheOperation> annOps = provider.getCacheOperations(annotationParser);
    if (annOps != null) {
      if (ops == null) {
        ops = annOps;
      }
      else {
        Collection<CacheOperation> combined = new ArrayList<>(ops.size() + annOps.size());
        combined.addAll(ops);
        combined.addAll(annOps);
        ops = combined;
      }
    }
  }
  return ops;
}
origin: Sable/soot

private void replaceConstraints(Collection constraints, TypeDecl before, TypeDecl after) {
 Collection newConstraints = new ArrayList();
 for(Iterator i2 = constraints.iterator(); i2.hasNext(); ) {
  TypeDecl U = (TypeDecl)i2.next();
  if(U == before) { //  TODO: fix parameterized type
   i2.remove();
   newConstraints.add(after);
  }
 }
 constraints.addAll(newConstraints);
}
origin: apache/ignite

assert set.size() == 1;
assert set.addAll(c);
assert !set.addAll(c);
assert set.size() == 1 + c.size();
assert set.isEmpty();
Collection<Integer> c1 = Arrays.asList(1, 3, 5, 7, 9);
assert set.size() == cnt;
assert set.size() == set.toArray().length;
assert set.addAll(c1);
assert set.size() == c2.size();
set.clear();
assert set.isEmpty();
  set.iterator().next();
  set.add(null);
origin: apache/geode

@Test
public void queryOnlyWhenIndexIsAvailable() throws Exception {
 setUpMockBucket(0);
 setUpMockBucket(1);
 when(indexForPR.isIndexAvailable(0)).thenReturn(true);
 when(indexForPR.isIndexAvailable(1)).thenReturn(true);
 Set<Integer> buckets = new LinkedHashSet<>(Arrays.asList(0, 1));
 InternalRegionFunctionContext ctx = Mockito.mock(InternalRegionFunctionContext.class);
 when(ctx.getLocalBucketSet((any()))).thenReturn(buckets);
 await().until(() -> {
  final Collection<IndexRepository> repositories = new HashSet<>();
  try {
   repositories.addAll(repoManager.getRepositories(ctx));
  } catch (BucketNotFoundException | LuceneIndexCreationInProgressException e) {
  }
  return repositories.size() == 2;
 });
 Iterator<IndexRepository> itr = repoManager.getRepositories(ctx).iterator();
 IndexRepositoryImpl repo0 = (IndexRepositoryImpl) itr.next();
 IndexRepositoryImpl repo1 = (IndexRepositoryImpl) itr.next();
 assertNotNull(repo0);
 assertNotNull(repo1);
 assertNotEquals(repo0, repo1);
 checkRepository(repo0, 0, 1);
 checkRepository(repo1, 0, 1);
}
origin: commons-collections/commons-collections

  resetFull();
  try {
    Iterator iter = collection.iterator();
    Object o = getOtherElements()[0];
    collection.add(o);
    confirmed.add(o);
    iter.next();
    fail("next after add should raise ConcurrentModification");
  } catch (ConcurrentModificationException e) {
    Iterator iter = collection.iterator();
    collection.addAll(Arrays.asList(getOtherElements()));
    confirmed.addAll(Arrays.asList(getOtherElements()));
    iter.next();
    fail("next after addAll should raise ConcurrentModification");
  } catch (ConcurrentModificationException e) {
  Iterator iter = collection.iterator();
  collection.clear();
  iter.next();
  fail("next after clear should raise ConcurrentModification");
} catch (ConcurrentModificationException e) {
try {
  Iterator iter = collection.iterator();
  List sublist = Arrays.asList(getFullElements()).subList(2,5);
  collection.removeAll(sublist);
  iter.next();
origin: apache/incubator-shardingsphere

  @Override
  public Collection<String> doSharding(final Collection<String> availableTargetNames, final Collection<ShardingValue> shardingValues) {
    Collection<String> shardingResult = shardingAlgorithm.doSharding(availableTargetNames, shardingValues.iterator().next());
    Collection<String> result = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    result.addAll(shardingResult);
    return result;
  }
}
origin: kiegroup/jbpm

public Collection<NodeInstance> getNodeInstances(boolean recursive) {
  Collection<NodeInstance> result = nodeInstances;
  if (recursive) {
    result = new ArrayList<NodeInstance>(result);
    for (Iterator<NodeInstance> iterator = nodeInstances.iterator(); iterator.hasNext(); ) {
      NodeInstance nodeInstance = iterator.next();
      if (nodeInstance instanceof NodeInstanceContainer) {
        result.addAll(((NodeInstanceContainer)
          nodeInstance).getNodeInstances(true));
      }
    }
  }
  return Collections.unmodifiableCollection(result);
}
origin: org.apache.lucene/lucene-core

 BooleanClause c =  cIter.next();
 ScorerSupplier subScorer = w.scorerSupplier(context);
 if (subScorer == null) {
  scorers.get(c.getOccur()).add(subScorer);
if (scorers.get(Occur.SHOULD).size() == minShouldMatch) {
 scorers.get(Occur.MUST).addAll(scorers.get(Occur.SHOULD));
 scorers.get(Occur.SHOULD).clear();
 minShouldMatch = 0;
if (scorers.get(Occur.FILTER).isEmpty() && scorers.get(Occur.MUST).isEmpty() && scorers.get(Occur.SHOULD).isEmpty()) {
} else if (scorers.get(Occur.SHOULD).size() < minShouldMatch) {
if (!needsScores && minShouldMatch == 0 && scorers.get(Occur.MUST).size() + scorers.get(Occur.FILTER).size() > 0) {
 scorers.get(Occur.SHOULD).clear();
origin: google/guava

@CanIgnoreReturnValue
@Override
public boolean putAll(@Nullable K key, Iterable<? extends V> values) {
 checkNotNull(values);
 // make sure we only call values.iterator() once
 // and we only call get(key) if values is nonempty
 if (values instanceof Collection) {
  Collection<? extends V> valueCollection = (Collection<? extends V>) values;
  return !valueCollection.isEmpty() && get(key).addAll(valueCollection);
 } else {
  Iterator<? extends V> valueItr = values.iterator();
  return valueItr.hasNext() && Iterators.addAll(get(key), valueItr);
 }
}
origin: apache/incubator-shardingsphere

/**
 * Parse insert values.
 *
 * @param insertStatement insert statement
 */
public void parse(final InsertStatement insertStatement) {
  Collection<Keyword> valueKeywords = new LinkedList<>();
  valueKeywords.add(DefaultKeyword.VALUES);
  valueKeywords.addAll(Arrays.asList(getSynonymousKeywordsForValues()));
  if (lexerEngine.skipIfEqual(valueKeywords.toArray(new Keyword[valueKeywords.size()]))) {
    parseValues(insertStatement);
  }
}

origin: apache/ignite

/** {@inheritDoc} */
@Override public GridClientData pinNodes(GridClientNode node, GridClientNode... nodes) throws GridClientException {
  Collection<GridClientNode> pinnedNodes = new ArrayList<>(nodes != null ? nodes.length + 1 : 1);
  if (node != null)
    pinnedNodes.add(node);
  if (nodes != null && nodes.length != 0)
    pinnedNodes.addAll(Arrays.asList(nodes));
  return createProjection(pinnedNodes.isEmpty() ? null : pinnedNodes,
    null, null, new GridClientDataFactory(flags));
}
origin: apache/incubator-dubbo

Collection collection = (Collection) value;
if (type.isArray()) {
  int length = collection.size();
  Object array = Array.newInstance(type.getComponentType(), length);
  int i = 0;
  try {
    Collection result = (Collection) type.newInstance();
    result.addAll(collection);
    return result;
  } catch (Throwable e) {
  collection.add(Array.get(value, i));
origin: apache/incubator-shardingsphere

/**
 * Parse select rest.
 */
public final void parse() {
  Collection<Keyword> unsupportedRestKeywords = new LinkedList<>();
  unsupportedRestKeywords.addAll(Arrays.asList(DefaultKeyword.UNION, DefaultKeyword.INTERSECT, DefaultKeyword.EXCEPT, DefaultKeyword.MINUS));
  unsupportedRestKeywords.addAll(Arrays.asList(getUnsupportedKeywordsRest()));
  lexerEngine.unsupportedIfEqual(unsupportedRestKeywords.toArray(new Keyword[unsupportedRestKeywords.size()]));
}

origin: neo4j/neo4j

ControllableStep( String name, LongAdder progress, Configuration config, StatsProvider... additionalStatsProviders )
{
  this.name = name;
  this.progress = progress;
  this.batchSize = config.batchSize(); // just to be able to report correctly
  statsProviders.add( this );
  statsProviders.addAll( Arrays.asList( additionalStatsProviders ) );
}
origin: stagemonitor/stagemonitor

private static void initIncludesAndExcludes() {
  CorePlugin corePlugin = Stagemonitor.getPlugin(CorePlugin.class);
  excludeContaining = new ArrayList<String>(corePlugin.getExcludeContaining().size());
  excludeContaining.addAll(corePlugin.getExcludeContaining());
  excludes = new ArrayList<String>(corePlugin.getExcludePackages().size());
  excludes.add("org.stagemonitor");
  excludes.addAll(corePlugin.getExcludePackages());
  includes = new ArrayList<String>(corePlugin.getIncludePackages().size());
  includes.addAll(corePlugin.getIncludePackages());
  if (includes.isEmpty()) {
    logger.warn("No includes for instrumentation configured. Please set the stagemonitor.instrument.include property.");
  }
}
origin: stackoverflow.com

 private List<File> getListFiles2(File parentDir) {
  List<File> inFiles = new ArrayList<>();
  Queue<File> files = new LinkedList<>();
  files.addAll(Arrays.asList(parentDir.listFiles()));
  while (!files.isEmpty()) {
    File file = files.remove();
    if (file.isDirectory()) {
      files.addAll(Arrays.asList(file.listFiles()));
    } else if (file.getName().endsWith(".csv")) {
      inFiles.add(file);
    }
  }
  return inFiles;
}
origin: spring-projects/spring-security

retainList = new ArrayList(collection.size());
  logger.debug("Filtering collection with " + collection.size()
      + " elements");
collection.clear();
collection.addAll(retainList);
      rootObject.getAuthentication(), Arrays.asList(array));
origin: Bilibili/DanmakuFlameMaster

public void setItems(Collection<BaseDanmaku> items) {
  if (mDuplicateMergingEnabled && mSortType != ST_BY_LIST) {
    synchronized (this.mLockObject) {
      this.items.clear();
      this.items.addAll(items);
      items = this.items;
    }
  } else {
    this.items = items;
  }
  if (items instanceof List) {
    mSortType = ST_BY_LIST;
  }
  mSize.set(items == null ? 0 : items.size());
}
java.utilCollectionaddAll

Javadoc

Attempts to add all of the objects contained in Collectionto the contents of this Collection (optional). If the passed Collectionis changed during the process of adding elements to this Collection, the behavior is not defined.

Popular methods of Collection

  • size
    Returns the number of elements in this collection. If this collection contains more than Integer.MAX
  • iterator
    Returns an iterator over the elements in this collection. There are no guarantees concerning the ord
  • add
  • isEmpty
    Returns true if this collection contains no elements.
  • contains
  • toArray
  • stream
  • forEach
  • remove
  • clear
  • removeAll
  • containsAll
  • removeAll,
  • containsAll,
  • equals,
  • hashCode,
  • retainAll,
  • removeIf,
  • parallelStream,
  • spliterator,
  • <init>

Popular in Java

  • Updating database using SQL prepared statement
  • getSharedPreferences (Context)
  • getResourceAsStream (ClassLoader)
  • getSystemService (Context)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • ImageIO (javax.imageio)
  • JTextField (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now