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:org.ambraproject.wombat.config.site.SiteTemplateLoader.java

private static ImmutableMap<String, TemplateLoader> buildLoaders(ServletContext servletContext, SiteSet siteSet)
        throws IOException {
    ImmutableMap.Builder<String, TemplateLoader> builder = ImmutableMap.builder();

    // Add the loader for the application root page
    builder.put("", new WebappTemplateLoader(servletContext, "/WEB-INF/themes/root/app/"));

    // Add loader for each site
    for (Site site : siteSet.getSites()) {
        Theme leaf = site.getTheme();//from  ww w  . j a  v a 2  s  .c  o m

        List<TemplateLoader> loaders = Lists.newArrayList();
        for (Theme theme : leaf.getInheritanceChain()) {
            loaders.add(theme.getTemplateLoader());
        }

        MultiTemplateLoader multiLoader = new MultiTemplateLoader(
                loaders.toArray(new TemplateLoader[loaders.size()]));
        builder.put(site.getKey(), multiLoader);
    }

    return builder.build();
}

From source file:org.jetbrains.android.dom.lint.IssueIdConverter.java

@NotNull
public static ImmutableMap<String, Issue> getIdSet() {
    if (ourIssues == null) {
        final ImmutableMap.Builder<String, Issue> builder = ImmutableMap.builder();
        for (Issue issue : new BuiltinIssueRegistry().getIssues()) {
            builder.put(issue.getId(), issue);
        }//w  w w .  ja  v  a  2 s . c  om

        ourIssues = builder.build();
    }

    return ourIssues;
}

From source file:com.google.gxp.compiler.parser.JavaNamespace.java

private static Map<String, ElementType> initElements() {
    ImmutableMap.Builder<String, ElementType> builder = ImmutableMap.builder();
    for (ElementType type : ElementType.values()) {
        builder.put(type.name().toLowerCase(), type);
    }/*from  ww w  . j a  v  a  2 s. c om*/
    return builder.build();
}

From source file:com.facebook.presto.connector.informationSchema.InformationSchemaColumnHandle.java

public static Map<String, ColumnHandle> toInformationSchemaColumnHandles(ConnectorTableMetadata tableMetadata) {
    ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder();
    for (ColumnMetadata columnMetadata : tableMetadata.getColumns()) {
        columnHandles.put(columnMetadata.getName(),
                new InformationSchemaColumnHandle(columnMetadata.getName()));
    }//from w  w  w . j ava 2  s.c  o m

    return columnHandles.build();
}

From source file:com.google.template.soy.shared.internal.InternalPlugins.java

public static ImmutableMap<String, SoyFunction> fromLegacyFunctions(Iterable<? extends SoyFunction> functions) {
    ImmutableMap.Builder<String, SoyFunction> builder = ImmutableMap.builder();
    for (SoyFunction function : functions) {
        builder.put(function.getName(), function);
    }//from w  w w. j  a  v  a  2  s .  c  o m
    return builder.build();
}

From source file:com.google.caliper.XmlUtils.java

public static ImmutableMap<String, String> attributesOf(Element element) {
    NamedNodeMap map = element.getAttributes();
    ImmutableMap.Builder<String, String> result = ImmutableMap.builder();
    for (int i = 0, size = map.getLength(); i < size; i++) {
        Attr attr = (Attr) map.item(i);
        result.put(attr.getName(), attr.getValue());
    }/*from www  . j  av a 2  s .  c  om*/
    return result.build();
}

From source file:com.isotrol.impe3.core.impl.ContentTypesFactory.java

/**
 * Returns a collection of cookies containing the provided content types.
 * @param types Content types to add to the collection.
 * @return The requested collection./*from  w ww  .j ava2s.  c o m*/
 * @throws NullPointerException if the argument is null.
 * @throws IllegalArgumentException if there are more than one content type with the same id.
 */
public static ContentTypes of(Iterable<ContentType> types) {
    Preconditions.checkNotNull(types);
    final ImmutableMap.Builder<UUID, ContentType> builder = ImmutableMap.builder();
    for (final ContentType type : types) {
        builder.put(type.getId(), type);
    }
    return new Immutable(builder.build());
}

From source file:com.sos.scheduler.engine.kernel.command.DispatchingCommandExecutor.java

private static ImmutableMap<Class<?>, CommandExecutor> mapOfExecutors(Iterable<CommandExecutor> executors) {
    ImmutableMap.Builder<Class<?>, CommandExecutor> b = new ImmutableMap.Builder<Class<?>, CommandExecutor>();
    for (CommandExecutor ex : executors)
        b.put(ex.getCommandClass(), ex);
    return b.build();
}

From source file:com.cloudera.csd.validation.SdlTestUtils.java

public static Map<String, RoleDescriptor> makeRoleMap(Collection<RoleDescriptor> roles) {
    ImmutableMap.Builder<String, RoleDescriptor> builder = ImmutableMap.builder();
    for (RoleDescriptor r : roles) {
        builder.put(r.getName(), r);
    }/*from  ww  w .  j a v a2 s. co  m*/
    return builder.build();
}

From source file:org.apache.druid.server.metrics.MonitorsConfig.java

public static Map<String, String[]> mapOfDatasourceAndTaskID(final String datasource, final String taskId) {
    final ImmutableMap.Builder<String, String[]> builder = ImmutableMap.builder();
    if (datasource != null) {
        builder.put(DruidMetrics.DATASOURCE, new String[] { datasource });
    }/*from   w w  w .  j  a  v a  2  s .c om*/
    if (taskId != null) {
        builder.put(DruidMetrics.ID, new String[] { taskId });
    }
    return builder.build();
}