Example usage for com.google.common.collect ImmutableMap.Builder putAll

List of usage examples for com.google.common.collect ImmutableMap.Builder putAll

Introduction

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

Prototype

public final void putAll(Map<? extends K, ? extends V> map) 

Source Link

Usage

From source file:com.facebook.buck.rules.CommandTool.java

@Override
public ImmutableMap<String, String> getEnvironment() {
    ImmutableMap.Builder<String, String> env = ImmutableMap.builder();
    if (baseTool.isPresent()) {
        env.putAll(baseTool.get().getEnvironment());
    }/*  w ww .  ja v  a  2  s  . c om*/
    env.putAll(Arg.stringify(environment));
    return env.build();
}

From source file:com.facebook.buck.features.go.GoBinary.java

private ImmutableMap<String, String> getEnvironment(BuildContext context) {
    ImmutableMap.Builder<String, String> environment = ImmutableMap.builder();

    if (linkMode == GoLinkStep.LinkMode.EXTERNAL) {
        environment.putAll(cxxLinker.getEnvironment(context.getSourcePathResolver()));
    }//  w w  w  . j  a v a 2 s. com
    environment.putAll(linker.getEnvironment(context.getSourcePathResolver()));

    return environment.build();
}

From source file:io.airlift.drift.codec.metadata.ThriftFieldMetadata.java

public Map<String, String> getIdlAnnotations() {
    ImmutableMap.Builder<String, String> annotationsBuilder = ImmutableMap.builder();
    annotationsBuilder.putAll(idlAnnotations);

    if (isRecursiveReference()) {
        annotationsBuilder.put(RECURSIVE_REFERENCE_ANNOTATION_KEY, "true");
    }/*w ww. j  a v a2 s.  c om*/

    return annotationsBuilder.build();
}

From source file:org.janusgraph.diskstorage.configuration.MergedConfiguration.java

@Override
public Map<String, Object> getSubset(ConfigNamespace umbrella, String... umbrellaElements) {
    ImmutableMap.Builder<String, Object> b = ImmutableMap.builder();
    Map<String, Object> fm = first.getSubset(umbrella, umbrellaElements);
    Map<String, Object> sm = second.getSubset(umbrella, umbrellaElements);

    b.putAll(first.getSubset(umbrella, umbrellaElements));

    for (Map.Entry<String, Object> secondEntry : sm.entrySet()) {
        if (!fm.containsKey(secondEntry.getKey())) {
            b.put(secondEntry);/* w w w  .j  a v  a 2  s . c o m*/
        }
    }

    return b.build();
}

From source file:com.google.devtools.build.lib.exec.apple.XCodeLocalEnvProvider.java

@Override
public Map<String, String> rewriteLocalEnv(Map<String, String> env, Path execRoot, Path tmpDir,
        String productName) throws IOException {
    boolean containsXcodeVersion = env.containsKey(AppleConfiguration.XCODE_VERSION_ENV_NAME);
    boolean containsAppleSdkVersion = env.containsKey(AppleConfiguration.APPLE_SDK_VERSION_ENV_NAME);

    ImmutableMap.Builder<String, String> newEnvBuilder = ImmutableMap.builder();
    newEnvBuilder.putAll(Maps.filterKeys(env, k -> !k.equals("TMPDIR")));
    newEnvBuilder.put("TMPDIR", tmpDir.getPathString());

    if (!containsXcodeVersion && !containsAppleSdkVersion) {
        return newEnvBuilder.build();
    }/*from  w  w w  .j  a v a 2  s .c o m*/

    // Empty developer dir indicates to use the system default.
    // TODO(bazel-team): Bazel's view of the xcode version and developer dir should be explicitly
    // set for build hermeticity.
    String developerDir = "";
    if (containsXcodeVersion) {
        String version = env.get(AppleConfiguration.XCODE_VERSION_ENV_NAME);
        developerDir = getDeveloperDir(execRoot, DottedVersion.fromString(version), productName);
        newEnvBuilder.put("DEVELOPER_DIR", developerDir);
    }
    if (containsAppleSdkVersion) {
        // The Apple platform is needed to select the appropriate SDK.
        if (!env.containsKey(AppleConfiguration.APPLE_SDK_PLATFORM_ENV_NAME)) {
            throw new IOException("Could not resolve apple platform for determining SDK");
        }
        String iosSdkVersion = env.get(AppleConfiguration.APPLE_SDK_VERSION_ENV_NAME);
        String appleSdkPlatform = env.get(AppleConfiguration.APPLE_SDK_PLATFORM_ENV_NAME);
        newEnvBuilder.put("SDKROOT",
                getSdkRoot(execRoot, developerDir, iosSdkVersion, appleSdkPlatform, productName));
    }

    return newEnvBuilder.build();
}

From source file:org.androidtransfuse.model.MethodDescriptor.java

