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.facebook.buck.android.exopackage.NativeExoHelper.java

@VisibleForTesting
public static ImmutableMultimap<String, Path> filterLibrariesForAbi(Path nativeLibsDir,
        ImmutableMultimap<String, Path> allLibraries, String abi, ImmutableSet<String> ignoreLibraries) {
    ImmutableMultimap.Builder<String, Path> filteredLibraries = ImmutableMultimap.builder();
    for (Map.Entry<String, Path> entry : allLibraries.entries()) {
        Path relativePath = nativeLibsDir.relativize(entry.getValue());
        // relativePath is of the form libs/x86/foo.so, or assetLibs/x86/foo.so etc.
        Preconditions.checkState(relativePath.getNameCount() == 3);
        Preconditions.checkState(relativePath.getName(0).toString().equals("libs")
                || relativePath.getName(0).toString().equals("assetLibs"));
        String libAbi = relativePath.getParent().getFileName().toString();
        String libName = relativePath.getFileName().toString();
        if (libAbi.equals(abi) && !ignoreLibraries.contains(libName)) {
            filteredLibraries.put(entry);
        }// w  w  w .  j a  v a2  s  . co m
    }
    return filteredLibraries.build();
}

From source file:com.facebook.buck.android.ExopackageInstaller.java

@VisibleForTesting
static ImmutableMap<String, Path> filterLibrariesForAbi(Path nativeLibsDir,
        ImmutableMultimap<String, Path> allLibraries, String abi, ImmutableSet<String> ignoreLibraries) {
    ImmutableMap.Builder<String, Path> filteredLibraries = ImmutableMap.builder();
    for (Map.Entry<String, Path> entry : allLibraries.entries()) {
        Path relativePath = nativeLibsDir.relativize(entry.getValue());
        // relativePath is of the form libs/x86/foo.so, or assetLibs/x86/foo.so etc.
        Preconditions.checkState(relativePath.getNameCount() == 3);
        Preconditions.checkState(relativePath.getName(0).toString().equals("libs")
                || relativePath.getName(0).toString().equals("assetLibs"));
        String libAbi = relativePath.getParent().getFileName().toString();
        String libName = relativePath.getFileName().toString();
        if (libAbi.equals(abi) && !ignoreLibraries.contains(libName)) {
            filteredLibraries.put(entry);
        }/*from  ww w .  java2  s  . co m*/
    }
    return filteredLibraries.build();
}

From source file:grakn.core.graql.reasoner.unifier.UnifierImpl.java

public UnifierImpl(ImmutableMultimap<Variable, Variable> map) {
    this(map.entries());
}

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

private String getNativeLibraryMetadataContents(ImmutableMultimap<String, Path> libraries) {
    return Joiner.on('\n').join(FluentIterable.from(libraries.entries()).transform(input -> {
        String hash = input.getKey();
        String filename = input.getValue().getFileName().toString();
        int index = filename.indexOf('.');
        String libname = index == -1 ? filename : filename.substring(0, index);
        return String.format("%s native-%s.so", libname, hash);
    }));//from  ww w.j  a  v a  2s  .c  om
}

From source file:de.se_rwth.langeditor.texteditor.errorhighlighting.ErrorHighlighter.java

private void displaySyntaxErrors(IResource resource, ModelState modelState) {
    ImmutableMultimap<SourcePosition, String> syntaxErrors = modelState.getSyntaxErrors();
    for (Entry<SourcePosition, String> entry : syntaxErrors.entries()) {
        addMarker(resource, entry.getValue(), entry.getKey());
    }//from  w w w .  j a va2s .c  o m
}

From source file:com.google.devtools.build.lib.packages.AspectDescriptor.java

/**
 * Creates a presentable description of this aspect, avaliable
 * to Skylark via "Target.aspects"./*from   w  w w.j  ava  2  s .  c  o  m*/
 *
 * The description is designed to be unique for each aspect descriptor,
 * but not to be parseable.
 */
public String getDescription() {
    if (aspectParameters.isEmpty()) {
        return aspectClass.getName();
    }

    StringBuilder builder = new StringBuilder(aspectClass.getName());
    builder.append('[');
    ImmutableMultimap<String, String> attributes = aspectParameters.getAttributes();
    boolean first = true;
    for (Entry<String, String> attribute : attributes.entries()) {
        if (!first) {
            builder.append(',');
        } else {
            first = false;
        }
        builder.append(attribute.getKey());
        builder.append("=\"");
        builder.append(TextFormat.escapeDoubleQuotesAndBackslashes(attribute.getValue()));
        builder.append("\"");
    }
    builder.append(']');
    return builder.toString();
}

From source file:org.gradle.internal.execution.history.impl.FileCollectionFingerprintSerializer.java

private void writeRootHashes(Encoder encoder, ImmutableMultimap<String, HashCode> rootHashes)
        throws IOException {
    encoder.writeSmallInt(rootHashes.size());
    for (Map.Entry<String, HashCode> entry : rootHashes.entries()) {
        encoder.writeString(entry.getKey());
        hashCodeSerializer.write(encoder, entry.getValue());
    }//  w  ww.  j a v  a 2 s . com
}

From source file:org.knowm.dropwizard.sundial.tasks.StartJobTask.java

@Override
public void execute(ImmutableMultimap<String, String> parameters, PrintWriter output) throws Exception {

    logger.info(parameters.toString());//w w  w. jav a  2 s. co  m

    Map<String, Object> params = new HashMap<String, Object>();

    for (Entry<String, String> entry : parameters.entries()) {
        params.put(entry.getKey(), entry.getValue());
    }

    String jobName = (String) parameters.get("JOB_NAME").toArray()[0];

    SundialJobScheduler.startJob(jobName, params);
}

From source file:org.knowm.dropwizard.sundial.tasks.AddJobTask.java

@Override
public void execute(ImmutableMultimap<String, String> parameters, PrintWriter output) throws Exception {

    logger.info(parameters.toString());// ww w  .  ja v a 2 s.co m

    Map<String, Object> params = new HashMap<String, Object>();

    for (Entry<String, String> entry : parameters.entries()) {
        params.put(entry.getKey(), entry.getValue());
    }

    String jobName = (String) parameters.get("JOB_NAME").toArray()[0];
    String jobClass = (String) parameters.get("JOB_CLASS").toArray()[0];

    SundialJobScheduler.addJob(jobName, jobClass, params, false);

}

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

/**
 * @return a file_hash => local_file_path mapping
 * @throws IOException if an error occurred while parsing the metadata files which describe the
 *     files to be installed/*from   w ww . j  a v a2 s .c  o m*/
 */
private ImmutableMap<String, Path> getRequiredDexFiles() throws IOException {
    ImmutableMap.Builder<String, Path> builder = ImmutableMap.builder();
    for (DexInfo dexInfo : dexInfoForModules) {
        Path metadataFile = pathResolver.getAbsolutePath(dexInfo.getMetadata());
        if (!Files.exists(metadataFile)) {
            continue;
        }
        ImmutableMultimap<String, Path> multimap = ExopackageInstaller.parseExopackageInfoMetadata(metadataFile,
                pathResolver.getAbsolutePath(dexInfo.getDirectory()), projectFilesystem);
        for (Map.Entry<String, Path> entry : multimap.entries()) {
            builder.put(entry);
        }
    }
    return builder.build();
}