Example usage for com.google.common.collect ImmutableSet.Builder addAll

List of usage examples for com.google.common.collect ImmutableSet.Builder addAll

Introduction

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

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:org.sosy_lab.cpachecker.cpa.validvars.ValidVars.java

public ValidVars extendGlobalVars(String varName) {
    if (varName != null) {
        ImmutableSet.Builder<String> builder = ImmutableSet.builder();
        builder.addAll(globalValidVars);
        builder.add(varName);/*w w  w  .  java 2  s . c  o m*/
        return new ValidVars(builder.build(), localValidVars, numFunctionCalled);
    }
    return this;
}

From source file:com.facebook.presto.execution.scheduler.SourcePartitionedScheduler.java

private Set<RemoteTask> assignSplits(Multimap<Node, Split> splitAssignment) {
    ImmutableSet.Builder<RemoteTask> newTasks = ImmutableSet.builder();
    for (Entry<Node, Collection<Split>> taskSplits : splitAssignment.asMap().entrySet()) {
        newTasks.addAll(stage.scheduleSplits(taskSplits.getKey(), taskSplits.getValue()));
        scheduledNodes.add(taskSplits.getKey().getNodeIdentifier());
    }/* w w  w  .j a va  2  s .  c  om*/
    return newTasks.build();
}

From source file:org.onosproject.onosjar.OnosJarStepFactory.java

@Override
public void createCompileToJarStep(BuildContext context, ImmutableSortedSet<Path> sourceFilePaths,
        BuildTarget invokingRule, SourcePathResolver resolver, ProjectFilesystem filesystem,
        ImmutableSortedSet<Path> declaredClasspathEntries, Path outputDirectory,
        Optional<Path> workingDirectory, Path pathToSrcsList, Optional<SuggestBuildRules> suggestBuildRules,
        ImmutableList<String> postprocessClassesCommands, ImmutableSortedSet<Path> entriesToJar,
        Optional<String> mainClass, Optional<Path> manifestFile, Path outputJar,
        ClassUsageFileWriter usedClassesFileWriter, ImmutableList.Builder<Step> steps,
        BuildableContext buildableContext, ImmutableSet<Pattern> classesToRemoveFromJar) {

    ImmutableSet.Builder<Path> sourceFilePathBuilder = ImmutableSet.builder();
    sourceFilePathBuilder.addAll(sourceFilePaths);

    ImmutableSet.Builder<Pattern> blacklistBuilder = ImmutableSet.builder();
    blacklistBuilder.addAll(classesToRemoveFromJar);

    // precompilation steps
    //   - generate sources
    //     add all generated sources ot pathToSrcsList
    if (webContext != null && apiTitle != null && resources.isPresent()) {
        ImmutableSortedSet<Path> resourceFilePaths = findSwaggerModelDefs(resolver, resources.get());
        blacklistBuilder.addAll(resourceFilePaths.stream()
                .map(rp -> Pattern.compile(rp.getFileName().toString(), Pattern.LITERAL))
                .collect(Collectors.toSet()));
        Path genSourcesOutput = workingDirectory.get();

        SwaggerStep swaggerStep = new SwaggerStep(filesystem, sourceFilePaths, resourceFilePaths,
                genSourcesOutput, outputDirectory, webContext, apiTitle, apiVersion, apiPackage,
                apiDescription);/* w  w w .  j a  v a2s  .c o m*/
        sourceFilePathBuilder.add(swaggerStep.apiRegistratorPath());
        steps.add(swaggerStep);

        //            steps.addAll(sourceFilePaths.stream()
        //                    .filter(sp -> sp.startsWith("src/main/webapp/"))
        //                    .map(sp -> CopyStep.forFile(filesystem, sp, outputDirectory))
        //                    .iterator());
    }

    createCompileStep(context, ImmutableSortedSet.copyOf(sourceFilePathBuilder.build()), invokingRule, resolver,
            filesystem, declaredClasspathEntries, outputDirectory, workingDirectory, pathToSrcsList,
            suggestBuildRules, usedClassesFileWriter, steps, buildableContext);

    // post compilation steps

    // FIXME BOC: add mechanism to inject new Steps
    //context.additionalStepFactory(JavaStep.class);

    // build the jar
    steps.add(new JarDirectoryStep(filesystem, outputJar, ImmutableSortedSet.of(outputDirectory),
            mainClass.orNull(), manifestFile.orNull(), true, blacklistBuilder.build()));

    OSGiWrapper osgiStep = new OSGiWrapper(outputJar, //input jar
            outputJar, //Paths.get(outputJar.toString() + ".jar"), //output jar
            invokingRule.getBasePath(), // sources dir
            outputDirectory, // classes dir
            declaredClasspathEntries, // classpath
            bundleName, // bundle name
            groupId, // groupId
            bundleVersion, // bundle version
            bundleLicense, // bundle license
            importPackages, // import packages
            exportPackages, // export packages
            includeResources, // include resources
            webContext, // web context
            dynamicimportPackages, // dynamic import packages
            bundleDescription // bundle description
    );
    steps.add(osgiStep);

    //steps.add(CopyStep.forFile(filesystem, Paths.get(outputJar.toString() + ".jar"), outputJar));

}

