Example usage for com.google.common.collect ImmutableMultimap entries

List of usage examples for com.google.common.collect ImmutableMultimap entries

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMultimap entries.

Prototype

@Override
public ImmutableCollection<Entry<K, V>> entries() 

Source Link

Document

Returns an immutable collection of all key-value pairs in the multimap.

Usage

From source file:com.google.api.tools.framework.model.ExtensionPool.java

/**
 * Returns an {@link Iterable} of extension names to {@link Extension}. Extension names
 * are a fully qualified name surrounded by parentheses. The path of the name is determined by
 * where the extension is defined. For example, given the extension defined below, the field name
 * is "(foo.bar.baz)". The returned {@link Iterable} is sorted by field number.
 *
 * <pre>/*www .  j a v  a 2 s .  co  m*/
 * syntax = "proto2";
 *
 * package = foo.bar;
 *
 * import "extendee.proto";
 *
 * extend extendee.ExtendeeMessage {
 *   optional baz = 1;
 * }
 * </pre>
 */
public Iterable<Entry<String, Extension>> getSortedExtensionsByTypeName(String name) {
    ImmutableMultimap<String, Extension> messageExtensions = extensions.get(name);
    if (messageExtensions == null) {
        return Lists.newArrayList();
    }
    return FIELD_NUMBER_ORDERING.immutableSortedCopy(messageExtensions.entries());
}

From source file:com.facebook.buck.android.exopackage.DexExoHelper.java

private ImmutableMap<String, Path> getRequiredDexFiles() throws IOException {
    ImmutableMultimap<String, Path> multimap = ExopackageInstaller.parseExopackageInfoMetadata(
            pathResolver.getAbsolutePath(dexInfo.getMetadata()),
            pathResolver.getAbsolutePath(dexInfo.getDirectory()), projectFilesystem);
    // Convert multimap to a map, because every key should have only one value.
    ImmutableMap.Builder<String, Path> builder = ImmutableMap.builder();
    for (Map.Entry<String, Path> entry : multimap.entries()) {
        builder.put(entry);/*from   w ww.  ja va 2 s .  c om*/
    }
    return builder.build();
}

From source file:com.facebook.buck.features.project.intellij.BaseIjModuleRule.java

private void addDepsAndFolder(IJFolderFactory folderFactory, DependencyType dependencyType,
        TargetNode<T> targetNode, boolean wantsPackagePrefix, ModuleBuildContext context,
        ImmutableSet<Path> resourcePaths) {
    ImmutableMultimap<Path, Path> foldersToInputsIndex = getSourceFoldersToInputsIndex(targetNode.getInputs()
            .stream().map(path -> projectFilesystem.relativize(targetNode.getFilesystem().resolve(path)))
            .collect(ImmutableList.toImmutableList()));

    if (!resourcePaths.isEmpty()) {
        foldersToInputsIndex = foldersToInputsIndex.entries().stream()
                .filter(entry -> !resourcePaths.contains(entry.getValue()))
                .collect(ImmutableListMultimap.toImmutableListMultimap(Map.Entry::getKey, Map.Entry::getValue));
    }/* ww  w . j av a  2 s . c o  m*/

    addSourceFolders(folderFactory, foldersToInputsIndex, wantsPackagePrefix, context);
    addDeps(foldersToInputsIndex, targetNode, dependencyType, context);

    addGeneratedOutputIfNeeded(folderFactory, targetNode, context);

    if (targetNode.getConstructorArg() instanceof JvmLibraryArg) {
        addAnnotationOutputIfNeeded(folderFactory, targetNode, context);
    }
}