List of usage examples for com.google.common.collect ImmutableList forEach
default void forEach(Consumer<? super T> action)
From source file:de.gfelbing.microservice.core.http.jetty.server.JettyServer.java
/** * Invokes @link{addHandler()} for each ContextHandler. * @param contextHandlers Handler to add. * @return itself for chaining.//ww w. ja va 2 s.c om */ public JettyServer addAll(final ImmutableList<ContextHandler> contextHandlers) { contextHandlers.forEach(contextHandler::addHandler); return this; }
From source file:eu.numberfour.n4js.internal.N4FilebasedWorkspaceResourceSetContainerState.java
/** * @param handle/*from w ww . j ava 2 s . c o m*/ * uri for the current project prefixed with {@code FileBasedWorkspace#N4FBPRJ} * @return a list of visible projects in form of handles. */ @Override public List<String> getVisibleContainerHandles(String handle) { URI containerURI = FileBasedWorkspace.uriFrom(handle); List<String> visiContainers = new ArrayList<>(); // add self visiContainers.add(handle); Optional<? extends IN4JSProject> project = in4jscore.findProject(containerURI); if (!project.isPresent()) { throw new IllegalStateException("No project with handle '" + handle + "' known in current In4jscore."); } ImmutableList<? extends IN4JSProject> dps = n4jsmodel.getDependencies((N4JSProject) project.get()); // map uri to handle-form and add. dps.forEach(d -> visiContainers.add(FileBasedWorkspace.handleFrom(d.getLocation()))); return visiContainers; }
From source file:org.apache.james.jmap.api.filtering.impl.FilteringAggregate.java
public List<? extends Event> defineRules(List<Rule> rules) { Preconditions.checkArgument(shouldNotContainDuplicates(rules)); ImmutableList<RuleSetDefined> events = ImmutableList .of(new RuleSetDefined(aggregateId, history.getNextEventId(), ImmutableList.copyOf(rules))); events.forEach(this::apply); return events; }
From source file:com.facebook.presto.execution.ClusterSizeMonitor.java
private synchronized void updateAllNodes(AllNodes allNodes) { if (includeCoordinator) { currentCount = allNodes.getActiveNodes().size(); } else {//from www .j a va 2 s . co m currentCount = Sets.difference(allNodes.getActiveNodes(), allNodes.getActiveCoordinators()).size(); } if (currentCount >= executionMinCount) { ImmutableList<SettableFuture<?>> listeners = ImmutableList.copyOf(futures); futures.clear(); executor.submit(() -> listeners.forEach(listener -> listener.set(null))); } }
From source file:org.apache.james.dlp.eventsourcing.aggregates.DLPDomainConfiguration.java
public List<Event> clear() { ImmutableList<DLPConfigurationItem> rules = retrieveRules().getItems(); if (!rules.isEmpty()) { ImmutableList<Event> events = ImmutableList .of(new ConfigurationItemsRemoved(aggregateId, history.getNextEventId(), rules)); events.forEach(this::apply); return events; } else {/*from w w w . jav a 2s. c om*/ return ImmutableList.of(); } }
From source file:org.apache.james.dlp.eventsourcing.aggregates.DLPDomainConfiguration.java
public List<Event> store(DLPRules updatedRules) { ImmutableSet<DLPConfigurationItem> existingRules = retrieveRules().getItems().stream() .collect(Guavate.toImmutableSet()); ImmutableSet<DLPConfigurationItem> updatedRulesSet = ImmutableSet.copyOf(updatedRules); Optional<Event> removedRulesEvent = generateRemovedRulesEvent(existingRules, updatedRulesSet); Optional<Event> addedRulesEvent = generateAddedRulesEvent(existingRules, updatedRulesSet, computeNextEventId(removedRulesEvent)); ImmutableList<Event> events = Stream.of(removedRulesEvent, addedRulesEvent).flatMap(OptionalUtils::toStream) .collect(Guavate.toImmutableList()); events.forEach(this::apply); return events; }
From source file:com.google.devtools.build.importdeps.ImportDepsChecker.java
/** Emit the jdeps proto. The parameter ruleLabel is optional, indicated with the empty string. */ public Dependencies emitJdepsProto(String ruleLabel) { Dependencies.Builder builder = Dependencies.newBuilder(); ImmutableList<Path> paths = classCache.collectUsedJarsInRegularClasspath(); // TODO(b/77723273): Consider "implicit" for Jars only needed to resolve supertypes paths.forEach(path -> builder .addDependency(Dependency.newBuilder().setKind(Kind.EXPLICIT).setPath(path.toString()).build())); return builder.setRuleLabel(ruleLabel).setSuccess(true).build(); }
From source file:com.google.idea.blaze.cpp.BlazeConfigurationResolver.java
/** * Create a wrapper script that transforms the CLion compiler invocation into a safe invocation of * the compiler script that blaze uses.// www .j ava2 s. c o m * * <p>CLion passes arguments to the compiler in an arguments file. The c toolchain compiler * wrapper script doesn't handle arguments files, so we need to move the compiler arguments from * the file to the command line. * * @param blazeCompilerExecutableFile blaze compiler wrapper * @return The wrapper script that CLion can call. */ @Nullable private static File createCompilerExecutableWrapper(File blazeCompilerExecutableFile) { try { File blazeCompilerWrapper = FileUtil.createTempFile("blaze_compiler", ".sh", true /* deleteOnExit */); if (!blazeCompilerWrapper.setExecutable(true)) { return null; } ImmutableList<String> compilerWrapperScriptLines = ImmutableList.of("#!/bin/bash", "", "# The c toolchain compiler wrapper script doesn't handle arguments files, so we", "# need to move the compiler arguments from the file to the command line.", "", "if [ $# -ne 2 ]; then", " echo \"Usage: $0 @arg-file compile-file\"", " exit 2;", "fi", "", "if [[ $1 != @* ]]; then", " echo \"Usage: $0 @arg-file compile-file\"", " exit 3;", "fi", "", " # Remove the @ before the arguments file path", "ARG_FILE=${1#@}", "# The actual compiler wrapper script we get from blaze", "EXE=" + blazeCompilerExecutableFile.getPath(), "# Read in the arguments file so we can pass the arguments on the command line.", "ARGS=`cat $ARG_FILE`", "$EXE $ARGS $2"); try (PrintWriter pw = new PrintWriter(blazeCompilerWrapper, UTF_8.name())) { compilerWrapperScriptLines.forEach(pw::println); } return blazeCompilerWrapper; } catch (IOException e) { return null; } }
From source file:org.locationtech.geogig.plumbing.diff.MutableTree.java
public RevTree build(ObjectStore store) { final ObjectId treeId = this.node.getObjectId(); final RevTree original = EMPTY_TREE_ID.equals(treeId) ? EMPTY : store.getTree(treeId); CanonicalTreeBuilder builder = CanonicalTreeBuilder.create(store, original);// .clearSubtrees(); ImmutableList<Node> currentTrees = original.trees(); currentTrees.forEach((n) -> builder.remove(n.getName())); for (MutableTree childTree : this.childTrees.values()) { childTree.build(store);/*from w w w . j ava2 s . c om*/ Node newNode = childTree.node; builder.put(newNode); } final Node oldNode = this.node; RevTree newTree = builder.build(); Envelope newBounds = SpatialOps.boundsOf(newTree); Node newNode = oldNode.update(newTree.getId(), newBounds); this.node = newNode; return newTree; }
From source file:com.google.errorprone.bugpatterns.CatchFail.java
private Optional<Fix> rethrowFix(ImmutableList<CatchTree> catchBlocks, VisitorState state) { SuggestedFix.Builder fix = SuggestedFix.builder(); catchBlocks.forEach(c -> { // e.g.//www .jav a2s . com // fail("message") -> throw new AssertionError("message", cause); // assertWithMessage("message format %s", 42) -> // throw new AssertionError(String.format("message format %s", 42), cause); StatementTree statementTree = getOnlyElement(c.getBlock().getStatements()); MethodInvocationTree methodInvocationTree = (MethodInvocationTree) ((ExpressionStatementTree) statementTree) .getExpression(); String message = null; if (message == null && !methodInvocationTree.getArguments().isEmpty()) { message = getMessageOrFormat(methodInvocationTree, state); } if (message != null) { // only catch and rethrow to add additional context, not for raw `fail()` calls fix.replace(statementTree, String.format("throw new AssertionError(%s, %s);", message, c.getParameter().getName())); } }); return fix.isEmpty() ? Optional.empty() : Optional.of(fix.build()); }