Example usage for com.google.common.collect ImmutableSet forEach

List of usage examples for com.google.common.collect ImmutableSet forEach

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSet forEach.

Prototype

default void forEach(Consumer<? super T> action) 

Source Link

Document

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

Usage

From source file:rocks.devonthe.stickychunk.database.SqlDatabase.java

public void saveUserData(ImmutableSet<UserData> loadedRegions) {
    loadedRegions.forEach(this::saveUserData);
}

From source file:com.facebook.buck.apple.AppleLibraryDescriptionSwiftEnhancer.java

@SuppressWarnings("unused")
public static BuildRule createSwiftCompileRule(BuildTarget target, CellPathResolver cellRoots,
        ActionGraphBuilder graphBuilder, SourcePathRuleFinder ruleFinder, BuildRuleParams params,
        AppleNativeTargetDescriptionArg args, ProjectFilesystem filesystem, CxxPlatform platform,
        AppleCxxPlatform applePlatform, SwiftBuckConfig swiftBuckConfig,
        ImmutableSet<CxxPreprocessorInput> inputs) {

    SourcePathRuleFinder rulePathFinder = new SourcePathRuleFinder(graphBuilder);
    SwiftLibraryDescriptionArg.Builder delegateArgsBuilder = SwiftLibraryDescriptionArg.builder();
    SwiftDescriptions.populateSwiftLibraryDescriptionArg(swiftBuckConfig,
            DefaultSourcePathResolver.from(rulePathFinder), delegateArgsBuilder, args, target);
    SwiftLibraryDescriptionArg swiftArgs = delegateArgsBuilder.build();

    Preprocessor preprocessor = platform.getCpp().resolve(graphBuilder);

    ImmutableSet<BuildRule> inputDeps = RichStream.from(inputs)
            .flatMap(input -> RichStream.from(input.getDeps(graphBuilder, rulePathFinder))).toImmutableSet();

    ImmutableSortedSet.Builder<BuildRule> sortedDeps = ImmutableSortedSet.naturalOrder();
    sortedDeps.addAll(inputDeps);//from   w  w w.ja v a 2 s  .  c om

    BuildRuleParams paramsWithDeps = params.withExtraDeps(sortedDeps.build());

    PreprocessorFlags.Builder flagsBuilder = PreprocessorFlags.builder();
    inputs.forEach(input -> flagsBuilder.addAllIncludes(input.getIncludes()));
    inputs.forEach(input -> flagsBuilder.addAllFrameworkPaths(input.getFrameworks()));
    PreprocessorFlags preprocessorFlags = flagsBuilder.build();

    Optional<CxxPreprocessorInput> underlyingModule = AppleLibraryDescription
            .underlyingModuleCxxPreprocessorInput(target, graphBuilder, platform);

    return SwiftLibraryDescription.createSwiftCompileRule(platform, applePlatform.getSwiftPlatform().get(),
            swiftBuckConfig, target, paramsWithDeps, graphBuilder, rulePathFinder, cellRoots, filesystem,
            swiftArgs, preprocessor, preprocessorFlags, underlyingModule.isPresent());
}

From source file:de.se_rwth.monticoreeditor.Resolving.java

void buildProject(IProject project, ImmutableSet<ModelState> modelStates, ImmutableList<Path> modelPath) {
    ModelStatesInProject astMapper = getModelStatesInProject(project);
    modelStates.forEach(astMapper::acceptModelState);
    SymbolTableMaintainer symbolTableMaintainer = getSymbolTableMaintainer(project, modelPath);
    modelStates.forEach(symbolTableMaintainer::acceptModelState);
}

From source file:de.monticore.umlcd4a.texteditor.Resolving.java

void buildProject(IProject project, ImmutableSet<ModelState> modelStates, ImmutableList<Path> modelPath) {
    ModelStatesInProject modelStatesInProject = getModelStatesInProject(project);
    modelStates.forEach(modelStatesInProject::acceptModelState);
    SymbolTableMaintainer symbolTableMaintainer = getSymbolTableMaintainer(project, modelPath);
    modelStates.forEach(symbolTableMaintainer::acceptModelState);
}

From source file:de.se_rwth.monticoreeditor.MonticoreLanguage.java

@Override
public void buildProject(IProject project, ImmutableSet<ModelState> modelStates,
        ImmutableList<Path> modelPath) {
    resolving.buildProject(project, modelStates, modelPath);
    modelStates.forEach(state -> {
        Log.getFindings().clear();//from w  ww.  j  a va2  s  .c  om
        checkContextConditions(state);
        addErrors(state);
    });
}

From source file:com.facebook.buck.jvm.java.JarBuilder.java

public JarBuilder setAlreadyAddedEntries(ImmutableSet<String> alreadyAddedEntries) {
    alreadyAddedEntries.forEach(this.alreadyAddedEntries::add);
    return this;
}

From source file:com.facebook.buck.features.apple.project.WorkspaceAndProjectGenerator.java

/**
 * Add a workspace scheme for each extension bundled with the source target of the workspace.
 *
 * @param projectGraph//from w  w w.  ja  v a2s . c  o m
 * @param schemeName
 * @param schemeArguments
 * @param schemeConfigsBuilder
 * @param schemeNameToSrcTargetNodeBuilder
 */
