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:com.helion3.bedrock.commands.WorldCommand.java

public static CommandSpec getCommand() {
    ImmutableMap.Builder<List<String>, CommandCallable> builder = ImmutableMap
            .<List<String>, CommandCallable>builder();
    builder.put(ImmutableList.of("difficulty"), DifficultyCommand.getCommand());

    return CommandSpec.builder().executor((src, args) -> {
        return CommandResult.empty();
    }).children(builder.build()).build();
}

From source file:tech.tablesaw.io.jdbc.SqlResultSetReader.java

private static Map<Integer, ColumnType> initializeMap() {
    return new HashMap<>(new ImmutableMap.Builder<Integer, ColumnType>().put(Types.BINARY, ColumnType.BOOLEAN)
            .put(Types.BOOLEAN, ColumnType.BOOLEAN).put(Types.BIT, ColumnType.BOOLEAN)

            .put(Types.DATE, ColumnType.LOCAL_DATE).put(Types.TIME, ColumnType.LOCAL_TIME)
            // Instant, LocalDateTime, OffsetDateTime and ZonedDateTime are often mapped to timestamp
            .put(Types.TIMESTAMP, ColumnType.INSTANT)

            .put(Types.DECIMAL, ColumnType.DOUBLE).put(Types.DOUBLE, ColumnType.DOUBLE)
            .put(Types.FLOAT, ColumnType.DOUBLE).put(Types.NUMERIC, ColumnType.DOUBLE)
            .put(Types.REAL, ColumnType.FLOAT)

            .put(Types.INTEGER, ColumnType.INTEGER).put(Types.SMALLINT, ColumnType.SHORT)
            .put(Types.TINYINT, ColumnType.SHORT).put(Types.BIGINT, ColumnType.LONG)

            .put(Types.CHAR, ColumnType.STRING).put(Types.NCHAR, ColumnType.STRING)
            .put(Types.NVARCHAR, ColumnType.STRING).put(Types.VARCHAR, ColumnType.STRING)
            .put(Types.LONGVARCHAR, ColumnType.TEXT).put(Types.LONGNVARCHAR, ColumnType.TEXT).build());
}

From source file:org.apache.shindig.gadgets.rewrite.lexer.LinkingTagRewriter.java

public static Map<String, Set<String>> getDefaultTargets() {
    return new ImmutableMap.Builder<String, Set<String>>().put("img", ImmutableSet.of("src"))
            .put("embed", ImmutableSet.of("src")).put("link", ImmutableSet.of("href")).build();
}

From source file:io.divolte.server.js.TrackingJavaScriptResource.java

private static ImmutableMap<String, Object> createScriptConstants(final ValidatedConfiguration vc) {
    final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
    builder.put("PARTY_COOKIE_NAME", vc.configuration().tracking.partyCookie);
    builder.put("PARTY_ID_TIMEOUT_SECONDS",
            trimLongToMaxInt(vc.configuration().tracking.partyTimeout.get(ChronoUnit.SECONDS)));
    builder.put("SESSION_COOKIE_NAME", vc.configuration().tracking.sessionCookie);
    builder.put("SESSION_ID_TIMEOUT_SECONDS",
            trimLongToMaxInt(vc.configuration().tracking.sessionTimeout.get(ChronoUnit.SECONDS)));
    vc.configuration().tracking.cookieDomain.ifPresent((v) -> builder.put("COOKIE_DOMAIN", v));
    builder.put("LOGGING", vc.configuration().javascript.logging);
    builder.put(SCRIPT_CONSTANT_NAME, vc.configuration().javascript.name);
    builder.put("AUTO_PAGE_VIEW_EVENT", vc.configuration().javascript.autoPageViewEvent);
    return builder.build();
}

From source file:com.salesforce.jprotoc.ProtoTypeMap.java

/**
 * Returns an instance of {@link ProtoTypeMap} based on the given {@link DescriptorProtos.FileDescriptorProto}
 * instances.//w  w w  .  j  a  v  a  2s  .c  om
 *
 * @param fileDescriptorProtos the full collection of files descriptors from the code generator request
 */
