Example usage for com.google.common.collect Multimap get

List of usage examples for com.google.common.collect Multimap get

Introduction

In this page you can find the example usage for com.google.common.collect Multimap get.

Prototype

Collection<V> get(@Nullable K key);

Source Link

Document

Returns a view collection of the values associated with key in this multimap, if any.

Usage

From source file:org.corpus_tools.annis.ql.parser.SemanticValidator.java

private void createTransitiveHull(QueryNode n, final Multimap<Long, QueryNode> connected,
        Set<Long> transitiveHull) {
    Collection<QueryNode> outgoing = connected.get(n.getId());
    if (outgoing != null) {
        for (QueryNode otherNode : outgoing) {
            if (transitiveHull.add(otherNode.getId())) {
                createTransitiveHull(otherNode, connected, transitiveHull);
            }//ww w.  ja v a  2  s . co m
        }
    }
}

From source file:com.axelor.meta.loader.AbstractLoader.java

/**
 * Resolve the given unresolved key.<br>
 * <br>/*w ww .  ja v a2  s  .c o  m*/
 * All the pending values of the unresolved key are returned for further
 * processing. The values are removed from the backing {@link Multimap}.
 * 
 * @param type
 *            the type of pending objects
 * @param unresolvedKey
 *            the unresolved key
 * @return a set of all the pending objects
 */
@SuppressWarnings("unchecked")
protected <T> Set<T> resolve(Class<T> type, String unresolvedKey) {
    Set<T> values = Sets.newHashSet();
    Map<Class<?>, Multimap<String, Object>> map = unresolved.get();
    if (map == null) {
        return values;
    }
    Multimap<String, Object> mm = map.get(type);
    if (mm == null) {
        return values;
    }
    for (Object item : mm.get(unresolvedKey)) {
        values.add((T) item);
    }
    mm.removeAll(unresolvedKey);
    return values;
}

From source file:org.gradle.execution.TaskNameResolvingBuildConfigurationAction.java

public void configure(BuildExecutionContext context) {
    GradleInternal gradle = context.getGradle();
    List<String> taskNames = gradle.getStartParameter().getTaskNames();
    Multimap<String, Task> selectedTasks = doSelect(gradle, taskNames, taskNameResolver);

    TaskGraphExecuter executer = gradle.getTaskGraph();
    for (String name : selectedTasks.keySet()) {
        executer.addTasks(selectedTasks.get(name));
    }//from www  . ja v a 2  s.  co  m

    if (selectedTasks.keySet().size() == 1) {
        LOGGER.info("Selected primary task {}", GUtil.toString(selectedTasks.keySet()));
    } else {
        LOGGER.info("Selected primary tasks {}", GUtil.toString(selectedTasks.keySet()));
    }

    context.proceed();
}

From source file:uk.ac.ebi.atlas.web.controllers.rest.GeneNameTooltipController.java

@RequestMapping(value = "/rest/genename-tooltip", method = RequestMethod.GET, produces = "text/html")
@ResponseStatus(HttpStatus.OK)/*from  w  w  w. java  2 s .  c  o m*/
@ResponseBody
public String getTooltipContent(@RequestParam(value = "geneName") String geneName,
        @RequestParam(value = "identifier") String identifier) {

    Multimap<String, String> multimap = bioEntityPropertyDao.fetchTooltipProperties(identifier);

    String synonyms = buildSynonyms(multimap);

    String goTerms = format(multimap.get("goterm"), true, NUMBER_OF_TERMS_TO_SHOW);

    String interproTerms = format(multimap.get("interproterm"), true, NUMBER_OF_TERMS_TO_SHOW);

    return MessageFormat.format(htmlTemplate, geneName, synonyms, identifier, goTerms, interproTerms);

}

From source file:crawler.HTTPRequest.java