private static void addWorkspaceExtensionSchemes(TargetGraph projectGraph, String schemeName,
        XcodeWorkspaceConfigDescriptionArg schemeArguments,
        ImmutableMap.Builder<String, XcodeWorkspaceConfigDescriptionArg> schemeConfigsBuilder,
        ImmutableSetMultimap.Builder<String, Optional<TargetNode<?>>> schemeNameToSrcTargetNodeBuilder) {
    if (!schemeArguments.getSrcTarget().isPresent()) {
        return;
    }

    LOG.debug("Potentially adding extension schemes for %s", schemeName);

    BuildTarget sourceBuildTarget = schemeArguments.getSrcTarget().get();
    TargetNode<?> sourceTargetNode = projectGraph.get(sourceBuildTarget);
    Set<BuildTarget> sourceTargetBuildDeps = sourceTargetNode.getBuildDeps();

    // Filter all of the source target's deps to find the bundled extensions that get an implicit
    // scheme.
    ImmutableSet<BuildTarget> implicitSchemeBuildTargets = sourceTargetBuildDeps.stream()
            .filter(t -> shouldIncludeImplicitExtensionSchemeForTargetNode(projectGraph.get(t)))
            .collect(ImmutableSet.toImmutableSet());

    // Create scheme for each bundled extension to allow Xcode to automatically begin debugging them
    // when this scheme it selected.
    implicitSchemeBuildTargets.forEach((buildTarget -> {
        String extensionSchemeName = schemeName + "+" + buildTarget.getShortName();
        TargetNode<?> targetNode = projectGraph.get(buildTarget);

        schemeConfigsBuilder.put(extensionSchemeName, createImplicitExtensionWorkspaceArgs(sourceBuildTarget));

        schemeNameToSrcTargetNodeBuilder.put(extensionSchemeName, Optional.of(sourceTargetNode));
        schemeNameToSrcTargetNodeBuilder.put(extensionSchemeName, Optional.of(targetNode));
    }));
}

From source file:com.zulily.omicron.sla.Policy.java

/**
 * Evaluates a list of jobs against the logic of this SLA
 *
 * @param jobs The jobs to evaluate/*ww w .ja v  a 2s .com*/
 * @return A collection of ACTIONABLE alerts from the result
 */
public List<Alert> evaluate(final Iterable<Job> jobs) {

    checkNotNull(jobs, "jobs");

    final List<Alert> result = new ArrayList<>();

    final Set<Long> activeJobIds = new HashSet<>();

    for (Job job : jobs) {

        if (!job.isActive()) {
            // Inactive indicates that the schedule was removed or changed
            // writing log info is noise
            continue;
        }

        if (isDisabled(job)) {
            info("SLA {0} disabled for line {1}", getName(),
                    String.valueOf(job.getCrontabExpression().getLineNumber()));
            continue;
        }

        if (isDowntime(job)) {
            info("Currently in SLA downtime for line {0}",
                    String.valueOf(job.getCrontabExpression().getLineNumber()));
            continue;
        }

        activeJobIds.add(job.getJobId());

        final Alert alert = generateAlert(job);

        if (alert.getAlertStatus() == AlertStatus.NotApplicable) {
            continue;
        }

        AlertLogEntry logEntry = lastAlertLog.get(job.getJobId());

        if (logEntry != null) {

            // Do not alert multiple times for success
            if (alert.getAlertStatus() == AlertStatus.Success && logEntry.getStatus() == AlertStatus.Success) {
                continue;
            }

            // Do not repeat alerts within the threshold
            if (alert.getAlertStatus() == AlertStatus.Failure && delayRepeat(logEntry, job)) {
                continue;
            }

        } else if (alert.getAlertStatus() != AlertStatus.Failure) {
            continue;
        }

        lastAlertLog.put(job.getJobId(), new AlertLogEntry(job.getJobId(), alert.getAlertStatus()));

        result.add(alert);

    }

    // Remove alerts for inactive jobs
    final ImmutableSet<Long> inactiveAlertJobIds = ImmutableSet
            .copyOf(Sets.difference(lastAlertLog.keySet(), activeJobIds));

    inactiveAlertJobIds.forEach(lastAlertLog::remove);

    return result;
}

From source file:de.monticore.umlcd4a.texteditor.CDLanguage.java

@Override
public void buildProject(IProject project, ImmutableSet<ModelState> modelStates,
        ImmutableList<Path> modelPath) {
    Log.getFindings().clear();/*www .  ja  v  a 2 s  . co m*/
    resolving.buildProject(project, modelStates, modelPath);
    modelStates.forEach(state -> {
        Log.getFindings().clear();
        checkContextConditions(state);
    });
}

From source file:com.facebook.buck.parser.ProjectBuildFileParserPool.java

@Override
public void close() {
    ImmutableSet<ResourcePool<ProjectBuildFileParser>> resourcePools;
    synchronized (this) {
        Preconditions.checkState(!closing.get());
        closing.set(true);/* w ww.jav a  2 s.  co  m*/
        resourcePools = ImmutableSet.copyOf(parserResourcePools.values());
    }
    resourcePools.forEach(ResourcePool::close);
}