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

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

Introduction

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

Prototype

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

Source Link

Document

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

Usage

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

private NativeLinkableInput getNativeLinkableInputUncached(CxxPlatform cxxPlatform,
        Linker.LinkableDepType type) {/*from   w  ww  .ja v  a  2  s.  co  m*/
    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.api.codegen.transformer.ruby.RubyGapicSurfaceTestTransformer.java

@Override
public List<ViewModel> transform(ProtoApiModel model, GapicProductConfig productConfig) {
    ImmutableList.Builder<ViewModel> views = ImmutableList.builder();
    views.addAll(createUnitTestViews(model, productConfig));
    views.addAll(createSmokeTestViews(model, productConfig));
    return views.build();
}

From source file:com.torodb.kvdocument.values.TwelveBytesValue.java

public TwelveBytesValue(ImmutableList<Byte> bytes) {
    Preconditions.checkArgument(bytes.size() <= 12,
            "The list size must be equal or smaller than 12 but " + bytes.size() + " were recived");

    if (bytes.size() == 12) {
        this.bytes = bytes;
    } else {/*from  w w  w .j a  v a  2 s.  c  o  m*/
        ImmutableList.Builder<Byte> builder = ImmutableList.builder();
        for (int i = 11; i >= bytes.size(); i--) {
            builder.add((byte) 0);
        }
        builder.addAll(bytes);
        this.bytes = bytes;
    }
    assert this.bytes.size() == 12;
    assert bytes.subList(12 - bytes.size(), 12).equals(bytes);
}

From source file:com.google.api.codegen.transformer.py.PythonGapicSurfaceTestTransformer.java

@Override
public List<ViewModel> transform(ProtoApiModel model, GapicProductConfig productConfig) {
    ImmutableList.Builder<ViewModel> models = ImmutableList.builder();
    models.addAll(createUnitTestViews(model, productConfig));
    models.addAll(createSmokeTestViews(model, productConfig));
    return models.build();
}

From source file:org.apache.beam.sdk.values.PCollectionList.java

/**
 * Returns a new {@link PCollectionList} that has all the {@link PCollection PCollections} of
 * this {@link PCollectionList} plus the given {@link PCollection PCollections} appended to the
 * end, in order./*  w  ww . j a  v  a2  s  .c  o m*/
 *
 * <p>All the {@link PCollection PCollections} in the resulting {@link PCollectionList} must be
 * part of the same {@link Pipeline}.
 */
public PCollectionList<T> and(Iterable<PCollection<T>> pcs) {
    ImmutableList.Builder<TaggedPValue> builder = ImmutableList.builder();
    builder.addAll(pcollections);
    for (PCollection<T> pc : pcs) {
        if (pc.getPipeline() != pipeline) {
            throw new IllegalArgumentException("PCollections come from different Pipelines");
        }
        builder.add(TaggedPValue.of(new TupleTag<T>(), pc));
    }
    return new PCollectionList<>(pipeline, builder.build());
}

From source file:org.killbill.billing.plugin.avatax.api.AvaTaxTaxCalculatorBase.java

@Override
public List<InvoiceItem> compute(final Account account, final Invoice newInvoice, final Invoice invoice,
        final Map<UUID, InvoiceItem> taxableItems, final Map<UUID, Collection<InvoiceItem>> adjustmentItems,
        final boolean dryRun, final Iterable<PluginProperty> pluginProperties, final UUID kbTenantId) {
    // Retrieve what we've already taxed (Tax Rates API) or sent (AvaTax)
    final Map<UUID, Set<UUID>> alreadyTaxedItemsWithAdjustments;
    try {/* w  w w.ja  v a  2 s.co m*/
        final List<AvataxResponsesRecord> responses = dao.getSuccessfulResponses(invoice.getId(), kbTenantId);
        alreadyTaxedItemsWithAdjustments = dao.getTaxedItemsWithAdjustments(responses);
    } catch (final SQLException e) {
        logger.warn("Unable to compute tax for account " + account.getId(), e);
        return ImmutableList.<InvoiceItem>of();
    }

    // For AvaTax, we can only send one type of document at a time (Sales or Return). In some cases, we need to send both, for example
    // in the case of repairs (adjustment for the original item, tax for the new item -- all generated items would be on the new invoice)
    final Map<UUID, InvoiceItem> salesTaxItems = new HashMap<UUID, InvoiceItem>();
    final Map<UUID, InvoiceItem> returnTaxItems = new HashMap<UUID, InvoiceItem>();
    final Map<UUID, Collection<InvoiceItem>> adjustmentItemsForReturnTaxItems = new HashMap<UUID, Collection<InvoiceItem>>();
    computeNewItemsToTaxAndExistingItemsToAdjust(taxableItems, adjustmentItems,
            alreadyTaxedItemsWithAdjustments, salesTaxItems, returnTaxItems, adjustmentItemsForReturnTaxItems);

    final ImmutableList.Builder<InvoiceItem> newInvoiceItemsBuilder = ImmutableList.<InvoiceItem>builder();
    if (!salesTaxItems.isEmpty()) {
        newInvoiceItemsBuilder.addAll(getTax(account, newInvoice, invoice, salesTaxItems, null, null, dryRun,
                pluginProperties, kbTenantId));
    }
    if (!returnTaxItems.isEmpty()) {
        final String originalInvoiceReferenceCode;
        try {
            final List<AvataxResponsesRecord> responses = dao.getSuccessfulResponses(invoice.getId(),
                    kbTenantId);
            originalInvoiceReferenceCode = responses.isEmpty() ? null : responses.get(0).getDocCode();
        } catch (final SQLException e) {
            logger.warn("Unable to compute tax for account " + account.getId(), e);
            return newInvoiceItemsBuilder.build();
        }

        newInvoiceItemsBuilder
                .addAll(getTax(account, newInvoice, invoice, returnTaxItems, adjustmentItemsForReturnTaxItems,
                        originalInvoiceReferenceCode, dryRun, pluginProperties, kbTenantId));
    }
    return newInvoiceItemsBuilder.build();
}

From source file:com.facebook.buck.cxx.CxxCollectAndLogInferDependenciesStep.java

private void processAnalysisRuleHelper(CxxInferAnalyze analysisRule,
        ImmutableList.Builder<String> accumulator) {
    accumulator.add(InferLogLine/*from  w  ww.  j a v a 2 s  . com*/
            .fromBuildTarget(analysisRule.getBuildTarget(), analysisRule.getAbsolutePathToResultsDir())
            .toString());
    accumulator.addAll(analysisRule.getCaptureRules().stream().map(this::processCaptureRule).iterator());
}

From source file:com.facebook.presto.cassandra.CassandraPartitionManager.java

private List<CassandraPartition> getCassandraPartitions(CassandraTable table,
        TupleDomain<ColumnHandle> tupleDomain) {
    if (tupleDomain.isNone()) {
        return ImmutableList.of();
    }//from ww w  .ja  v a2 s .  c om

    Set<List<Object>> partitionKeysSet = getPartitionKeysSet(table, tupleDomain);

    // empty filter means, all partitions
    if (partitionKeysSet.isEmpty()) {
        return cassandraSession.getPartitions(table, ImmutableList.of());
    }

    ImmutableList.Builder<CassandraPartition> partitions = ImmutableList.builder();
    for (List<Object> partitionKeys : partitionKeysSet) {
        partitions.addAll(cassandraSession.getPartitions(table, partitionKeys));
    }

    return partitions.build();
}

From source file:com.google.caliper.runner.DefaultRunner.java

private List<String> createCommand(Scenario scenario, Vm vm, MeasurementType type) {
    String classPath = System.getProperty("java.class.path");
    if (classPath == null || classPath.length() == 0) {
        throw new IllegalStateException("java.class.path is undefined in " + System.getProperties());
    }//from  w w w .j  a  va  2 s .  co  m

    ImmutableList.Builder<String> command = ImmutableList.builder();
    command.addAll(ARGUMENT_SPLITTER.split(scenario.getVariables().get(Scenario.VM_KEY)));
    command.add("-cp").add(classPath);
    if (type == MeasurementType.INSTANCE || type == MeasurementType.MEMORY) {
        String allocationJarFile = System.getenv("ALLOCATION_JAR");
        command.add("-javaagent:" + allocationJarFile);
    }
    command.addAll(vm.getVmSpecificOptions(type, arguments));

    Map<String, String> vmParameters = scenario.getVariables(scenarioSelection.getVmParameterNames());
    for (String vmParameter : vmParameters.values()) {
        command.addAll(ARGUMENT_SPLITTER.split(vmParameter));
    }

    command.add(InProcessRunner.class.getName());
    createCommand(command, scenario, type);
    return command.build();
}

From source file:com.google.devtools.build.lib.rules.apple.DottedVersion.java

/**
 * Returns the string representation of this dotted version, padded to a minimum number of
 * components if the string representation does not already contain that many components.
 * /*from www .  ja  v a 2 s. com*/
 * <p>For example, a dotted version of "7.3" will return "7.3" with either one or two components
 * requested, "7.3.0" if three are requested, and "7.3.0.0" if four are requested.
 * 
 * <p>Trailing zero components at the end of a string representation will not be removed. For
 * example, a dotted version of "1.0.0" will return "1.0.0" if only one or two components
 * are requested.
 *
 * @param numMinComponents the minimum number of dot-separated numbers that should be present
 *     in the returned string representation
 */
public String toStringWithMinimumComponents(int numMinComponents) {
    ImmutableList.Builder<Component> stringComponents = ImmutableList.builder();
    stringComponents.addAll(components);
    int numComponents = Math.max(this.numOriginalComponents, numMinComponents);
    int zeroesToPad = numComponents - components.size();
    for (int i = 0; i < zeroesToPad; i++) {
        stringComponents.add(ZERO_COMPONENT);
    }
    return Joiner.on('.').join(stringComponents.build());
}