public String serializeRequest(HTTPClient.HTTPMethod method) {
    // give StringBuilder some initial capacity will save time if the 
    // request is big
    StringBuilder builder = new StringBuilder(112);

    // BUILDING FIRST LINE 
    builder.append(method.value());/*from  www .j  a v  a2  s . co  m*/
    builder.append(" ");
    String path = this.getURL().getPath();
    builder.append(path == "" ? "/" : path);
    builder.append(" ");
    builder.append("HTTP/1.0\r\n");

    // BUILDING HEADERS 
    Multimap<String, String> headers = this.getHeaders();

    for (String key : headers.keySet()) {

        Collection<String> values = headers.get(key);

        for (String value : values) {
            builder.append(key);
            builder.append(":");
            builder.append(value);
            builder.append("\r\n");
        }
    }

    builder.append("\r\n");

    if (method == HTTPClient.HTTPMethod.POST) {
        builder.append(this.getRequestBody());
    }

    return builder.toString();
}

From source file:eu.interedition.collatex.dekker.matrix.IslandConflictResolver.java

private void addBestOfCompeting(MatchTableSelection selection, Multimap<Double, Island> distanceMap1) {
    for (Double d : shortestToLongestDistances(distanceMap1)) {
        for (Island ci : distanceMap1.get(d)) {
            if (selection.isIslandPossibleCandidate(ci)) {
                selection.addIsland(ci);
            }/*from www.  j  a  v a 2  s . co  m*/
        }
    }
}

From source file:org.eclipse.packagedrone.repo.importer.aether.web.AetherResolver.java

private static void markExisting(final AetherResult result, final ReadableChannel channel) {
    // build version map

    final Multimap<String, String> existing = HashMultimap.create();

    for (final ArtifactInformation ai : channel.getArtifacts()) {
        final String groupId = ai.getMetaData().get(KEY_GROUP_ID);
        final String artifactId = ai.getMetaData().get(KEY_ARTIFACT_ID);
        final String classifier = ai.getMetaData().get(KEY_CLASSIFIER);
        final String extension = ai.getMetaData().get(KEY_EXTENSION);

        final String version = ai.getMetaData().get(KEY_VERSION);

        if (groupId != null && artifactId != null && version != null) {
            final String key = makeExistingKey(groupId, artifactId, classifier, extension);
            existing.put(key, version);/*w  w  w  .ja  v  a  2 s . c  o m*/
        }
    }

    // match

    for (final AetherResult.Entry entry : result.getArtifacts()) {
        final String key = makeExistingKey(entry.getCoordinates().getGroupId(),
                entry.getCoordinates().getArtifactId(), entry.getCoordinates().getClassifier(),
                entry.getCoordinates().getExtension());
        entry.getExistingVersions().addAll(existing.get(key));
    }
}

From source file:org.sonar.server.qualityprofile.ws.InheritanceAction.java

private Long getActiveRuleCount(Multimap<String, FacetValue> profileStats) {
    Long result = null;/*from w w w  .j a v a 2s.c  o  m*/
    if (profileStats.containsKey(COUNT_ACTIVE_RULES)) {
        result = profileStats.get(COUNT_ACTIVE_RULES).iterator().next().getValue();
    }
    return result;
}

From source file:org.gradle.model.internal.registry.RuleBindings.java

private void removeReferences(ModelNodeInternal node, RuleBinder ruleBinder,
        Multimap<ModelPath, Reference> references) {
    Iterator<Reference> iterator = references.get(node.getPath()).iterator();
    while (iterator.hasNext()) {
        Reference reference = iterator.next();
        if (reference.owner.equals(ruleBinder)) {
            iterator.remove();//from   w w w .  ja  va 2s.c  om
        }
    }
}

From source file:org.gradle.plugins.ide.idea.model.internal.IdeaDependenciesOptimizer.java

private void applyScopeToNextDependency(Iterator<Dependency> iterator,
        Multimap<Object, GeneratedIdeaScope> scopesByDependencyKey) {
    Dependency dep = iterator.next();/*  www  . jav  a  2 s  . co  m*/
    Object key = getKey(dep);
    Collection<GeneratedIdeaScope> ideaScopes = scopesByDependencyKey.get(key);
    if (ideaScopes.isEmpty()) {
        iterator.remove();
    } else {
        GeneratedIdeaScope scope = ideaScopes.iterator().next();
        dep.setScope(scope.name());
        scopesByDependencyKey.remove(key, scope);
    }
}