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.google.api.codegen.transformer.php.PhpApiMethodParamTransformer.java

@Override
public List<DynamicLangDefaultableParamView> generateMethodParams(GapicMethodContext context) {
    ImmutableList.Builder<DynamicLangDefaultableParamView> methodParams = ImmutableList.builder();
    methodParams.addAll(generateDefaultableParams(context));

    TypeRef arrayType = TypeRef.fromPrimitiveName("string").makeRepeated();

    DynamicLangDefaultableParamView.Builder optionalArgs = DynamicLangDefaultableParamView.newBuilder();
    optionalArgs.name(context.getNamer().localVarName(Name.from("optional", "args")));
    optionalArgs.defaultValue(context.getTypeTable().getSnippetZeroValueAndSaveNicknameFor(arrayType));
    optionalArgs.typeHint("array");
    methodParams.add(optionalArgs.build());

    return methodParams.build();
}

From source file:org.apache.beam.sdk.values.reflect.RowFactory.java

private List<FieldValueGetter> createGetters(Class pojoClass) {
    ImmutableList.Builder<FieldValueGetter> getters = ImmutableList.builder();

    for (GetterFactory getterFactory : getterFactories) {
        getters.addAll(getterFactory.generateGetters(pojoClass));
    }//from w w  w . j av a 2  s .c o  m

    return getters.build();
}

From source file:com.b2international.snowowl.identity.MultiIdentityProvider.java

@Override
public Promise<Users> searchUsers(Collection<String> usernames, int limit) {
    return Promise.all(providers.stream().map(provider -> provider.searchUsers(usernames, limit))
            .collect(Collectors.toList())).then(responses -> {
                final ImmutableList.Builder<User> users = ImmutableList.builder();
                int total = 0;
                for (Users matches : Iterables.filter(responses, Users.class)) {
                    users.addAll(matches);
                    total += matches.getTotal();
                }/*from   w ww .j a  va 2  s .c o m*/
                return new Users(users.build(), limit, total);
            });
}

From source file:com.facebook.presto.operator.MaterializingOperator.java

public MaterializingOperator(OperatorContext operatorContext, List<TupleInfo> sourceTupleInfos) {
    this.operatorContext = checkNotNull(operatorContext, "operatorContext is null");

    ImmutableList.Builder<Type> types = ImmutableList.builder();
    for (TupleInfo sourceTupleInfo : checkNotNull(sourceTupleInfos, "sourceTupleInfos is null")) {
        types.addAll(sourceTupleInfo.getTypes());
    }/*from ww  w  .j av a 2 s .co m*/
    resultBuilder = MaterializedResult.resultBuilder(new TupleInfo(types.build()));
}

From source file:com.facebook.buck.features.haskell.HaskellBuckConfig.java

private Optional<ImmutableList<String>> getFlags(String section, String field) {
    Optional<String> value = delegate.getValue(section, field);
    if (!value.isPresent()) {
        return Optional.empty();
    }//from w ww .  j  av  a  2  s .c o m
    ImmutableList.Builder<String> split = ImmutableList.builder();
    if (!value.get().trim().isEmpty()) {
        split.addAll(Splitter.on(" ").split(value.get().trim()));
    }
    return Optional.of(split.build());
}

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

@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
    ImmutableList.Builder<String> commandBuilder = ImmutableList.builder();

    //TODO(k21): Let apps select their minimum target.
    String target = "7.0";

    commandBuilder.addAll(actoolCommand);
    commandBuilder.add("--output-format", "human-readable-text", "--notices", "--warnings", "--errors",
            "--platform", applePlatformName, "--minimum-deployment-target", target, "--compress-pngs",
            "--compile", output.toString(), "--output-partial-info-plist", outputPlist.toString());

    if (applePlatformName.equals(ApplePlatform.APPLETVOS.getName())
            || applePlatformName.equals(ApplePlatform.APPLETVSIMULATOR.getName())) {
        commandBuilder.add("--target-device", "tv");
    } else {//  w  ww. ja  va 2 s .c o m
        //TODO(k21): Let apps decide which device they want to target (iPhone / iPad / both)
        commandBuilder.add("--target-device", "iphone", "--target-device", "ipad");
    }

    if (appIcon.isPresent()) {
        commandBuilder.add("--app-icon", appIcon.get());
    }

    if (launchImage.isPresent()) {
        commandBuilder.add("--launch-image", launchImage.get());
    }

    commandBuilder.add("--optimization", optimization.toArgument());
    commandBuilder.addAll(Iterables.transform(assetCatalogDirs, Object::toString));

    return commandBuilder.build();
}

