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

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

Introduction

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

Prototype

boolean add(E e);

Source Link

Document

Appends the specified element to the end of this list (optional operation).

Usage

From source file:com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.r11.AndroidNdkCrosstoolsR11.java

private static ImmutableList<DefaultCpuToolchain> getDefaultCpuToolchains(StlImpl stlImpl) {
    // TODO(bazel-team): It would be better to auto-generate this somehow.

    ImmutableMap<String, String> defaultCpus = ImmutableMap.<String, String>builder()
            // arm
            .put("armeabi", "arm-linux-androideabi-4.9").put("armeabi-v7a", "arm-linux-androideabi-4.9-v7a")
            .put("armeabi-v7a-hard", "arm-linux-androideabi-4.9-v7a-hard")
            .put("armeabi-thumb", "arm-linux-androideabi-4.9-thumb")
            .put("armeabi-v7a-thumb", "arm-linux-androideabi-4.9-v7a-thumb")
            .put("armeabi-v7a-hard-thumb", "arm-linux-androideabi-4.9-v7a-hard-thumb")
            .put("arm64-v8a", "aarch64-linux-android-4.9")

            // mips
            .put("mips", "mipsel-linux-android-4.9").put("mips64", "mips64el-linux-android-4.9")

            // x86
            .put("x86", "x86-4.9").put("x86_64", "x86_64-4.9").build();

    ImmutableList.Builder<DefaultCpuToolchain> defaultCpuToolchains = ImmutableList.builder();
    for (Entry<String, String> defaultCpu : defaultCpus.entrySet()) {
        defaultCpuToolchains.add(DefaultCpuToolchain.newBuilder().setCpu(defaultCpu.getKey())
                .setToolchainIdentifier(defaultCpu.getValue() + "-" + stlImpl.getName()).build());
    }// w w w. j  av a 2  s  . c om
    return defaultCpuToolchains.build();
}

From source file:com.android.builder.core.VariantType.java

public static ImmutableList<VariantType> getTestingTypes() {
    ImmutableList.Builder<VariantType> result = ImmutableList.builder();
    for (VariantType variantType : values()) {
        if (variantType.isForTesting()) {
            result.add(variantType);
        }/*  www .  j  a v  a2 s. co  m*/
    }
    return result.build();
}

From source file:com.torodb.torod.db.postgresql.query.processors.InProcessor.java

@Nullable
private static ProcessedQueryCriteria getNumericQuery(InQueryCriteria criteria,
        Multimap<BasicType, Value<?>> byTypeValues) {
    ImmutableList.Builder<Value<?>> newInBuilder = ImmutableList.builder();

    for (Value<?> value : byTypeValues.values()) {
        newInBuilder.add(value);
    }//  w w  w.j a va2 s. c om

    ImmutableList<Value<?>> newIn = newInBuilder.build();

    if (newIn.isEmpty()) {
        return null;
    }

    DisjunctionBuilder structureBuilder = new DisjunctionBuilder();

    structureBuilder.add(new TypeIsQueryCriteria(criteria.getAttributeReference(), BasicType.DOUBLE));
    structureBuilder.add(new TypeIsQueryCriteria(criteria.getAttributeReference(), BasicType.INTEGER));
    structureBuilder.add(new TypeIsQueryCriteria(criteria.getAttributeReference(), BasicType.LONG));

    newInBuilder.addAll(byTypeValues.get(BasicType.DOUBLE));
    newInBuilder.addAll(byTypeValues.get(BasicType.INTEGER));
    newInBuilder.addAll(byTypeValues.get(BasicType.LONG));

    return new ProcessedQueryCriteria(structureBuilder.build(),
            new InQueryCriteria(criteria.getAttributeReference(), newIn));
}

From source file:org.zanata.client.BashCompletionGenerator.java

private static List<Option> getOptions(Class<?> bean) {
    ImmutableList.Builder<Option> allOptions = ImmutableList.builder();
    // recursively process all the methods/fields.
    for (Class<?> c = bean; c != null; c = c.getSuperclass()) {
        ImmutableList.Builder<AccessibleObject> builder = ImmutableList.builder();
        List<AccessibleObject> fieldAndMethods = builder.add(c.getDeclaredFields()).add(c.getDeclaredMethods())
                .build();//from  w w  w.  ja  va2s.c  o  m
        for (AccessibleObject accessibleObject : fieldAndMethods) {
            Option option = accessibleObject.getAnnotation(Option.class);
            if (option != null) {
                allOptions.add(option);
            }
        }
    }
    return allOptions.build();
}

