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.jgaap.backend.Canonicizers.java

private static ImmutableMap<String, Canonicizer> loadCanonicizersMap() {
    // Load the canonicizers dynamically
    ImmutableMap.Builder<String, Canonicizer> builder = ImmutableMap.builder();
    for (Canonicizer canon : CANONICIZERS) {
        builder.put(canon.displayName().toLowerCase().trim(), canon);
    }//from w w w  . j a  v a2s. c  o m
    return builder.build();
}

From source file:nextmethod.web.razor.tokenizer.JavaKeywordDetector.java

private static Map<String, JavaKeyword> createKeywordsMap() {
    final ImmutableMap.Builder<String, JavaKeyword> builder = ImmutableMap.<String, JavaKeyword>builder();

    for (JavaKeyword keyword : JavaKeyword.values()) {
        builder.put(keyword.keyword(), keyword);
    }/*from   www  .j a va 2  s  . c o m*/

    return builder.build();
}

From source file:com.google.api.codegen.common.GeneratedResult.java

/**
 * Converts a map of results (body plus properties) to a map of bodies (stripping properties).
 *
 * @param results results map to convert
 * @param <T> class which represents result body
 *///  w w w  . j  av a 2  s.  c o  m
public static <T> Map<String, T> extractBodies(Map<String, GeneratedResult<T>> results) {
    ImmutableMap.Builder<String, T> extractedResults = ImmutableMap.builder();
    for (Map.Entry<String, GeneratedResult<T>> entry : results.entrySet()) {
        extractedResults.put(entry.getKey(), Objects.requireNonNull(entry.getValue().getBody()));
    }
    return extractedResults.build();
}

From source file:com.netflix.atlas.client.util.NetflixTagKey.java

private static void put(ImmutableMap.Builder<String, String> builder, String k, String v) {
    if (v != null && v.length() > 0) {
        builder.put(k, v);
    }/*  www  .  j  a v a  2s. com*/
}

From source file:org.apache.jackrabbit.oak.cache.StringCache.java

private static Map<String, String> createStringMap(String... strings) {
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
    for (String string : strings) {
        builder.put(string, string);
    }//from  www.ja v  a  2 s .c  o m
    return builder.build();
}

From source file:com.proofpoint.configuration.ConfigurationLoader.java

private static ImmutableMap<String, String> toMap(Properties properties) {
    ImmutableMap.Builder<String, String> result = ImmutableMap.builder();
    for (Map.Entry<Object, Object> entry : properties.entrySet()) {
        result.put(entry.getKey().toString(), entry.getValue().toString());
    }//from  w w  w.j  av a 2 s  .  c o m

    return result.build();
}

From source file:org.prebake.service.plan.PlanGraph.java

public static Builder builder(Product... nodes) {
    ImmutableMap.Builder<BoundName, Product> products = ImmutableMap.builder();
    for (Product p : nodes) {
        products.put(p.name, p);
    }//  w  w w . j  a v a  2 s. c o  m
    return new Builder(products.build());
}

From source file:com.jgaap.backend.EventCullers.java

private static ImmutableMap<String, EventCuller> loadEventCullersMap() {
    // Load the classifiers dynamically
    ImmutableMap.Builder<String, EventCuller> builder = ImmutableMap.builder();
    for (EventCuller eventCuller : EVENT_CULLERS) {
        builder.put(eventCuller.displayName().toLowerCase().trim(), eventCuller);
    }/*from  ww  w  . ja  v  a 2 s.  co  m*/
    return builder.build();
}

From source file:com.gradleware.tooling.testing.Combinations.java

/**
 * Returns all combinations for the given lists.
 *
 * @param lists the lists whose elements to combine, must not be null
 * @return all the combinations, never null
 *//*from w  w  w.j  av  a  2s . c  o m*/
public static ImmutableList<List<Object>> getCombinations(List<?>... lists) {
    Preconditions.checkNotNull(lists);

    if (lists.length == 0) {
        return ImmutableList.of();
    }

    ImmutableMap.Builder<Integer, List<?>> listsMappedByDepth = ImmutableMap.builder();
    for (int i = 0; i < lists.length; i++) {
        listsMappedByDepth.put(i, lists[i]);
    }

    return getCombinationsRecursive(listsMappedByDepth.build(), 0, new Object[(lists.length)]);
}

From source file:com.google.errorprone.refaster.Match.java

public static Match create(TemplateMatch match) {
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
    for (Map.Entry<Bindings.Key<?>, Object> entry : match.getUnifier().getBindings().entrySet()) {
        builder.put(entry.getKey().getIdentifier(), entry.getValue().toString());
    }/*  w  ww  .  j a va2  s  .co m*/
    return create(builder.build());
}