From source file:com.google.devtools.build.lib.packages.RawAttributeMapper.java

/**
 * If the attribute is configurable for this rule instance, returns its configuration
 * keys. Else returns an empty list.//from  w w w .  j ava2  s  .  co m
 */
public <T> Iterable<Label> getConfigurabilityKeys(String attributeName, Type<T> type) {
    SelectorList<T> selectorList = getSelectorList(attributeName, type);
    if (selectorList == null) {
        return ImmutableList.of();
    }
    ImmutableList.Builder<Label> builder = ImmutableList.builder();
    for (Selector<T> selector : selectorList.getSelectors()) {
        builder.addAll(selector.getEntries().keySet());
    }
    return builder.build();
}

From source file:com.google.devtools.build.lib.analysis.configuredtargets.AbstractConfiguredTarget.java

@Override
public final ImmutableCollection<String> getKeys() {
    ImmutableList.Builder<String> result = ImmutableList.builder();
    result.addAll(ImmutableList.of(DATA_RUNFILES_FIELD, DEFAULT_RUNFILES_FIELD, LABEL_FIELD, FILES_FIELD,
            FilesToRunProvider.SKYLARK_NAME));
    if (get(OutputGroupProvider.SKYLARK_CONSTRUCTOR) != null) {
        result.add(OutputGroupProvider.SKYLARK_NAME);
    }//from w  w w .ja  v a2  s.co  m
    addExtraSkylarkKeys(result::add);
    return result.build();
}

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

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    SourcePathResolver pathResolver = context.getSourcePathResolver();
    TreeMultimap<Path, Path> assets = TreeMultimap.create();

    ImmutableList.Builder<Step> steps = ImmutableList.builder();

    steps.addAll(MakeCleanDirectoryStep.of(BuildCellRelativePath.fromCellRelativePath(
            context.getBuildCellRootPath(), getProjectFilesystem(), getPathToMergedAssets().getParent())));
    steps.add(new AbstractExecutionStep("finding_assets") {
        @Override//from   w ww  .j  a v  a 2s .c o  m
        public StepExecutionResult execute(ExecutionContext context) throws IOException {
            for (SourcePath sourcePath : assetsDirectories) {
                Path relativePath = pathResolver.getRelativePath(sourcePath);
                Path absolutePath = pathResolver.getAbsolutePath(sourcePath);
                ProjectFilesystem assetFilesystem = pathResolver.getFilesystem(sourcePath);
                assetFilesystem.walkFileTree(relativePath, new SimpleFileVisitor<Path>() {
                    @Override
                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                        Preconditions.checkState(!Files.getFileExtension(file.toString()).equals("gz"),
                                "BUCK doesn't support adding .gz files to assets (%s).", file);
                        assets.put(absolutePath, absolutePath.relativize(file.normalize()));
                        return super.visitFile(file, attrs);
                    }
                });
            }
            return StepExecutionResults.SUCCESS;
        }
    });
    steps.add(new MergeAssetsStep(getProjectFilesystem().getPathForRelativePath(getPathToMergedAssets()),
            baseApk.map(pathResolver::getAbsolutePath), assets));
    buildableContext.recordArtifact(getPathToMergedAssets());
    return steps.build();
}

From source file:org.apache.brooklyn.location.jclouds.networking.SharedLocationSecurityGroupCustomizer.java

@Override
public void customize(JcloudsLocation location, ComputeService computeService, JcloudsMachineLocation machine) {
    super.customize(location, computeService, machine);

    if (!enabled)
        return;/*from ww  w .j a va 2s.co m*/

    final JcloudsLocationSecurityGroupCustomizer instance = getInstance(getSharedGroupId(location));

    ImmutableList.Builder<IpPermission> builder = ImmutableList.<IpPermission>builder();
    builder.addAll(getIpPermissions(instance, tcpPortRanges, IpProtocol.TCP));
    builder.addAll(getIpPermissions(instance, udpPortRanges, IpProtocol.UDP));

    if (inboundPorts != null) {
        for (int inboundPort : inboundPorts) {
            IpPermission ipPermission = IpPermission.builder().fromPort(inboundPort).toPort(inboundPort)
                    .ipProtocol(IpProtocol.TCP).cidrBlock(instance.getBrooklynCidrBlock()).build();
            builder.add(ipPermission);
        }
    }
    instance.addPermissionsToLocation(machine, builder.build());
}