public static ProtoTypeMap of(@Nonnull Collection<DescriptorProtos.FileDescriptorProto> fileDescriptorProtos) {
    Preconditions.checkNotNull(fileDescriptorProtos, "fileDescriptorProtos");
    Preconditions.checkArgument(!fileDescriptorProtos.isEmpty(), "fileDescriptorProtos.isEmpty()");

    final ImmutableMap.Builder<String, String> types = ImmutableMap.builder();

    for (final DescriptorProtos.FileDescriptorProto fileDescriptor : fileDescriptorProtos) {
        final DescriptorProtos.FileOptions fileOptions = fileDescriptor.getOptions();

        final String protoPackage = fileDescriptor.hasPackage() ? "." + fileDescriptor.getPackage() : "";
        final String javaPackage = Strings.emptyToNull(
                fileOptions.hasJavaPackage() ? fileOptions.getJavaPackage() : fileDescriptor.getPackage());
        final String enclosingClassName = fileOptions.getJavaMultipleFiles() ? null
                : getJavaOuterClassname(fileDescriptor, fileOptions);

        fileDescriptor.getEnumTypeList().forEach(e -> types.put(protoPackage + "." + e.getName(),
                toJavaTypeName(e.getName(), enclosingClassName, javaPackage)));

        fileDescriptor.getMessageTypeList().forEach(m -> types.put(protoPackage + "." + m.getName(),
                toJavaTypeName(m.getName(), enclosingClassName, javaPackage)));
    }

    return new ProtoTypeMap(types.build());
}

From source file:brooklyn.rest.transform.HighAvailabilityTransformer.java

public static HighAvailabilitySummary highAvailabilitySummary(String ownNodeId,
        ManagementPlaneSyncRecord memento) {
    Map<String, HaNodeSummary> nodes = Maps.newLinkedHashMap();
    for (Map.Entry<String, ManagementNodeSyncRecord> entry : memento.getManagementNodes().entrySet()) {
        nodes.put(entry.getKey(), haNodeSummary(entry.getValue()));
    }// w ww.  j a v  a 2 s.  com

    // TODO What links?
    ImmutableMap.Builder<String, URI> lb = ImmutableMap.<String, URI>builder();

    return new HighAvailabilitySummary(ownNodeId, memento.getMasterNodeId(), nodes, lb.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
 *///w w w  .j a va  2 s.  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:org.jclouds.openstack.nova.v1_1.util.NovaUtils.java

/**
 * The traditional way to represent a graph in Java is Map<V, Set<V>>, which is awkward in a
 * number of ways. Guava's Multimap framework makes it easy to handle a mapping from keys to
 * multiple values.//w  w w .ja  v a  2 s. c  om
 * <p/>
 * Until we write or discover a gson Multimap deserializer, we may be stuck with this.
 * 
 * TODO: ask on stackoverflow and/or jesse wilson
 */
@Deprecated
public static <K, V> Map<K, Set<V>> toOldSchool(Multimap<K, V> in) {
    ImmutableMap.Builder<K, Set<V>> out = ImmutableMap.<K, Set<V>>builder();
    for (K type : in.keySet())
        out.put(type, ImmutableSet.copyOf(in.get(type)));
    return out.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 www . j  a  va2s.c o  m
    return builder.put(key, value);
}

From source file:com.facebook.buck.command.config.AbstractConfigIgnoredByDaemon.java

private static ImmutableMap<String, ImmutableSet<String>> getIgnoreFieldsForDaemonRestart() {
    ImmutableMap.Builder<String, ImmutableSet<String>> ignoreFieldsForDaemonRestartBuilder = ImmutableMap
            .builder();//from  ww  w.j  a  va  2s . c  o  m
    ignoreFieldsForDaemonRestartBuilder.put("apple", ImmutableSet.of("generate_header_symlink_tree_only"));
    ignoreFieldsForDaemonRestartBuilder.put("build", ImmutableSet.of("threads"));
    ignoreFieldsForDaemonRestartBuilder.put("cache",
            ImmutableSet.of("dir", "dir_mode", "http_mode", "http_url", "mode", "slb_server_pool"));
    ignoreFieldsForDaemonRestartBuilder.put("client", ImmutableSet.of("id", "skip-action-graph-cache"));
    ignoreFieldsForDaemonRestartBuilder.put("intellij", ImmutableSet.of("multi_cell_module_support"));
    ignoreFieldsForDaemonRestartBuilder.put("log", ImmutableSet.of("chrome_trace_generation", "compress_traces",
            "max_traces", "public_announcements", "log_build_id_to_console_enabled", "build_details_template"));
    ignoreFieldsForDaemonRestartBuilder.put("project", ImmutableSet.of("ide_prompt", "ide_force_kill"));
    ignoreFieldsForDaemonRestartBuilder.put("ui",
            ImmutableSet.of("superconsole", "thread_line_limit", "thread_line_output_max_columns",
                    "warn_on_config_file_overrides", "warn_on_config_file_overrides_ignored_files"));
    ignoreFieldsForDaemonRestartBuilder.put("color", ImmutableSet.of("ui"));
    ignoreFieldsForDaemonRestartBuilder.put("version_control", ImmutableSet.of("generate_statistics"));
    return ignoreFieldsForDaemonRestartBuilder.build();
}