/** * 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; }
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); }
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);
@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); }
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();
@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; } }
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); }
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();
@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); } }
/** * 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); } }
/** {@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)); }
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));
/** * 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()])); }
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 ) ); }
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."); } }
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; }
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()); }