/** * Release a single reference to the current request scope instance. * <p> * Once all instance references are released, the instance will be recycled. */ @Override public void release() { if (referenceCounter.decrementAndGet() < 1) { try { new HashSet<>(store.keySet()).forEach(this::remove); } finally { logger.debugLog("Released scope instance {0}", this); } } }
/** * Release a single reference to the current request scope instance. * <p> * Once all instance references are released, the instance will be recycled. */ @Override public void release() { if (referenceCounter.decrementAndGet() < 1) { try { new HashSet<>(store.keySet()).forEach(this::remove); } finally { logger.debugLog("Released scope instance {0}", this); } } }
public void predict(Set<String> predictedRelationsRaw, Set<String> goldRelationsRaw) { Set<String> predictedRelations = new HashSet<>(predictedRelationsRaw); predictedRelations.remove(NO_RELATION); Set<String> goldRelations = new HashSet<>(goldRelationsRaw); goldRelations.remove(NO_RELATION); // Register the prediction for (String pred : predictedRelations) { if (goldRelations.contains(pred)) { correctCount.incrementCount(pred); } predictedCount.incrementCount(pred); } goldRelations.forEach(goldCount::incrementCount); HashSet<String> allRelations = new HashSet<String>(){{ addAll(predictedRelations); addAll(goldRelations); }}; allRelations.forEach(totalCount::incrementCount); // Register the confusion matrix if (predictedRelations.size() == 1 && goldRelations.size() == 1) { confusion.add(predictedRelations.iterator().next(), goldRelations.iterator().next()); } if (predictedRelations.size() == 1 && goldRelations.isEmpty()) { confusion.add(predictedRelations.iterator().next(), "NR"); } if (predictedRelations.isEmpty() && goldRelations.size() == 1) { confusion.add("NR", goldRelations.iterator().next()); } }
CommandFactory( final List<AgentCommandArguments> agentCommandArguments, final ApplicationContext applicationContext ) { this.agentCommandArgumentsBeans = agentCommandArguments; this.applicationContext = applicationContext; agentCommandArguments.forEach( commandArgs -> { Sets.newHashSet(commandArgs.getClass().getAnnotation(Parameters.class).commandNames()).forEach( commandName -> { commandMap.put(commandName, commandArgs.getConsumerClass()); } ); } ); }
private String buildDiffs() { final StringBuilder builder = new StringBuilder(); builder.append("acquired but not released:\n"); HashSet<String> keyDiff = new HashSet<>(acquiredCounts.keySet()); keyDiff.removeAll(releasedCounts.keySet()); keyDiff.forEach(k -> { builder.append(k).append("(").append(acquiredCounts.get(k)).append(")\n"); }); builder.append("released but not acquired:\n"); keyDiff.clear(); keyDiff.addAll(releasedCounts.keySet()); keyDiff.removeAll(acquiredCounts.keySet()); keyDiff.forEach(k -> { builder.append(k).append("(").append(releasedCounts.get(k)).append(")\n"); }); return builder.toString(); } }
@Test public void headersWhenDisableThenNoSecurityHeaders() { new HashSet<>(this.expectedHeaders.keySet()).forEach(this::expectHeaderNamesNotPresent); this.headers.disable(); assertHeaders(); }
@Override public void destroyAllData() { // Make a defensive copy of keys, as the map gets cleared when // removing components. new HashSet<>(activeComponents.keySet()) .forEach(component -> removeComponent(component)); } };
/** * A lens that focuses on the keys of a map. * * @param <K> the key type * @param <V> the value type * @return a lens that focuses on the keys of a map */ public static <K, V> Lens.Simple<Map<K, V>, Set<K>> keys() { return simpleLens(m -> new HashSet<>(m.keySet()), (m, ks) -> { HashSet<K> ksCopy = new HashSet<>(ks); Map<K, V> updated = new HashMap<>(m); Set<K> keys = updated.keySet(); keys.retainAll(ksCopy); ksCopy.removeAll(keys); ksCopy.forEach(k -> updated.put(k, null)); return updated; }); }
private void reScanHost(boolean skipExisting) { if (!skipExisting) { new HashSet<>(trackers.values()).forEach(Tracker::cancel); } new SQLBatch() { @Override protected void scripts() { long count = sql("select count(h) from HostVO h", Long.class).find(); sql("select h.uuid from HostVO h", String.class).limit(1000).paginate(count, (List<String> hostUuids) -> { List<String> byUs = hostUuids.stream().filter(huuid -> { if (skipExisting) { return destMaker.isManagedByUs(huuid) && !trackers.containsKey(huuid); } else { return destMaker.isManagedByUs(huuid); } }).collect(Collectors.toList()); trackHost(byUs); }); } }.execute(); }
private void unregisterPassivatedKeys() { /* * Actually unregister anything that was removed in an update that the * client has confirmed that it has applied. */ if (!confirmedUpdates.isEmpty()) { confirmedUpdates.forEach(this::doUnregister); confirmedUpdates.clear(); } }
/** * run node consumer in tx as long as he returns true * * @param consumer the node consumer * @return child instance to make methods of the child class accessible. */ public ME forEachNodeInTx(Consumer<Node> consumer) { withinTransaction(() -> nodes.forEach(consumer)); return self; }
protected static void removeObProjRecord(Collection<Record> records) { new HashSet<>(records) .forEach( record -> { if (!isObProj(record)) { return; } records.remove(record); LOGGER.debug("Found and removed ObProj record: {}", record); }); }
/** * run node consumer in tx as long as he returns true * * @param consumer the node consumer * @return child instance to make methods of the child class accessible. */ public ME forEachNodeInTx(Consumer<Node> consumer) { withinTransaction(() -> nodes.forEach(consumer)); return self; }
public PerlBuiltInVariablesService(Project project) { myPsiManager = PsiManager.getInstance(project); for (int i = 1; i <= 20; i++) { String variableName = Integer.toString(i); myScalars.put(variableName, new PerlBuiltInVariable(myPsiManager, "$" + variableName)); } PerlBuiltInScalars.BUILT_IN.forEach(name -> myScalars.put(name, new PerlBuiltInVariable(myPsiManager, "$" + name))); PerlArrayUtil.BUILT_IN.forEach(name -> myArrays.put(name, new PerlBuiltInVariable(myPsiManager, "@" + name))); PerlHashUtil.BUILT_IN.forEach(name -> myHashes.put(name, new PerlBuiltInVariable(myPsiManager, "%" + name))); PerlGlobUtil.BUILT_IN.forEach(name -> myGlobs.put(name, new PerlBuiltInVariable(myPsiManager, "*" + name))); }
public String toString(int i) { StringBuilder result = new StringBuilder(); getForest().forEach(node -> result.append(node.toString(i))); return result.toString(); }
public Map<String, String> getFullLdContext() { Map<String, String> result = new HashMap<>(); getForest().forEach(child -> result.putAll(child.getFullLdContext())); return result; }
public Map<String, String> getFullLdContext() { Map<String, String> result = new HashMap<>(); getForest().forEach(child -> result.putAll(child.getFullLdContext())); return result; }
private PsiElement[] findLightSymbolDeclarations(@NotNull LightSymbol lightSymbol) { SortedSet<PsiElement> result = new TreeSet<>(Comparator.comparing(PsiElement::getTextOffset)); GlobalDefinitionCollector coll = new GlobalDefinitionCollector(lightSymbol.getContainingFile()); if (coll.getAssignments().containsKey(lightSymbol.getName())) { coll.getAssignments().get(lightSymbol.getName()).forEach( assignmentProperty -> result.add(assignmentProperty.myLhsOfAssignment)); } return result.toArray(PsiElement.EMPTY_ARRAY); }
@After public void shutdownServers() { new HashSet<>(serverRouter.handlerMap.values()).forEach(AbstractServer::shutdown); }