public MethodDescriptor(JMethod method, ASTMethod astMethod,
        ImmutableMap<ASTParameter, TypedExpression> parameterMap,
        ImmutableMap<ASTType, TypedExpression> typeMap) {
    this.method = method;
    this.astMethod = astMethod;
    this.parameterMap = parameterMap;
    this.blocks.push(method.body());

    ImmutableMap.Builder<ASTType, TypedExpression> queryBuilder = ImmutableMap.builder();

    Set<ASTType> duplicateTypes = new HashSet<ASTType>();

    duplicateTypes.addAll(typeMap.keySet());

    queryBuilder.putAll(typeMap);
    for (Map.Entry<ASTParameter, TypedExpression> parameterEntry : parameterMap.entrySet()) {
        if (!duplicateTypes.contains(parameterEntry.getKey().getASTType())) {
            queryBuilder.put(parameterEntry.getKey().getASTType(), parameterEntry.getValue());
            duplicateTypes.add(parameterEntry.getKey().getASTType());
        }/*from   w  w  w. ja  va 2  s.  c  om*/
    }

    this.querymap = queryBuilder.build();
}

From source file:com.bendb.thrifty.schema.EnumType.java

@VisibleForTesting
public EnumType(EnumElement element, ThriftType type, Map<NamespaceScope, String> namespaces) {
    super(element.name(), namespaces);
    this.element = element;
    this.type = type;

    ImmutableList.Builder<Member> membersBuilder = ImmutableList.builder();
    for (EnumMemberElement memberElement : element.members()) {
        membersBuilder.add(new Member(memberElement));
    }/*  w  w w .  j a v a  2s .  c  o m*/
    this.members = membersBuilder.build();

    ImmutableMap.Builder<String, String> annotationBuilder = ImmutableMap.builder();
    AnnotationElement anno = element.annotations();
    if (anno != null) {
        annotationBuilder.putAll(anno.values());
    }
    this.annotations = annotationBuilder.build();
}

From source file:org.gradle.api.tasks.WriteProperties.java

/**
 * Returns an immutable view of properties to be written to the properties file.
 * @since 3.3//from  w  w w  .ja  va 2  s .co m
 */
@Input
public Map<String, String> getProperties() {
    ImmutableMap.Builder<String, String> propertiesBuilder = ImmutableMap.builder();
    propertiesBuilder.putAll(properties);
    try {
        for (Map.Entry<String, Callable<String>> e : deferredProperties.entrySet()) {
            propertiesBuilder.put(e.getKey(), e.getValue().call());
        }
    } catch (Exception e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
    return propertiesBuilder.build();
}

From source file:com.facebook.buck.rules.coercer.BuildConfigFields.java

/**
 * @return A new {@link BuildConfigFields} with all of the fields from this object, combined with
 *     all of the fields from the specified {@code fields}. If both objects have fields with the
 *     same name, the entry from the {@code fields} parameter wins.
 */// ww  w. j ava 2s.c o m
public BuildConfigFields putAll(BuildConfigFields fields) {

    ImmutableMap.Builder<String, Field> nameToFieldBuilder = ImmutableMap.builder();
    nameToFieldBuilder.putAll(fields.nameToField);
    for (Field field : this.nameToField.values()) {
        if (!fields.nameToField.containsKey(field.name)) {
            nameToFieldBuilder.put(field.name, field);
        }
    }
    return new BuildConfigFields(nameToFieldBuilder.build());
}

From source file:com.splicemachine.orc.AbstractOrcDataSource.java

@Override
public final <K> Map<K, FixedLengthSliceInput> readFully(Map<K, DiskRange> diskRanges) throws IOException {
    requireNonNull(diskRanges, "diskRanges is null");

    if (diskRanges.isEmpty()) {
        return ImmutableMap.of();
    }/*from  ww  w.j  a v  a  2  s .c o  m*/

    //
    // Note: this code does not use the Java 8 stream APIs to avoid any extra object allocation
    //

    // split disk ranges into "big" and "small"
    long maxReadSizeBytes = maxBufferSize.toBytes();
    ImmutableMap.Builder<K, DiskRange> smallRangesBuilder = ImmutableMap.builder();
    ImmutableMap.Builder<K, DiskRange> largeRangesBuilder = ImmutableMap.builder();
    for (Entry<K, DiskRange> entry : diskRanges.entrySet()) {
        if (entry.getValue().getLength() <= maxReadSizeBytes) {
            smallRangesBuilder.put(entry);
        } else {
            largeRangesBuilder.put(entry);
        }
    }
    Map<K, DiskRange> smallRanges = smallRangesBuilder.build();
    Map<K, DiskRange> largeRanges = largeRangesBuilder.build();

    // read ranges
    ImmutableMap.Builder<K, FixedLengthSliceInput> slices = ImmutableMap.builder();
    slices.putAll(readSmallDiskRanges(smallRanges));
    slices.putAll(readLargeDiskRanges(largeRanges));

    return slices.build();
}