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:net.morimekta.config.impl.MappedConfig.java

public MappedConfig(Supplier<Config> contained, Map<String, String> mapping) {
    this.contained = contained;
    this.mapping = ImmutableMap.copyOf(mapping);
}

From source file:com.b2international.commons.graph.GraphUtilsInternal.java

/**
 * Returns with the longest path from the DAG represented as the map argument.
 * <p>Keys are nodes and there are a dedicated edged to each value associated with a key. 
 * @param map the graph as a map.// ww  w  .  j  a v a 2  s  . co m
 * @return the longest path.
 */
/*default*/ static <N> List<N> getLongestPath(final Map<? extends N, Collection<N>> map) {

    checkNotNull(map, "map");

    final Map<N, Collection<N>> copy = ImmutableMap.copyOf(map);

    final Map<N, Node> nodes = newHashMap();
    final PrimaryGraph graph = new PrimaryGraph();

    //initialize nodes in the graph
    for (final Entry<N, Collection<N>> entry : copy.entrySet()) {
        final N key = entry.getKey();

        if (!nodes.containsKey(key)) {
            nodes.put(key, graph.newNode(key));
        }

        final Iterable<? extends N> values = entry.getValue();
        if (!isEmpty(values)) {
            for (final N node : values) {
                if (!nodes.containsKey(node)) {
                    nodes.put(node, graph.newNode(node));
                }
            }
        }
    }

    for (final N node : nodes.keySet()) {
        final Node graphNode = nodes.get(node);

        final Iterable<? extends N> targetNodes = copy.get(node);
        if (!isEmpty(targetNodes)) {
            for (final N targetNode : targetNodes) {
                graph.newEdge(graphNode, nodes.get(targetNode));
            }
        }
    }

    return getValueArray(getLongestPath(graph));

}

From source file:com.continuuity.weave.internal.DefaultWeaveSpecification.java

public DefaultWeaveSpecification(String name, Map<String, RuntimeSpecification> runnables, List<Order> orders) {
    this.name = name;
    this.runnables = ImmutableMap.copyOf(runnables);
    this.orders = ImmutableList.copyOf(orders);
}

From source file:com.facebook.buck.rules.DefaultCellPathResolver.java

private static ImmutableMap<String, Path> getCellPathsFromConfigRepositoriesSection(Path root,
        ImmutableMap<String, String> repositoriesSection) {
    return ImmutableMap.copyOf(Maps.transformValues(repositoriesSection,
            input -> root.resolve(MorePaths.expandHomeDir(root.getFileSystem().getPath(input))).normalize()));
}

From source file:org.jclouds.azurecompute.arm.domain.StorageServiceUpdateParams.java

@SerializedNames({ "tags", "properties" })
public static StorageServiceUpdateParams create(final Map<String, String> tags,
        final StorageServiceUpdateProperties storageServiceProperties) {
    return new AutoValue_StorageServiceUpdateParams(tags == null ? null : ImmutableMap.copyOf(tags),
            storageServiceProperties);//from   www.j  a v  a2  s.com
}

From source file:io.airlift.drift.transport.MethodMetadata.java

public static MethodMetadata toMethodMetadata(ThriftCodecManager codecManager, ThriftMethodMetadata metadata) {
    List<ParameterMetadata> parameters = metadata
            .getParameters().stream().map(parameter -> new ParameterMetadata(parameter.getId(),
                    parameter.getName(), getCodec(codecManager, parameter.getThriftType())))
            .collect(Collectors.toList());

    ThriftCodec<Object> resultCodec = getCodec(codecManager, metadata.getReturnType());

    Map<Short, ThriftCodec<Object>> exceptionCodecs = ImmutableMap
            .copyOf(transformEntries(metadata.getExceptions(), (key, value) -> getCodec(codecManager, value)));

    return new MethodMetadata(metadata.getName(), parameters, resultCodec, exceptionCodecs,
            metadata.getOneway(), metadata.isIdempotent());
}

From source file:org.elasticsearch.monitor.dump.SimpleDumpGenerator.java

public SimpleDumpGenerator(File dumpLocation, Map<String, DumpContributor> contributors) {
    this.dumpLocation = dumpLocation;
    this.contributors = ImmutableMap.copyOf(contributors);
}

From source file:org.jclouds.concurrent.TransformParallelException.java

public TransformParallelException(Map<?, Future<?>> success, Map<?, Exception> exceptions,
        String messagePrefix) {/*from w  w w. j a  v a2s  . c  o  m*/
    super(String.format("error %s: %s", messagePrefix, exceptions));
    this.success = ImmutableMap.copyOf(success);
    this.exceptions = ImmutableMap.copyOf(exceptions);
    initCause(Iterables.get(exceptions.values(), 0));
}

From source file:com.nirmata.workflow.admin.TaskDetails.java

public TaskDetails(TaskId taskId, TaskType taskType, Map<String, String> metaData) {
    this.taskId = Preconditions.checkNotNull(taskId, "taskId cannot be null");
    this.taskType = Optional.ofNullable(taskType);
    metaData = Preconditions.checkNotNull(metaData, "metaData cannot be null");

    this.metaData = ImmutableMap.copyOf(metaData);
}

From source file:org.sosy_lab.cpachecker.cpa.smg.SMGStateInformation.java

private SMGStateInformation(Set<SMGEdgeHasValue> pHvEdges, Map<Integer, SMGEdgePointsTo> pPtEdges) {
    hvEdges = ImmutableSet.copyOf(pHvEdges);
    ptEdges = ImmutableMap.copyOf(pPtEdges);
}