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.google.devtools.common.options.OptionFilterDescriptions.java

public static ImmutableMap<OptionEffectTag, String> getOptionEffectTagDescription(String productName) {
    ImmutableMap.Builder<OptionEffectTag, String> effectTagDescriptionBuilder = ImmutableMap.builder();
    effectTagDescriptionBuilder
            .put(OptionEffectTag.UNKNOWN, "This option has unknown, or undocumented, effect.")
            .put(OptionEffectTag.NO_OP, "This option has literally no effect.")
            .put(OptionEffectTag.LOSES_INCREMENTAL_STATE,
                    "Changing the value of this option can cause significant loss of incremental "
                            + "state, which slows builds. State could be lost due to a server restart or to "
                            + "invalidation of a large part of the dependency graph.")
            .put(OptionEffectTag.CHANGES_INPUTS,
                    "This option actively changes the inputs that " + productName
                            + " considers for the build, such as filesystem restrictions, repository versions, "
                            + "or other options.")
            .put(OptionEffectTag.AFFECTS_OUTPUTS,
                    "This option affects " + productName
                            + "'s outputs. This tag is intentionally broad, can include transitive affects, "
                            + "and does not specify the type of output it affects.")
            .put(OptionEffectTag.BUILD_FILE_SEMANTICS,
                    "This option affects the semantics of BUILD or .bzl files.")
            .put(OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION,
                    "This option affects settings of " + productName
                            + "-internal machinery. This tag does not, on its own, mean that build artifacts "
                            + "are affected.")
            .put(OptionEffectTag.LOADING_AND_ANALYSIS,
                    "This option affects the loading and analysis of dependencies, and the building "
                            + "of the dependency graph.")
            .put(OptionEffectTag.EXECUTION,
                    "This option affects the execution phase, such as sandboxing or remote execution "
                            + "related options.")
            .put(OptionEffectTag.HOST_MACHINE_RESOURCE_OPTIMIZATIONS,
                    "This option triggers an optimization that may be machine specific and is not "
                            + "guaranteed to work on all machines. The optimization could include a tradeoff "
                            + "with other aspects of performance, such as memory or cpu cost.")
            .put(OptionEffectTag.EAGERNESS_TO_EXIT,
                    "This option changes how eagerly " + productName
                            + " will exit from a failure, where a choice between continuing despite the "
                            + "failure and ending the invocation exists.")
            .put(OptionEffectTag.BAZEL_MONITORING,
                    "This option is used to monitor " + productName + "'s behavior and performance.")
            .put(OptionEffectTag.TERMINAL_OUTPUT, "This option affects " + productName + "'s terminal output.")
            .put(OptionEffectTag.ACTION_COMMAND_LINES,
                    "This option changes the command line arguments of one or more build actions.")
            .put(OptionEffectTag.TEST_RUNNER, "This option changes the testrunner environment of the build.");
    return effectTagDescriptionBuilder.build();
}

From source file:com.google.idea.blaze.base.lang.projectview.language.ProjectViewKeywords.java

private static ImmutableMap<String, ListSectionParser> getListKeywordMap() {
    ImmutableMap.Builder<String, ListSectionParser> builder = ImmutableMap.builder();
    for (SectionParser parser : Sections.getParsers()) {
        if (parser instanceof ListSectionParser) {
            builder.put(parser.getName(), (ListSectionParser) parser);
        }/* www .  ja  v a 2  s .c  o m*/
    }
    return builder.build();
}

From source file:ai.grakn.graql.internal.gremlin.spanningtree.graph.DirectedEdge.java

public static <T> Predicate<DirectedEdge<T>> competesWith(final Set<DirectedEdge<T>> required) {
    final ImmutableMap.Builder<T, T> requiredSourceByDestinationBuilder = ImmutableMap.builder();
    for (DirectedEdge<T> edge : required) {
        requiredSourceByDestinationBuilder.put(edge.destination, edge.source);
    }// w ww  .  ja v  a2s  . co m
    final Map<T, T> requiredSourceByDest = requiredSourceByDestinationBuilder.build();
    return input -> {
        assert input != null;
        return (requiredSourceByDest.containsKey(input.destination)
                && !input.source.equals(requiredSourceByDest.get(input.destination)));
    };
}

From source file:at.ac.univie.isc.asio.tool.Beans.java