From source file:org.jclouds.rackspace.autoscale.v1.internal.ParseHelper.java

@SuppressWarnings("unchecked")
public static ImmutableList<Map<String, Object>> buildScalingPoliciesRequestList(
        Map<String, Object> postParams) {
    List<CreateScalingPolicy> scalingPoliciesRequest = (List<CreateScalingPolicy>) postParams
            .get("scalingPolicies");
    ImmutableList.Builder<Map<String, Object>> scalingPoliciesListBuilder = ImmutableList.builder();

    for (CreateScalingPolicy scalingPolicy : scalingPoliciesRequest) {
        scalingPoliciesListBuilder.add(buildScalingPolicyMap(scalingPolicy));
    }//from w ww . j  a  v  a 2  s  . co  m
    return scalingPoliciesListBuilder.build();
}

From source file:org.apache.hadoop.hdfs.server.namenode.AclEntryStatusFormat.java

public static ImmutableList<AclEntry> toAclEntries(int[] entries) {
    ImmutableList.Builder<AclEntry> b = new ImmutableList.Builder<AclEntry>();
    for (int entry : entries) {
        AclEntry aclEntry = toAclEntry(entry);
        b.add(aclEntry);
    }/*from   w w w  . j  a va  2 s  . co  m*/
    return b.build();
}

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

/**
 * Creates the list of non-optional query params assigned in the constructor
 *///from   w w  w .ja  v a 2 s .c om
public static ImmutableList<QueryParam> toQueryParamList(final Operation operation,
        final ImmutableList<Ds3Param> requiredParams) {
    final ImmutableList.Builder<QueryParam> builder = ImmutableList.builder();
    if (operation != null) {
        builder.add(new OperationQueryParam(operation.toString().toLowerCase()));
    }
    builder.addAll(toRequiredQueryParamList(requiredParams));
    return builder.build();
}

From source file:org.gradle.api.internal.changedetection.state.TreeSnapshotSerializer.java

static TreeSnapshot readStoredTreeSnapshot(long assignedId, Decoder decoder,
        IncrementalFileSnapshotSerializer incrementalFileSnapshotSerializer, StringInterner stringInterner)
        throws Exception {
    final int entryCount = decoder.readSmallInt();
    ImmutableList.Builder<FileSnapshotWithKey> fileSnapshotWithKeyListBuilder = ImmutableList.builder();
    for (int i = 0; i < entryCount; i++) {
        String key = stringInterner.intern(decoder.readString());
        fileSnapshotWithKeyListBuilder
                .add(new FileSnapshotWithKey(key, incrementalFileSnapshotSerializer.read(decoder)));
    }/*from www  .  j  a  v a  2 s  .  co  m*/
    final ImmutableList<FileSnapshotWithKey> fileSnapshotWithKeyList = fileSnapshotWithKeyListBuilder.build();
    return new StoredTreeSnapshot(fileSnapshotWithKeyList, assignedId);
}

From source file:io.prestosql.operator.OrderByOperator.java

private static List<Type> toTypes(List<? extends Type> sourceTypes, List<Integer> outputChannels) {
    ImmutableList.Builder<Type> types = ImmutableList.builder();
    for (int channel : outputChannels) {
        types.add(sourceTypes.get(channel));
    }/*from ww w  .j av  a 2s .co  m*/
    return types.build();
}

From source file:com.facebook.buck.apple.xcode.ProjectGeneratorTestUtils.java

public static PartialGraph createPartialGraphFromBuildRuleResolver(BuildRuleResolver resolver) {
    DependencyGraph graph = RuleMap.createGraphFromBuildRules(resolver);
    ImmutableList.Builder<BuildTarget> targets = ImmutableList.builder();
    for (BuildRule rule : graph.getNodes()) {
        targets.add(rule.getBuildTarget());
    }/*from  w w w.j a  v a  2 s  .c  om*/
    return PartialGraphFactory.newInstance(graph, targets.build());
}