From source file:org.fcrepo.kernel.impl.rdf.impl.TypeRdfContext.java

private void concatRdfTypes() throws RepositoryException {
    final ImmutableList.Builder<NodeType> nodeTypesB = ImmutableList.<NodeType>builder();

    final NodeType primaryNodeType = resource().getNode().getPrimaryNodeType();

    if (primaryNodeType != null) {
        nodeTypesB.add(primaryNodeType);
    }/*from ww  w.  ja va 2s .  co m*/

    try {
        final Set<NodeType> primarySupertypes = ImmutableSet.<NodeType>builder()
                .add(primaryNodeType.getSupertypes()).build();
        nodeTypesB.addAll(primarySupertypes);
    } catch (NullPointerException e) {
        // ignore
    }

    final NodeType[] mixinNodeTypesArr = resource().getNode().getMixinNodeTypes();

    if (mixinNodeTypesArr != null) {
        final Set<NodeType> mixinNodeTypes = ImmutableSet.<NodeType>builder().add(mixinNodeTypesArr).build();
        nodeTypesB.addAll(mixinNodeTypes);

        final ImmutableSet.Builder<NodeType> mixinSupertypes = ImmutableSet.<NodeType>builder();
        for (final NodeType mixinNodeType : mixinNodeTypes) {
            mixinSupertypes.addAll(ImmutableSet.<NodeType>builder().add(mixinNodeType.getSupertypes()).build());
        }

        nodeTypesB.addAll(mixinSupertypes.build());
    }

    final ImmutableList<NodeType> nodeTypes = nodeTypesB.build();
    final Iterator<NodeType> nodeTypesIt = nodeTypes.iterator();

    concat(Iterators.transform(nodeTypesIt, nodetype2triple()));
}

From source file:com.facebook.buck.rules.DefaultTargetNode.java

@Override
public ImmutableSet<BuildTarget> getDeps() {
    ImmutableSet.Builder<BuildTarget> builder = ImmutableSet.builder();
    builder.addAll(getDeclaredDeps());
    builder.addAll(getExtraDeps());/* w ww. jav  a 2s. c  om*/
    return builder.build();
}

From source file:com.facebook.buck.features.project.intellij.BaseIjModuleRule.java

private ImmutableSet<Path> findConfiguredGeneratedSourcePaths(TargetNode<T> targetNode) {
    ImmutableSet.Builder<Path> generatedSourcePaths = ImmutableSet.builder();

    generatedSourcePaths.addAll(findConfiguredGeneratedSourcePathsUsingLabels(targetNode));

    return generatedSourcePaths.build();
}

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

@Override
public ImmutableSet<BuildRule> getStaticLibraryDeps() {
    ImmutableSet.Builder<BuildRule> builder = ImmutableSet.builder();
    for (BuildRule dep : getDeps()) {
        if (dep instanceof ProvidesLinkedBinaryDeps) {
            builder.addAll(((ProvidesLinkedBinaryDeps) dep).getStaticLibraryDeps());
        }/*from   w ww  .  j  a  va2 s  .co m*/
    }
    return builder.build();
}

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

@Override
public ImmutableSet<BuildRule> getCompileDeps() {
    ImmutableSet.Builder<BuildRule> builder = ImmutableSet.builder();
    for (BuildRule dep : getDeps()) {
        if (dep instanceof ProvidesLinkedBinaryDeps) {
            builder.addAll(((ProvidesLinkedBinaryDeps) dep).getCompileDeps());
        }/*from   www.j  a v a2 s .  c  om*/
    }
    return builder.build();
}

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

private NativeLinkableInput getNativeLinkableInputUncached(CxxPlatform cxxPlatform,
        Linker.LinkableDepType type) {//from  w  ww .j  a  va2s .  c om
    if (!isPlatformSupported(cxxPlatform)) {
        return NativeLinkableInput.of();
    }
    ImmutableList.Builder<Arg> linkerArgsBuilder = ImmutableList.builder();
    linkerArgsBuilder
            .addAll(StringArg.from(Preconditions.checkNotNull(exportedLinkerFlags.apply(cxxPlatform))));

    ImmutableSet.Builder<FrameworkPath> frameworkPaths = ImmutableSet.builder();
    frameworkPaths.addAll(Preconditions.checkNotNull(frameworks));

    frameworkPaths.add(FrameworkPath.ofSourcePath(new BuildTargetSourcePath(this.getBuildTarget())));
    if (type == Linker.LinkableDepType.SHARED) {
        linkerArgsBuilder.addAll(
                StringArg.from("-rpath", "@loader_path/Frameworks", "-rpath", "@executable_path/Frameworks"));
    }

    final ImmutableList<Arg> linkerArgs = linkerArgsBuilder.build();
    return NativeLinkableInput.of(linkerArgs, frameworkPaths.build(), Collections.emptySet());
}

From source file:com.google.devtools.build.lib.rules.android.NativeLibs.java

public ImmutableSet<Artifact> getAllNativeLibs() {
    ImmutableSet.Builder<Artifact> result = ImmutableSet.builder();

    for (Iterable<Artifact> libs : nativeLibs.values()) {
        result.addAll(libs);
    }/* ww  w . jav a 2  s.c  o m*/

    return result.build();
}