/**
 * Create a copy of given input properties.
 *
 * @param input source properties/*from   w ww . j  av  a2s . c  o  m*/
 * @param exclude keys of properties that should be omitted
 * @return map of copied properties
 */
public static Map<String, String> copyToMap(final Properties input, final String... exclude) {
    final ImmutableSet<String> excluded = ImmutableSet.copyOf(exclude);
    final ImmutableMap.Builder<String, String> clone = ImmutableMap.builder();
    for (String key : input.stringPropertyNames()) {
        if (!excluded.contains(key)) {
            clone.put(key, input.getProperty(key));
        }
    }
    return clone.build();
}

From source file:com.sun.tools.hat.internal.server.ObjectQuery.java

private static Map<JavaField, JavaThing> makeFieldMap(JavaField[] fields, JavaThing[] values) {
    ImmutableMap.Builder<JavaField, JavaThing> builder = ImmutableMap.builder();
    for (int i = 0; i < fields.length; ++i) {
        builder.put(fields[i], values[i]);
    }/*from ww  w .ja  va2 s.c om*/
    return builder.build();
}

From source file:com.spotify.missinglink.Simple.java

public static Artifact newArtifact(String name, DeclaredClass... classes) {
    final ImmutableMap.Builder<ClassTypeDescriptor, DeclaredClass> builder = ImmutableMap.builder();
    for (DeclaredClass clazz : classes) {
        builder.put(clazz.className(), clazz);
    }/*from w  ww . j  a v  a  2 s .  co m*/

    return new ArtifactBuilder().name(new ArtifactName(name)).classes(builder.build()).build();
}

From source file:org.apache.tajo.util.TimeZoneUtil.java

private static ImmutableMap<String, String> load() {
    ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String>builder();
    String[] timezoneIds = java.util.TimeZone.getAvailableIDs();
    for (String timezoneId : timezoneIds) {
        builder.put(timezoneId.toUpperCase(), timezoneId);
    }//  www  .  ja v a2s. c o  m

    return builder.build();
}

From source file:com.google.idea.blaze.base.lang.projectview.language.ProjectViewKeywords.java

/** We get the parser so we have access to both the keyword and the divider char. */
private static ImmutableMap<String, ScalarSectionParser> getScalarKeywordMap() {
    ImmutableMap.Builder<String, ScalarSectionParser> builder = ImmutableMap.builder();
    for (SectionParser parser : Sections.getParsers()) {
        if (parser instanceof ScalarSectionParser) {
            builder.put(parser.getName(), (ScalarSectionParser) parser);
        }//from  w  w w  .  java 2s .c o  m
    }
    return builder.build();
}

From source file:com.google.api.codegen.ruby.RubyApiaryNameMap.java

@SuppressWarnings("unchecked")
private static ImmutableMap<ResourceId, String> getNameMap() throws IOException {
    String data = Resources.toString(Resources.getResource(RubyApiaryNameMap.class, "apiary_names.yaml"),
            StandardCharsets.UTF_8);

    // Unchecked cast here.
    Map<String, String> nameData = (Map<String, String>) (new Yaml().load(data));
    ImmutableMap.Builder<ResourceId, String> builder = ImmutableMap.<ResourceId, String>builder();
    for (Map.Entry<String, String> entry : nameData.entrySet()) {
        builder.put(parseKey(entry.getKey()), entry.getValue());
    }/*from w  ww  . j a v a  2  s.  c o  m*/
    return builder.build();
}

From source file:com.google.walkaround.util.server.flags.JsonFlags.java

/**
 * The returned map is guaranteed to map every FlagDeclaration <code>decl</code> in
 * <code>flagDeclarations</code> to a non-null Object of type <code>decl.getType()</code>.
 *//*from  w  ww.jav a2s  .  co  m*/
public static Map<FlagDeclaration, Object> parse(Iterable<? extends FlagDeclaration> flagDeclarations,
        String jsonString) throws FlagFormatException {
    JsonObject json;
    try {
        json = new JsonParser().parse(jsonString).getAsJsonObject();
    } catch (JsonParseException e) {
        throw new FlagFormatException("Failed to parse jsonString: " + jsonString, e);
    }
    // TODO(ohler): Detect unknown flags and error (or at least warn).
    ImmutableMap.Builder<FlagDeclaration, Object> b = ImmutableMap.builder();
    for (FlagDeclaration decl : flagDeclarations) {
        b.put(decl, parseOneFlag(decl, json));
    }
    return b.build();
}