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.spectralogic.ds3autogen.python.generators.request.GetObjectRequestGenerator.java

/**
 * Gets the sorted list of optional constructor params, including the request payload
 *//*from  www  .j a  v  a  2s.com*/
@Override
public ImmutableList<ConstructorParam> toOptionalConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(toOptionalArgumentsList(ds3Request.getOptionalQueryParams()));
    builder.add(new Arguments("string", PAYLOAD_NAME));
    builder.add(new Arguments("", "stream"));

    return builder.build().stream().sorted(new CustomArgumentComparator())
            .map(arg -> new ConstructorParam(camelToUnderscore(arg.getName()), true))
            .collect(GuavaCollectors.immutableList());
}

From source file:io.prestosql.plugin.hive.PartitionUpdate.java

public static List<PartitionUpdate> mergePartitionUpdates(Iterable<PartitionUpdate> unMergedUpdates) {
    ImmutableList.Builder<PartitionUpdate> partitionUpdates = ImmutableList.builder();
    for (Collection<PartitionUpdate> partitionGroup : Multimaps.index(unMergedUpdates, PartitionUpdate::getName)
            .asMap().values()) {/*ww w. ja v a  2 s .c  o m*/
        PartitionUpdate firstPartition = partitionGroup.iterator().next();

        ImmutableList.Builder<String> allFileNames = ImmutableList.builder();
        long totalRowCount = 0;
        long totalInMemoryDataSizeInBytes = 0;
        long totalOnDiskDataSizeInBytes = 0;
        for (PartitionUpdate partition : partitionGroup) {
            // verify partitions have the same new flag, write path and target path
            // this shouldn't happen but could if another user added a partition during the write
            if (partition.getUpdateMode() != firstPartition.getUpdateMode()
                    || !partition.getWritePath().equals(firstPartition.getWritePath())
                    || !partition.getTargetPath().equals(firstPartition.getTargetPath())) {
                throw new PrestoException(HIVE_CONCURRENT_MODIFICATION_DETECTED,
                        format("Partition %s was added or modified during INSERT", firstPartition.getName()));
            }
            allFileNames.addAll(partition.getFileNames());
            totalRowCount += partition.getRowCount();
            totalInMemoryDataSizeInBytes += partition.getInMemoryDataSizeInBytes();
            totalOnDiskDataSizeInBytes += partition.getOnDiskDataSizeInBytes();
        }

        partitionUpdates.add(new PartitionUpdate(firstPartition.getName(), firstPartition.getUpdateMode(),
                firstPartition.getWritePath(), firstPartition.getTargetPath(), allFileNames.build(),
                totalRowCount, totalInMemoryDataSizeInBytes, totalOnDiskDataSizeInBytes));
    }
    return partitionUpdates.build();
}

From source file:io.prestosql.sql.tree.LambdaExpression.java

@Override
public List<Node> getChildren() {
    ImmutableList.Builder<Node> nodes = ImmutableList.builder();
    nodes.addAll(arguments);
    nodes.add(body);// ww  w .j  ava  2 s. c o m
    return nodes.build();
}

From source file:com.greensopinion.finance.services.domain.Category.java

public Category withMatchRule(MatchRule rule) {
    checkNotNull(rule);/*from w  w  w .  java 2s  .co  m*/
    ImmutableList.Builder<MatchRule> newRules = ImmutableList.builder();
    newRules.addAll(getMatchRules());
    newRules.add(rule);
    return new Category(name, newRules.build());
}

From source file:com.facebook.buck.rules.macros.WorkerMacroExpander.java

@Override
protected ImmutableList<BuildRule> extractBuildTimeDeps(BuildRuleResolver resolver, BuildRule rule)
        throws MacroException {
    ImmutableList.Builder<BuildRule> deps = ImmutableList.builder();
    deps.add(rule);//from w ww  .j a  v  a  2 s. c  o m
    deps.addAll(getTool(rule).getDeps(new SourcePathRuleFinder(resolver)));
    return deps.build();
}

