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:com.google.devtools.build.lib.skyframe.CoverageReportFunction.java

@Override
public SkyValue compute(SkyKey skyKey, Environment env) throws InterruptedException {
    Preconditions.checkState(CoverageReportValue.SKY_KEY.equals(skyKey),
            String.format("Expected %s for SkyKey but got %s instead", CoverageReportValue.SKY_KEY, skyKey));

    ImmutableList<ActionAnalysisMetadata> actions = PrecomputedValue.COVERAGE_REPORT_KEY.get(env);
    if (actions == null) {
        return null;
    }//w  ww .  j  ava 2s  .co  m

    ImmutableSet.Builder<Artifact> outputs = new ImmutableSet.Builder<>();

    for (ActionAnalysisMetadata action : actions) {
        outputs.addAll(action.getOutputs());
    }

    return new CoverageReportValue(outputs.build(), actions);
}

From source file:com.facebook.buck.rust.RustLibraryArg.java

@Override
public ImmutableCollection<BuildRule> getDeps(SourcePathRuleFinder ruleFinder) {
    ImmutableSet.Builder<BuildRule> deps = ImmutableSet.builder();

    deps.addAll(ruleFinder.filterBuildRuleInputs(getInputs()));
    deps.addAll(this.deps);

    return deps.build();
}

From source file:org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition.java

public ImmutablePrivilegeDefinition(String name, boolean isAbstract, Iterable<String> declaredAggregateNames) {
    this.name = name;
    this.isAbstract = isAbstract;
    ImmutableSet.Builder<String> builder = ImmutableSet.builder();
    if (declaredAggregateNames != null) {
        builder.addAll(declaredAggregateNames);
    }/*from   ww  w.  j av a  2 s  .  c  o  m*/
    this.declaredAggregateNames = builder.build();
}

From source file:org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.ResolutionFailureCollector.java

public Set<UnresolvedDependency> complete(Set<UnresolvedDependency> extraFailures) {
    if (extraFailures.isEmpty() && failuresByRevisionId.isEmpty()) {
        return ImmutableSet.of();
    }//  w w w. j  a v  a 2s.  co m
    ImmutableSet.Builder<UnresolvedDependency> builder = ImmutableSet.builder();
    builder.addAll(extraFailures);
    for (Map.Entry<ComponentSelector, BrokenDependency> entry : failuresByRevisionId.entrySet()) {
        Collection<List<ComponentIdentifier>> paths = DependencyGraphPathResolver
                .calculatePaths(entry.getValue().requiredBy, root);

        ComponentSelector key = entry.getKey();
        ModuleVersionSelector moduleVersionSelector = componentSelectorConverter.getSelector(key);
        builder.add(new DefaultUnresolvedDependency(moduleVersionSelector,
                entry.getValue().failure.withIncomingPaths(paths)));
    }
    return builder.build();
}

From source file:co.cask.cdap.internal.batch.DefaultMapReduceSpecification.java

private Set<String> getAllDatasets(Set<String> dataSets, String inputDataSet, String outputDataSet) {
    ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<>();
    builder.addAll(dataSets);

    if (inputDataSet != null && !inputDataSet.isEmpty()) {
        builder.add(inputDataSet);/*ww w  . j  av  a2s .  c om*/
    }

    if (outputDataSet != null && !outputDataSet.isEmpty()) {
        builder.add(outputDataSet);
    }

    return builder.build();
}

From source file:org.opendaylight.controller.netconf.impl.NetconfServerSessionNegotiatorFactory.java

private ImmutableSet<String> validateBaseCapabilities(final Set<String> baseCapabilities) {
    // Check base capabilities to be supported by the server
    final Sets.SetView<String> unknownBaseCaps = Sets.difference(baseCapabilities, DEFAULT_BASE_CAPABILITIES);
    Preconditions.checkArgument(unknownBaseCaps.isEmpty(),
            "Base capabilities that will be supported by netconf server have to be subset of %s, unknown base capabilities: %s",
            DEFAULT_BASE_CAPABILITIES, unknownBaseCaps);

    final ImmutableSet.Builder<String> b = ImmutableSet.builder();
    b.addAll(baseCapabilities);
    // Base 1.0 capability is supported by default
    b.add(XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0);
    return b.build();
}

From source file:io.airlift.discovery.ReplicatedDynamicStore.java

@Override
public Set<Service> getAll() {
    ImmutableSet.Builder<Service> builder = ImmutableSet.builder();
    for (Entry entry : store.getAll()) {
        builder.addAll(codec.fromJson(entry.getValue()));
    }//from  w  ww . jav a2s .c o  m

    return builder.build();
}

From source file:org.onlab.graph.AdjacencyListsGraph.java

/**
 * Creates a graph comprising of the specified vertexes and edges.
 *
 * @param vertexes set of graph vertexes
 * @param edges    set of graph edges/*from   w w  w .j a v  a2s.c o  m*/
 */
public AdjacencyListsGraph(Set<V> vertexes, Set<E> edges) {
    checkNotNull(vertexes, "Vertex set cannot be null");
    checkNotNull(edges, "Edge set cannot be null");

    // Record ingress/egress edges for each vertex.
    ImmutableSetMultimap.Builder<V, E> srcMap = ImmutableSetMultimap.builder();
    ImmutableSetMultimap.Builder<V, E> dstMap = ImmutableSetMultimap.builder();

    // Also make sure that all edge end-points are added as vertexes
    ImmutableSet.Builder<V> actualVertexes = ImmutableSet.builder();
    actualVertexes.addAll(vertexes);

    for (E edge : edges) {
        srcMap.put(edge.src(), edge);
        actualVertexes.add(edge.src());
        dstMap.put(edge.dst(), edge);
        actualVertexes.add(edge.dst());
    }

    // Make an immutable copy of the edge and vertex sets
    this.edges = ImmutableSet.copyOf(edges);
    this.vertexes = actualVertexes.build();

    // Build immutable copies of sources and destinations edge maps
    sources = srcMap.build();
    destinations = dstMap.build();
}

From source file:org.androidtransfuse.transaction.TransactionProcessorComposite.java

@Override
public ImmutableSet<Exception> getErrors() {
    ImmutableSet.Builder<Exception> exceptions = ImmutableSet.builder();
    for (TransactionProcessor processor : processors) {
        exceptions.addAll(processor.getErrors());
    }//w w w  . ja  v a 2s . c  o  m
    return exceptions.build();
}

From source file:com.google.devtools.build.lib.actions.CompositeRunfilesSupplier.java

@Override
public Iterable<Artifact> getArtifacts() {
    ImmutableSet.Builder<Artifact> result = ImmutableSet.builder();
    for (RunfilesSupplier supplier : suppliers) {
        result.addAll(supplier.getArtifacts());
    }//from w ww .  ja  v  a  2s  .c om
    return result.build();
}