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.sonar.plugins.core.timemachine.ViolationPersisterDecorator.java

/**
 * Search for past violation.//from  ww w.  j a v a2s .c  o m
 */
RuleFailureModel selectPastViolation(Violation violation,
        Multimap<Rule, RuleFailureModel> pastViolationsByRule) {
    Collection<RuleFailureModel> pastViolations = pastViolationsByRule.get(violation.getRule());
    if (pastViolations == null || pastViolations.isEmpty()) {
        // skip violation, if there is no past violations with same rule
        return null;
    }
    String dbFormattedMessage = RuleFailureModel.abbreviateMessage(violation.getMessage());
    RuleFailureModel found = selectPastViolationUsingLine(violation, dbFormattedMessage, pastViolations);
    if (found == null) {
        found = selectPastViolationUsingChecksum(violation, dbFormattedMessage, pastViolations);
    }
    return found;
}

From source file:org.eclipse.xtend.core.jvmmodel.SyntheticNameClashResolver.java

protected boolean collides(JvmIdentifiableElement element, String currentName,
        Multimap<String, JvmIdentifiableElement> scope) {
    if (scope.containsKey(currentName)) {
        if (element instanceof JvmOperation) {
            for (JvmIdentifiableElement other : scope.get(currentName)) {
                if (!(other instanceof JvmOperation) || ((JvmOperation) element).getParameters()
                        .size() == ((JvmOperation) other).getParameters().size())
                    return true;
            }/* w  w w. j a  va 2  s  . c  o  m*/
            return false;
        }
        return true;
    }
    return false;
}

From source file:gr.forth.ics.swkm.model2.index.NamespaceIndexer.java

Iterator<Resource> findInNamespace(RdfType type, Uri namespace) {
    //assuming type is only schema, and namespace does not have a local part
    //the relevant checks have moved to ModelImpl#findSchemaNodes
    Multimap<RdfType, Resource> map = index.get(namespace);
    if (map == null) {
        return Iterators.emptyIterator();
    }//  www  .  j  a v a 2  s  .  c om
    return Iterators.unmodifiableIterator(map.get(type).iterator());
}

From source file:org.wso2.appcloud.core.DomainMappingManager.java

/**
 * Check whether there is a CNAME entry from {@code customUrl} to {@code pointedUrl}.
 *
 * @param pointedUrl url that is pointed by the CNAME entry of {@code customUrl}
 * @param customUrl  custom url./*from  w  w  w .  ja  va2 s. c  om*/
 * @return success whether there is a CNAME entry from {@code customUrl} to {@code pointedUrl}
 * @throws AppCloudException
 */
public boolean verifyCustomUrlByCname(String pointedUrl, String customUrl) throws AppCloudException {
    Hashtable<String, String> env = new Hashtable<String, String>();
    boolean success;
    // set environment configurations
    env.put(JNDI_KEY_NAMING_FACTORY_INITIAL, "com.sun.jndi.dns.DnsContextFactory");
    env.put(JNDI_KEY_DNS_TIMEOUT, "5000");
    env.put(JDNI_KEY_DNS_RETRIES, "1");
    try {
        Multimap<String, String> resolvedHosts = resolveDNS(customUrl, env);
        Collection<String> resolvedCnames = resolvedHosts.get(DNS_CNAME_RECORD);
        if (!resolvedCnames.isEmpty() && resolvedCnames.contains(pointedUrl)) {
            if (log.isDebugEnabled()) {
                log.debug(pointedUrl + " can be reached from: " + customUrl + " via CNAME records");
            }
            success = true;
        } else {
            if (log.isDebugEnabled()) {
                log.debug(pointedUrl + " cannot be reached from: " + customUrl + " via CNAME records");
            }
            success = false;
        }
    } catch (AppCloudException e) {
        log.error("Error occurred while resolving dns for: " + customUrl, e);
        throw new AppCloudException("Error occurred while resolving dns for: " + customUrl, e);
    } catch (NamingException e) {
        // we are logging this as warn messages since this is caused, due to an user error. For example if the
        // user entered a rubbish custom url(Or a url which is, CNAME record is not propagated at the
        // time of adding the url), then url validation will fail but it is not an system error
        log.warn(pointedUrl + " cannot be reached from: " + customUrl + " via CNAME records. Provided custom"
                + " url: " + customUrl + " might not a valid url.", e);
        success = false;
    }
    return success;
}

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

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

From source file:foo.domaintest.http.HttpApiModule.java

@Provides
@Param("payload")
String providePayload(Multimap<String, String> params, @EasterEggs String easterEggUrl) {
    return easterEggUrl == null ? getFirst(params.get("payload"), null) : easterEggUrl;
}

From source file:eu.tomylobo.routes.infrastructure.Node.java

public void load(Multimap<String, Multimap<String, String>> sections, String nodeName) {
    final String nodeSectionName = "node " + nodeName;
    final Multimap<String, String> nodeSection = Ini.getOnlyValue(sections.get(nodeSectionName));

    position = Ini.loadVector(nodeSection, "position.%s");
    tension = Ini.getOnlyDouble(nodeSection.get("tension"));
    bias = Ini.getOnlyDouble(nodeSection.get("bias"));
    continuity = Ini.getOnlyDouble(nodeSection.get("continuity"));
}

From source file:com.ibm.common.activitystreams.internal.MultimapAdapter.java

/**
 * Method serialize.//from   w w  w  . j  a va  2s.c o m
 * @param src Multimap
 * @param typeOfSrc Type
 * @param context JsonSerializationContext
        
 * @return JsonElement */
public JsonElement serialize(Multimap src, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject obj = new JsonObject();
    for (Object key : src.keySet()) {
        Iterable<Object> vals = src.get(key);
        if (size(vals) == 1) {
            Object f = getFirst(vals, null);
            if (f != null)
                obj.add(key.toString(), context.serialize(f, f.getClass()));
        } else {
            obj.add(key.toString(), context.serialize(vals, Iterable.class));
        }
    }
    return obj;
}

From source file:org.computer.whunter.rpm.parser.RpmSpecParser.java

String getProperty(Multimap<String, String> properties, String key) {
    Collection<String> collection = properties.get(key);
    if (collection.isEmpty())
        return null;
    if (collection.size() != 1)
        throw new RuntimeException("multiple values for key " + key);
    return collection.iterator().next();
}

From source file:org.eclipselabs.spray.dev.pde.internal.UpdateTargetPlatform.java

/**
 * Selects the most recent version/*from   w ww  .j av  a  2 s . c  om*/
 * @param iuId Installable Unit Id
 * @param versionMap Map with the available versions for a IU
 * @return The IU
 */
protected String pickVersion(String iuId, Multimap<String, Version> versionMap) {
    Version selectedVersion = null;
    for (Version v : versionMap.get(iuId)) {
        if (selectedVersion == null || v.compareTo(selectedVersion) > 0) {
            selectedVersion = v;
        }
    }
    if (selectedVersion == null) {
        LOG.warn("No version for Installable Unit " + iuId + " picked.");
        return null;
    } else {
        return selectedVersion.toString();
    }
}