From source file:io.prestosql.sql.planner.iterative.rule.PruneCrossJoinColumns.java

@Override
protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator, JoinNode joinNode,
        Set<Symbol> referencedOutputs) {
    Optional<PlanNode> newLeft = restrictOutputs(idAllocator, joinNode.getLeft(), referencedOutputs);
    Optional<PlanNode> newRight = restrictOutputs(idAllocator, joinNode.getRight(), referencedOutputs);

    if (!newLeft.isPresent() && !newRight.isPresent()) {
        return Optional.empty();
    }//from ww w  .j a v a 2 s.  c  o m

    ImmutableList.Builder<Symbol> outputSymbolBuilder = ImmutableList.builder();
    outputSymbolBuilder.addAll(newLeft.orElse(joinNode.getLeft()).getOutputSymbols());
    outputSymbolBuilder.addAll(newRight.orElse(joinNode.getRight()).getOutputSymbols());

    return Optional.of(new JoinNode(idAllocator.getNextId(), joinNode.getType(),
            newLeft.orElse(joinNode.getLeft()), newRight.orElse(joinNode.getRight()), joinNode.getCriteria(),
            outputSymbolBuilder.build(), joinNode.getFilter(), joinNode.getLeftHashSymbol(),
            joinNode.getRightHashSymbol(), joinNode.getDistributionType()));
}

From source file:io.prestosql.sql.tree.SearchedCaseExpression.java

@Override
public List<Node> getChildren() {
    ImmutableList.Builder<Node> nodes = ImmutableList.builder();
    nodes.addAll(whenClauses);
    defaultValue.ifPresent(nodes::add);//  ww w  .j  a  va  2s  .  co  m
    return nodes.build();
}

From source file:com.spectralogic.ds3autogen.net.generators.requestmodels.BulkGetRequestGenerator.java

/**
 * Gets the list of required Arguments from a Ds3Request
 *///from  w  w w  .  j a  v  a 2 s  .  c  o  m
@Override
public ImmutableList<Arguments> toRequiredArgumentsList(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(GeneratorUtils.getRequiredArgs(ds3Request));
    builder.add(new Arguments("IEnumerable<string>", "FullObjects"));
    builder.add(new Arguments("IEnumerable<Ds3PartialObject>", "PartialObjects"));
    return builder.build();
}

From source file:com.spectralogic.ds3autogen.python.generators.request.PutObjectRequestGenerator.java

/**
 * Gets the sorted list of optional constructor params, including the request payload
 *///from  www.j a  v  a  2 s .  co  m
@Override
public ImmutableList<ConstructorParam> toOptionalConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(toOptionalArgumentsList(ds3Request.getOptionalQueryParams()));
    builder.add(new Arguments("string", PAYLOAD_NAME));
    builder.add(new Arguments("", "headers"));
    builder.add(new Arguments("", "stream"));

    return builder.build().stream().sorted(new CustomArgumentComparator())
            .map(arg -> new ConstructorParam(camelToUnderscore(arg.getName()), true))
            .collect(GuavaCollectors.immutableList());
}

From source file:com.facebook.buck.android.AndroidResourceIndex.java

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList.Builder<Step> steps = ImmutableList.builder();

    steps.addAll(
            MakeCleanDirectoryStep.of(BuildCellRelativePath.fromCellRelativePath(context.getBuildCellRootPath(),
                    getProjectFilesystem(), Objects.requireNonNull(getPathToOutputFile().getParent()))));

    steps.add(new WriteFileStep(getProjectFilesystem(), "", getPathToOutputFile(), /* executable */ false));

    steps.add(//from   w  w w.  j a  va2s  .c  om
            new MiniAapt(context.getSourcePathResolver(), getProjectFilesystem(), resDir, getPathToOutputFile(),
                    ImmutableSet.of(), false, MiniAapt.ResourceCollectionType.ANDROID_RESOURCE_INDEX));
    return steps.build();
}