Example usage for com.google.common.collect ImmutableMap builder

List of usage examples for com.google.common.collect ImmutableMap builder

Introduction

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

Prototype

public static <K, V> Builder<K, V> builder() 

Source Link

Usage

From source file:dk.ilios.spanner.benchmark.ParameterSet.java

/**
 * Returns the set of all parameters and their possible values.
 * @param benchmarkClass    Benchmark class.
 * @param annotationClass   Annotation specifying a parameter.
 * @return// w  ww .  jav a 2s  .com
 * @throws InvalidBenchmarkException
 */
public static ParameterSet create(Class<?> benchmarkClass, Class<? extends Annotation> annotationClass)
        throws InvalidBenchmarkException {
    // deterministic order, not reflection order
    ImmutableMap.Builder<String, Parameter> parametersBuilder = ImmutableSortedMap.naturalOrder();

    for (Field field : benchmarkClass.getDeclaredFields()) {
        if (field.isAnnotationPresent(annotationClass)) {
            Parameter parameter = Parameter.create(field);
            parametersBuilder.put(field.getName(), parameter);
        }
    }
    return new ParameterSet(parametersBuilder.build());
}

From source file:com.fitbur.core.guava.collect.provider.ImmutableMapBuilder.java

@Override
public ImmutableMap.Builder provide() {
    return new ImmutableMap.Builder();
}

From source file:it.infn.mw.iam.authn.saml.util.SamlIdResolvers.java

public SamlIdResolvers() {
    ImmutableMap.Builder<String, SamlUserIdentifierResolver> builder = ImmutableMap
            .<String, SamlUserIdentifierResolver>builder();

    for (Saml2Attribute a : Saml2Attribute.values()) {
        builder.put(a.getAlias(), new AttributeUserIdentifierResolver(a));
    }/* w w w.  j av a 2  s  . c  om*/

    builder.put(NAME_ID_NAME, new NameIdUserIdentifierResolver());

    registeredResolvers = builder.build();
}

From source file:com.helion3.safeguard.commands.SafeGuardCommands.java

/**
 * Build a complete command hierarchy//from   w w  w.  ja va2 s.  co  m
 * @return
 */
public static CommandSpec getCommand() {
    ImmutableMap.Builder<List<String>, CommandCallable> builder = ImmutableMap.builder();
    builder.put(ImmutableList.of("pos", "position"), PositionCommand.getCommand());
    builder.put(ImmutableList.of("zone", "z"), ZoneCommands.getCommand());
    builder.put(ImmutableList.of("reload"), ReloadCommand.getCommand());
    builder.put(ImmutableList.of("?", "help"), HelpCommand.getCommand());

    return CommandSpec.builder().executor((src, args) -> {
        src.sendMessage(Text.of(Format.heading(TextColors.GRAY, "By ", TextColors.GOLD, "viveleroi.\n"),
                TextColors.GRAY, "Help: ", TextColors.WHITE, "/sg ?\n", TextColors.GRAY, "IRC: ",
                TextColors.WHITE, "irc.esper.net #helion3\n"));
        return CommandResult.empty();
    }).children(builder.build()).build();
}

From source file:com.google.devtools.common.options.OptionFilterDescriptions.java

static ImmutableMap<OptionDocumentationCategory, String> getOptionCategoriesEnumDescription(
        String productName) {//from  w w w.ja v a  2 s.c  o  m
    ImmutableMap.Builder<OptionDocumentationCategory, String> optionCategoriesBuilder = ImmutableMap.builder();
    optionCategoriesBuilder
            .put(OptionDocumentationCategory.UNCATEGORIZED, "Miscellaneous options, not otherwise categorized.")
            .put( // Here for completeness, the help output should not include this option.
                    OptionDocumentationCategory.UNDOCUMENTED,
                    "This feature should not be documented, as it is not meant for general use")
            .put(OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
                    "Options that appear before the command and are parsed by the client")
            .put(OptionDocumentationCategory.LOGGING,
                    "Options that affect the verbosity, format or location of logging")
            .put(OptionDocumentationCategory.EXECUTION_STRATEGY, "Options that control build execution")
            .put(OptionDocumentationCategory.BUILD_TIME_OPTIMIZATION,
                    "Options that trigger optimizations of the build time")
            .put(OptionDocumentationCategory.OUTPUT_SELECTION, "Options that control the output of the command")
            .put(OptionDocumentationCategory.OUTPUT_PARAMETERS,
                    "Options that let the user configure the intended output, affecting its value, as "
                            + "opposed to its existence")
            .put(OptionDocumentationCategory.INPUT_STRICTNESS,
                    "Options that affect how strictly Bazel enforces valid build inputs (rule definitions, "
                            + " flag combinations, etc.)")
            .put(OptionDocumentationCategory.SIGNING, "Options that affect the signing outputs of a build")
            .put(OptionDocumentationCategory.TESTING,
                    "Options that govern the behavior of the test environment or test runner")
            .put(OptionDocumentationCategory.TOOLCHAIN,
                    "Options that configure the toolchain used for action execution")
            .put(OptionDocumentationCategory.QUERY, "Options relating to query output and semantics")
            .put(OptionDocumentationCategory.GENERIC_INPUTS,
                    "Options specifying or altering a generic input to a Bazel command that does not fall "
                            + "into other categories.");
    return optionCategoriesBuilder.build();
}

