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:com.google.caliper.worker.handler.HostDevice.java

private static void getLinuxEnvironment(Map<String, String> propertyMap) {
    // the following probably doesn't work on ALL linux
    Multimap<String, String> cpuInfo = propertiesFromLinuxFile("/proc/cpuinfo");
    propertyMap.put("host.cpus", Integer.toString(cpuInfo.get("processor").size()));
    String s = "cpu cores";
    propertyMap.put("host.cpu.cores", describe(cpuInfo, s));
    propertyMap.put("host.cpu.names", describe(cpuInfo, "model name"));
    propertyMap.put("host.cpu.cachesize", describe(cpuInfo, "cache size"));

    Multimap<String, String> memInfo = propertiesFromLinuxFile("/proc/meminfo");
    // TODO redo memInfo.toString() so we don't get square brackets
    propertyMap.put("host.memory.physical", memInfo.get("MemTotal").toString());
    propertyMap.put("host.memory.swap", memInfo.get("SwapTotal").toString());
}

From source file:org.apache.shindig.gadgets.FetchResponseUtils.java

private static void addAllHeaders(Map<String, Collection<String>> headers, HttpResponse response) {
    Multimap<String, String> responseHeaders = response.getHeaders();
    for (String name : responseHeaders.keySet()) {
        headers.put(name.toLowerCase(), responseHeaders.get(name));
    }/*from ww w  .jav a 2 s.com*/
}

From source file:org.icgc.dcc.portal.manifest.writer.GenericManifestWriter.java

@SneakyThrows
public static void write(OutputStream buffer, Multimap<String, ManifestFile> bundles) {
    val tsv = createTsv(buffer);
    tsv.writeHeader(TSV_HEADERS);/*from w w  w .ja  va 2 s.  c o m*/

    for (val url : bundles.keySet()) {
        val bundle = bundles.get(url);
        val row = createRow(url, bundle);

        tsv.write(row);
    }

    tsv.flush();
}

From source file:eu.numberfour.n4js.ui.organize.imports.N4JSOrganizeImportsHelper.java

/**
 * Turn this Multimap into a two-dimensional array the first index giving the page, second the choices of this page.
 *
 * @param multimap/*from  w w w  .  ja v  a  2  s. c  om*/
 *            name to many options
 * @return two-dim Array of T
 */
public static <T> Object[][] createOptions(Multimap<String, T> multimap) {
    Object[][] ret = new Object[multimap.keySet().size()][];

    int page = 0;
    for (String key : multimap.keySet()) {
        Collection<T> values = multimap.get(key);
        ret[page] = new Object[values.size()];
        int option = 0;
        for (T ns : values) {
            ret[page][option] = ns;
            option++;
        }
        page++;
    }

    return ret;
}

From source file:com.torodb.torod.db.backends.query.processors.InProcessor.java

@Nullable
private static ProcessedQueryCriteria getProcessedQuery(InQueryCriteria criteria,
        Multimap<ScalarType, ScalarValue<?>> byTypeValues, ScalarType type) {
    Collection<ScalarValue<?>> values = byTypeValues.get(type);
    if (values.isEmpty()) {
        return null;
    }// www  . j  av  a2s. c om
    ImmutableList.Builder<ScalarValue<?>> newInBuilder = new ImmutableList.Builder();
    for (ScalarValue<?> value : values) {
        newInBuilder.add(value);
    }

    return new ProcessedQueryCriteria(new TypeIsQueryCriteria(criteria.getAttributeReference(), type),
            new InQueryCriteria(criteria.getAttributeReference(), newInBuilder.build()));
}

From source file:org.icgc.dcc.portal.manifest.writer.GDCManifestWriter.java

@SneakyThrows
public static void write(OutputStream buffer, Multimap<String, ManifestFile> bundles) {
    val tsv = createTsv(buffer);
    tsv.writeHeader(TSV_HEADERS);/*from   w w w  .jav a 2  s.c  o  m*/

    for (val url : bundles.keySet()) {
        val bundle = bundles.get(url);
        checkState(bundle.size() == 1, "%s expected to have only one file", bundle);

        val file = getFirst(bundle, null);
        val row = createRow(file);

        tsv.write(row);
    }

    tsv.flush();
}

From source file:org.icgc.dcc.portal.manifest.writer.ICGCManifestWriter.java

@SneakyThrows
public static void write(OutputStream buffer, Multimap<String, ManifestFile> bundles) {
    val tsv = createTsv(buffer);
    tsv.writeHeader(TSV_HEADERS);/* w w  w. j av a 2 s .  c o m*/

    for (val url : bundles.keySet()) {
        val bundle = bundles.get(url);
        val row = createRow(bundle);

        tsv.write(row);
    }

    tsv.flush();
}

From source file:com.google.gerrit.server.mail.MailUtil.java

public static MailRecipients getRecipientsFromReviewers(Multimap<ReviewerStateInternal, Account.Id> reviewers) {
    MailRecipients recipients = new MailRecipients();
    recipients.reviewers.addAll(reviewers.get(REVIEWER));
    recipients.cc.addAll(reviewers.get(CC));
    return recipients;
}

From source file:org.onehippo.cms7.essentials.dashboard.utils.BeanWriterUtils.java

public static void populateBeanwriterMessages(final PluginContext context,
        final RestfulList<MessageRestful> messages) {
    final Multimap<String, Object> pluginContextData = context.getPluginContextData();
    final Collection<Object> objects = pluginContextData.get(CONTEXT_DATA_KEY);
    for (Object object : objects) {
        final BeanWriterLogEntry entry = (BeanWriterLogEntry) object;
        final ActionType actionType = entry.getActionType();
        if (actionType == ActionType.CREATED_METHOD || actionType == ActionType.MODIFIED_METHOD) {
            messages.add(new MessageRestful(
                    String.format("%s in HST bean: %s", entry.getMessage(), entry.getBeanName())));
        } else if (actionType == ActionType.CREATED_CLASS) {
            messages.add(new MessageRestful(String.format("%s (%s)", entry.getMessage(), entry.getBeanPath())));
        } else {/*from   w  w  w. j a va2  s.  c  o m*/
            messages.add(new MessageRestful(entry.getMessage()));
        }
    }
}

From source file:be.solidx.hot.utils.CollectionUtils.java

public static Map<String, Object> flat(Multimap<String, Object> multimap) {
    Map<String, Object> flattenMap = new LinkedHashMap<String, Object>();
    for (String key : multimap.keySet()) {
        int i = 0;
        for (Object object : multimap.get(key)) {
            flattenMap.put(key.replaceAll("\\.", "_") + "_" + i++, object);
        }/* w w  w.  j  a  v  a2 s. co  m*/
    }
    return flattenMap;
}