Example usage for com.google.common.collect Maps newHashMap

List of usage examples for com.google.common.collect Maps newHashMap

Introduction

In this page you can find the example usage for com.google.common.collect Maps newHashMap.

Prototype

public static <K, V> HashMap<K, V> newHashMap() 

Source Link

Document

Creates a mutable, empty HashMap instance.

Usage

From source file:org.sonatype.nexus.yum.internal.capabilities.AliasMappings.java

private static Map<String, String> parseAliases(final String mappings) {
    final Map<String, String> parsedAliases = Maps.newHashMap();

    if (mappings != null && !mappings.trim().isEmpty()) {
        final String[] segments = mappings.split(",");
        for (final String segment : segments) {
            if (!segment.trim().isEmpty()) {
                final String[] parts = segment.split("=");
                if (parts.length != 2) {
                    throw new IllegalArgumentException(
                            "Invalid format for entry '" + segment + "'. Expected <alias>=<version>");
                }/*w ww. j a  va2  s  .  c  om*/
                parsedAliases.put(parts[0], parts[1]);
            }
        }
    }

    return parsedAliases;
}

From source file:com.enonic.cms.core.plugin.manager.ExtensionHolder.java

public ExtensionHolder() {
    this.map = Maps.newHashMap();
    this.listeners = Lists.newArrayList();
}

From source file:net.diogobohm.timed.api.db.serializer.DBProjectSerializer.java

@Override
public Map<String, Object> serialize(DBProject object) {
    Map<String, Object> valueMap = Maps.newHashMap();

    valueMap.put("name", object.getName());

    return valueMap;
}

From source file:org.des.tao.ide.builder.EventBuilder.java

public EventBuilder() {
    this.eventMap = Maps.newHashMap();
    this.edgeList = Lists.newLinkedList();
    this.eventMap.put("edges", this.edgeList);
}

From source file:eu.thebluemountain.customers.dctm.brownbag.badcontentslister.Command.java

/**
 * The method that parses the elements in the arguments to build a map
 * containing the commands and the related value if any
 * @param args carries the command-line arguments
 * @return the commands/*ww w.j  a v  a2  s  . c o  m*/
 */
public static Map<Command, Optional<String>> parse(String[] args) {
    final int size = args.length;
    Map<Command, Optional<String>> cmds = Maps.newHashMap();
    for (int index = 0; index < size; index++) {
        Command cmd = of(args[index]);
        Preconditions.checkArgument(!cmds.containsKey(cmd), "duplicate arguments introducing command %s", cmd);
        if (cmd.requiresvalue) {
            index++;
            Preconditions.checkArgument(index < size, "command '%s' requires missing value", cmd);
            String value = args[index];
            cmds.put(cmd, Optional.of(value));
        } else {
            cmds.put(cmd, Optional.<String>absent());
        }
    }
    return cmds;
}

From source file:ai.grakn.graql.internal.gremlin.spanningtree.graph.SparseWeightedGraph.java

public static <T> SparseWeightedGraph<T> from(Iterable<T> nodes, Iterable<Weighted<DirectedEdge<T>>> edges) {
    final Map<T, Map<T, Weighted<DirectedEdge<T>>>> incomingEdges = Maps.newHashMap();
    for (Weighted<DirectedEdge<T>> edge : edges) {
        if (!incomingEdges.containsKey(edge.val.destination)) {
            incomingEdges.put(edge.val.destination, Maps.newHashMap());
        }/*from   w  w w .  j  a v  a2  s .  c om*/
        incomingEdges.get(edge.val.destination).put(edge.val.source, edge);
    }
    return new SparseWeightedGraph<>(ImmutableSet.copyOf(nodes), incomingEdges);
}

From source file:org.spdx.rdfparser.model.SpdxElementFactory.java

/**
 * Add to a cache of created elements/*from   www  .ja  va2s .c  o  m*/
 * @param modelContainer
 * @param node
 * @param element
 */
static synchronized void addToCreatedElements(IModelContainer modelContainer, Node node, SpdxElement element) {
    Map<Node, SpdxElement> containerNodes = createdElements.get(modelContainer);
    if (containerNodes == null) {
        containerNodes = Maps.newHashMap();
        createdElements.put(modelContainer, containerNodes);
    }
    containerNodes.put(node, element);
}

From source file:org.jetbrains.jet.lang.types.SubstitutionUtils.java

/**
 * Builds a context with all the supertypes' parameters substituted
 */// ww  w .j  a va 2 s .  c o m
@NotNull
public static TypeSubstitutor buildDeepSubstitutor(@NotNull JetType type) {
    Map<TypeConstructor, TypeProjection> substitution = Maps.newHashMap();
    TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(substitution);
    // we use the mutability of the map here
    fillInDeepSubstitutor(type, typeSubstitutor, substitution, null);
    return typeSubstitutor;
}

From source file:org.eclipse.recommenders.models.dependencies.impl.JREExecutionEnvironmentStrategy.java

private static Map<String, ProjectCoordinate> createLookUpTable() {
    Map<String, ProjectCoordinate> result = Maps.newHashMap();

    result.put("JRE-1.1", new ProjectCoordinate("jre", "jre", "1.1.0"));
    result.put("J2SE-1.2", new ProjectCoordinate("jre", "jre", "1.2.0"));
    result.put("J2SE-1.3", new ProjectCoordinate("jre", "jre", "1.3.0"));
    result.put("J2SE-1.4", new ProjectCoordinate("jre", "jre", "1.4.0"));
    result.put("J2SE-1.5", new ProjectCoordinate("jre", "jre", "1.5.0"));
    result.put("JavaSE-1.6", new ProjectCoordinate("jre", "jre", "1.6.0"));
    result.put("JavaSE-1.7", new ProjectCoordinate("jre", "jre", "1.7.0"));

    return result;
}

From source file:com.bivgroup.websocket.websocket.jetty.WebsocketEndpoint.java

/**
 * Parser param context to map/*from   ww w  .  j  a  v  a 2  s .  c  o m*/
 */
public static Map<String, String> getQueryMap(String query) {
    Map<String, String> map = Maps.newHashMap();
    if (query != null) {
        String[] params = query.split("&");
        for (String param : params) {
            String[] nameval = param.split("=");
            map.put(nameval[0], nameval[1]);
        }
    }
    return map;
}