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

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

Introduction

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

Prototype

public final V put(K k, V v) 

Source Link

Usage

From source file:com.wrmsr.kleist.util.collect.MoreMaps.java

public static <T> Map<T, Integer> indexMap(Iterator<T> it) {
    int size = 0;
    ImmutableMap.Builder<T, Integer> builder = ImmutableMap.builder();
    while (it.hasNext()) {
        T item = it.next();/*w  ww . ja  v  a  2s  .  com*/
        builder.put(item, size++);
    }
    return builder.build();
}

From source file:com.facebook.buck.util.ProcessExecutorSerializer.java

public static ImmutableMap<String, Object> serialize(ProcessExecutor executor) {
    ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
    if (executor instanceof DefaultProcessExecutor) {
        builder.put(TYPE, TYPE_DEFAULT);
    } else if (executor instanceof ContextualProcessExecutor) {
        builder.put(TYPE, TYPE_CONTEXTUAL);
        ContextualProcessExecutor contextualProcessExecutor = (ContextualProcessExecutor) executor;
        builder.put(CONTEXT, contextualProcessExecutor.getContext());
        builder.put(DELEGATE, serialize(contextualProcessExecutor.getDelegate()));
    } else {// ww w  .  jav  a2 s. c  o m
        throw new RuntimeException(
                String.format("Cannot serialize ProcessExecutor with class %s", executor.getClass()));
    }
    return builder.build();
}

From source file:io.crate.operation.reference.information.InformationDocLevelReferenceResolver.java

private static void add(ImmutableMap.Builder<ReferenceIdent, RowCollectExpression<?, ?>> builder,
        RowCollectExpression<?, ?> expression) {
    builder.put(expression.info().ident(), expression);
}

From source file:com.facebook.buck.jvm.java.ClassUsageFileWriterSerializer.java

public static ImmutableMap<String, Object> serialize(ClassUsageFileWriter writer) {
    ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();

    if (writer instanceof DefaultClassUsageFileWriter) {
        builder.put(TYPE, TYPE_DEFAULT);
        builder.put(RELATIVE_PATH, ((DefaultClassUsageFileWriter) writer).getRelativePath().toString());
    } else if (writer instanceof NoOpClassUsageFileWriter) {
        builder.put(TYPE, TYPE_NOOP);//w  w  w .j  av  a 2s .  c om
    } else {
        throw new UnsupportedOperationException(
                String.format("Cannot serialize ClassUsageFileWriter with class: %s", writer.getClass()));
    }

    return builder.build();
}

From source file:org.gradle.internal.component.external.model.DefaultMutableIvyModuleResolveMetadata.java

private static Map<String, Configuration> toMap(Collection<Configuration> configurations) {
    ImmutableMap.Builder<String, Configuration> builder = ImmutableMap.builder();
    for (Configuration configuration : configurations) {
        builder.put(configuration.getName(), configuration);
    }//from  ww  w.  j av  a 2 s  . co  m
    return builder.build();
}

From source file:com.isotrol.impe3.pms.core.obj.Builders.java

static <K, V> ImmutableMap.Builder<K, V> put(ImmutableMap.Builder<K, V> builder, K key, V value) {
    if (builder == null) {
        builder = ImmutableMap.builder();
    }/*from w  w  w. j ava  2  s .com*/
    return builder.put(key, value);
}

From source file:com.google.idea.blaze.base.lang.buildfile.language.semantics.BuildLanguageSpec.java

public static BuildLanguageSpec fromProto(Build.BuildLanguage proto) {
    ImmutableMap.Builder<String, RuleDefinition> builder = ImmutableMap.builder();
    for (Build.RuleDefinition rule : proto.getRuleList()) {
        builder.put(rule.getName(), RuleDefinition.fromProto(rule));
    }//w w w  .  j a v a  2 s.  c o  m
    return new BuildLanguageSpec(builder.build());
}

From source file:google.registry.rdap.RdapTestHelper.java

static void addTermsOfServiceNotice(ImmutableMap.Builder<String, Object> builder, String linkBase) {
    builder.put("notices",
            ImmutableList.of(ImmutableMap.of("title", "RDAP Terms of Service", "description",
                    ImmutableList.of(//from w  w w.  ja v  a2s.  co m
                            "By querying our Domain Database, you are agreeing to comply with these terms"
                                    + " so please read them carefully.",
                            "Any information provided is 'as is' without any guarantee of accuracy.",
                            "Please do not misuse the Domain Database. It is intended solely for"
                                    + " query-based access.",
                            "Don't use the Domain Database to allow, enable, or otherwise support the"
                                    + " transmission of mass unsolicited, commercial advertising or"
                                    + " solicitations.",
                            "Don't access our Domain Database through the use of high volume, automated"
                                    + " electronic processes that send queries or data to the systems of any"
                                    + " ICANN-accredited registrar.",
                            "You may only use the information contained in the Domain Database for lawful"
                                    + " purposes.",
                            "Do not compile, repackage, disseminate, or otherwise use the information"
                                    + " contained in the Domain Database in its entirety, or in any substantial"
                                    + " portion, without our prior written permission.",
                            "We may retain certain details about queries to our Domain Database for the"
                                    + " purposes of detecting and preventing misuse.",
                            "We reserve the right to restrict or deny your access to the database if we"
                                    + " suspect that you have failed to comply with these terms.",
                            "We reserve the right to modify this agreement at any time."),
                    "links",
                    ImmutableList.of(ImmutableMap.of("value", linkBase + "help/tos", "rel", "alternate", "href",
                            "https://www.registry.tld/about/rdap/tos.html", "type", "text/html")))));
}

From source file:com.google.cloud.datastore.ReadOption.java

static Map<Class<? extends ReadOption>, ReadOption> asImmutableMap(ReadOption... options) {
    ImmutableMap.Builder<Class<? extends ReadOption>, ReadOption> builder = ImmutableMap.builder();
    for (ReadOption option : options) {
        builder.put(option.getClass(), option);
    }//from  w w  w  . j a  v a2s. co  m
    return builder.build();
}

From source file:com.google.devtools.build.lib.pkgcache.LoadingPhaseRunner.java

/**
 * Returns a map of collected package names to root paths.
 *///from www  .ja v  a  2  s  .co  m
public static ImmutableMap<PackageIdentifier, Path> collectPackageRoots(Collection<Package> packages) {
    // Make a map of the package names to their root paths.
    ImmutableMap.Builder<PackageIdentifier, Path> packageRoots = ImmutableMap.builder();
    for (Package pkg : packages) {
        packageRoots.put(pkg.getPackageIdentifier(), pkg.getSourceRoot());
    }
    return packageRoots.build();
}