From source file:com.yahoo.yqlplus.engine.java.SourceBindingModule.java

@SuppressWarnings("unchecked")
public SourceBindingModule(Object... kvPairs) {
    ImmutableMap.Builder<String, Source> sourceInstances = ImmutableMap.builder();
    ImmutableMap.Builder<String, Exports> exportsInstances = ImmutableMap.builder();
    ImmutableMap.Builder<String, Class<? extends Source>> sources = ImmutableMap.builder();
    ImmutableMap.Builder<String, Class<? extends Exports>> exports = ImmutableMap.builder();
    for (int i = 0; i < kvPairs.length; i += 2) {
        String key = (String) kvPairs[i];
        if (kvPairs[i + 1] instanceof Source) {
            sourceInstances.put(key, (Source) kvPairs[i + 1]);
            continue;
        } else if (kvPairs[i + 1] instanceof Exports) {
            exportsInstances.put(key, (Exports) kvPairs[i + 1]);
            continue;
        }//from  w w  w  .j  a  v a2  s  .c o m
        Class<?> clazz = (Class<?>) kvPairs[i + 1];
        if (Source.class.isAssignableFrom(clazz)) {
            sources.put(key, (Class<? extends Source>) kvPairs[i + 1]);
        } else if (Exports.class.isAssignableFrom(clazz)) {
            exports.put(key, (Class<? extends Exports>) kvPairs[i + 1]);
        } else {
            throw new IllegalArgumentException("Don't know how to bind " + clazz);
        }
    }
    this.sources = sources.build();
    this.exports = exports.build();
    this.sourceInstances = sourceInstances.build();
    this.exportInstances = exportsInstances.build();
}

From source file:com.b2international.snowowl.snomed.api.rest.CodeSystemVersionRestRequests.java

public static ValidatableResponse createVersion(String shortName, String version, String effectiveDate) {
    Map<?, ?> requestBody = ImmutableMap.builder().put("version", version).put("description", version)
            .put("effectiveDate", effectiveDate).build();

    return givenAuthenticatedRequest(SnomedApiTestConstants.ADMIN_API).contentType(ContentType.JSON)
            .body(requestBody).post("/codesystems/{shortNameOrOid}/versions", shortName).then();
}

From source file:com.efficios.jabberwocky.lttng.ust.analysis.debuginfo.UstDebugInfoAnalysisDefinitions.java

private static Map<String, Integer> buildEventNames(LttngUst28EventLayout layout) {
    ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
    builder.put(layout.eventDlOpen(), DL_DLOPEN_INDEX);
    builder.put(layout.eventDlBuildId(), DL_BUILD_ID_INDEX);
    builder.put(layout.eventDlDebugLink(), DL_DEBUG_LINK_INDEX);
    builder.put(layout.eventDlClose(), DL_DLCLOSE_INDEX);
    builder.put(layout.eventStatedumpBinInfo(), STATEDUMP_BIN_INFO_INDEX);
    builder.put(layout.eventStateDumpBuildId(), STATEDUMP_BUILD_ID_INDEX);
    builder.put(layout.eventStateDumpDebugLink(), STATEDUMP_DEBUG_LINK_INDEX);
    builder.put(layout.eventStatedumpStart(), STATEDUMP_START_INDEX);
    return builder.build();
}

From source file:com.google.copybara.Options.java

public Options(Iterable<? extends Option> options) {
    ImmutableMap.Builder<Class<? extends Option>, Option> builder = ImmutableMap.builder();
    for (Option option : options) {
        builder.put(option.getClass(), option);
    }//from w w  w.  ja v a 2 s. co  m
    config = builder.build();
}

From source file:consumer.kafka.ProcessedOffsetManager.java

private static void persistProcessedOffsets(Properties props, Map<Integer, Long> partitionOffsetMap) {
    ZkState state = new ZkState(props.getProperty(Config.ZOOKEEPER_CONSUMER_CONNECTION));
    for (Map.Entry<Integer, Long> po : partitionOffsetMap.entrySet()) {
        Map<Object, Object> data = (Map<Object, Object>) ImmutableMap.builder()
                .put("consumer", ImmutableMap.of("id", props.getProperty(Config.KAFKA_CONSUMER_ID)))
                .put("offset", po.getValue()).put("partition", po.getKey())
                .put("broker", ImmutableMap.of("host", "", "port", ""))
                .put("topic", props.getProperty(Config.KAFKA_TOPIC)).build();
        String path = processedPath(po.getKey(), props);
        try {// w  ww . j a v  a  2s .  co  m
            state.writeJSON(path, data);
        } catch (Exception ex) {
            state.close();
            throw ex;
        }
    }
    state.close();
}