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

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

Introduction

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

Prototype

public static <K, V> ImmutableMap<K, V> copyOf(Iterable<? extends Entry<? extends K, ? extends V>> entries) 

Source Link

Usage

From source file:com.google.api.codegen.config.ResourceNameMessageConfig.java

@Nullable
public static ResourceNameMessageConfig createResourceNameMessageConfig(DiagCollector diagCollector,
        ResourceNameMessageConfigProto messageResourceTypesProto, String defaultPackage) {
    String messageName = messageResourceTypesProto.getMessageName();
    String fullyQualifiedMessageName = getFullyQualifiedMessageName(defaultPackage, messageName);
    ImmutableMap<String, String> fieldEntityMap = ImmutableMap
            .copyOf(messageResourceTypesProto.getFieldEntityMap());

    return new AutoValue_ResourceNameMessageConfig(fullyQualifiedMessageName, fieldEntityMap);
}

From source file:net.oneandone.neo.datareplicator.utils.Utils.java

public static ImmutableMap<String, String> toMap(String content) {
    return ImmutableMap.copyOf(Splitter.on("\n").trimResults().withKeyValueSeparator("=").split(content));
}

From source file:com.facebook.buck.intellij.plugin.config.BuckExecutableDetector.java

public static String getExecutable(Path suggestedExecutable) throws HumanReadableException {
    return EXECUTABLE_FINDER.getExecutable(suggestedExecutable, ImmutableMap.copyOf(System.getenv()))
            .toString();//ww  w.j  ava2  s.c o  m
}

From source file:com.facebook.buck.core.model.targetgraph.TargetGraphFactory.java

public static TargetGraph newInstance(Iterable<TargetNode<?>> nodes) {
    Map<BuildTarget, TargetNode<?>> builder = new HashMap<>();
    for (TargetNode<?> node : nodes) {
        builder.put(node.getBuildTarget(), node);
        BuildTarget unflavoredTarget = node.getBuildTarget().withoutFlavors();
        if (node.getBuildTarget().isFlavored() && !builder.containsKey(unflavoredTarget)) {
            builder.put(unflavoredTarget, node.withFlavors(ImmutableSet.of()));
        }//w  w w .j a  va  2  s  .  c  om
    }
    ImmutableMap<BuildTarget, TargetNode<?>> map = ImmutableMap.copyOf(builder);

    MutableDirectedGraph<TargetNode<?>> graph = new MutableDirectedGraph<>();
    for (TargetNode<?> node : map.values()) {
        graph.addNode(node);
        for (BuildTarget dep : node.getBuildDeps()) {
            graph.addEdge(node, Objects.requireNonNull(map.get(dep), dep::toString));
        }
    }
    return new TargetGraph(graph, map);
}

From source file:com.microsoft.thrifty.schema.parser.AnnotationElement.java

public static AnnotationElement create(Location location, Map<String, String> values) {
    return new AutoValue_AnnotationElement(location, ImmutableMap.copyOf(values));
}

From source file:com.facebook.buck.config.BuckConfigTestUtils.java

public static BuckConfig createWithDefaultFilesystem(TemporaryPaths temporaryFolder, Reader reader)
        throws IOException {
    ProjectFilesystem projectFilesystem = TestProjectFilesystems
            .createProjectFilesystem(temporaryFolder.getRoot());
    return createFromReader(reader, projectFilesystem, Architecture.detect(), Platform.detect(),
            ImmutableMap.copyOf(System.getenv()));
}

From source file:com.facebook.buck.testutil.TargetGraphFactory.java

public static TargetGraph newInstance(Iterable<TargetNode<?, ?>> nodes) {
    Map<BuildTarget, TargetNode<?, ?>> builder = new HashMap<>();
    for (TargetNode<?, ?> node : nodes) {
        builder.put(node.getBuildTarget(), node);
        BuildTarget unflavoredTarget = BuildTarget.of(node.getBuildTarget().getUnflavoredBuildTarget());
        if (node.getBuildTarget().isFlavored() && !builder.containsKey(unflavoredTarget)) {
            builder.put(unflavoredTarget, node);
        }//from w  ww  . j  a v  a 2s.c o m
    }
    ImmutableMap<BuildTarget, TargetNode<?, ?>> map = ImmutableMap.copyOf(builder);

    MutableDirectedGraph<TargetNode<?, ?>> graph = new MutableDirectedGraph<>();
    for (TargetNode<?, ?> node : map.values()) {
        graph.addNode(node);
        for (BuildTarget dep : node.getDeps()) {
            graph.addEdge(node, Preconditions.checkNotNull(map.get(dep), dep));
        }
    }
    return new TargetGraph(graph, map, ImmutableSet.of());
}

From source file:org.sakaiproject.nakamura.util.MapUtils.java

/**
 * Converts a name value string delimited with = and ; into an immutable map.
 * /* ww w  .j a v a  2  s .c  o m*/
 * @param values
 *          the contents of the map
 * @return an immutable map.
 */
public static Map<String, String> convertToImmutableMap(String values) {
    Map<String, String> m = Maps.newHashMap();
    String[] templates = StringUtils.split(values, ';');
    for (String template : templates) {
        String[] nv = StringUtils.split(template, '=', 2);
        if (nv != null && nv.length > 1) {
            m.put(nv[0].trim(), nv[1].trim());
        }
    }
    return ImmutableMap.copyOf(m);
}

From source file:org.onosproject.store.consistent.impl.DatabaseDefinition.java

/**
 * Creates a new DatabaseDefinition.//  ww w. j  ava  2s  .co m
 *
 * @param partitions partition map
 * @param nodes      set of nodes
 * @return database definition
 */
public static DatabaseDefinition from(Map<String, Set<NodeInfo>> partitions, Set<NodeInfo> nodes) {
    checkNotNull(partitions);
    checkNotNull(nodes);
    DatabaseDefinition definition = new DatabaseDefinition();
    definition.partitions = ImmutableMap.copyOf(partitions);
    definition.nodes = ImmutableSet.copyOf(nodes);
    return definition;
}

From source file:com.spotify.apollo.RequestValue.java

private static Request create(String method, String uri, Map<String, List<String>> parameters, Headers headers,
        Optional<String> service, Optional<ByteString> payload, Optional<Duration> ttl) {
    return new AutoValue_RequestValue(method, uri, ImmutableMap.copyOf(parameters), headers, service, payload,
            ttl);/*w ww .  j  a va2  s.c o  m*/
}