Example usage for com.google.common.collect ImmutableMap keySet

List of usage examples for com.google.common.collect ImmutableMap keySet

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMap keySet.

Prototype

public ImmutableSet<K> keySet() 

Source Link

Usage

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

public ImmutableMap<IjLibrary, DependencyType> getDependentLibrariesFor(IjModule source) {
    ImmutableMap<IjProjectElement, DependencyType> deps = getDepsFor(source);
    return deps.keySet().stream().filter(dep -> dep instanceof IjLibrary).map(library -> (IjLibrary) library)
            .collect(ImmutableMap.toImmutableMap(k -> k, input -> Objects.requireNonNull(deps.get(input))));
}

From source file:com.facebook.buck.ide.intellij.IjModuleGraph.java

public ImmutableMap<IjModule, DependencyType> getDependentModulesFor(IjModule source) {
    final ImmutableMap<IjProjectElement, DependencyType> deps = getDepsFor(source);
    return deps.keySet().stream().filter(dep -> dep instanceof IjModule).map(module -> (IjModule) module)
            .collect(MoreCollectors.toImmutableMap(k -> k,
                    input -> Preconditions.checkNotNull(deps.get(input))));
}

From source file:com.facebook.buck.ide.intellij.IjModuleGraph.java

public ImmutableMap<IjLibrary, DependencyType> getDependentLibrariesFor(IjModule source) {
    final ImmutableMap<IjProjectElement, DependencyType> deps = getDepsFor(source);
    return deps.keySet().stream().filter(dep -> dep instanceof IjLibrary).map(library -> (IjLibrary) library)
            .collect(MoreCollectors.toImmutableMap(k -> k,
                    input -> Preconditions.checkNotNull(deps.get(input))));
}

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

private String getResourceMetadataContents(ImmutableMap<String, Path> filesByHash) {
    return Joiner.on("\n")
            .join(RichStream.from(filesByHash.keySet()).map(h -> "resources " + h).toOnceIterable());
}

From source file:co.cask.hydrator.plugin.transform.CachingLookup.java

@Override
public Map<String, T> lookup(Set<String> keys) {
    ImmutableMap<String, T> cached = cache.getAllPresent(keys);

    Set<String> missingKeys = Sets.difference(keys, cached.keySet());
    Map<String, T> missing = delegate.lookup(missingKeys);
    cache.putAll(missing);//from  w  w w  . j  a v  a 2  s .c  om

    return ImmutableMap.<String, T>builder().putAll(cached).putAll(missing).build();
}

From source file:edu.mit.streamjit.impl.concurrent.ConcurrentDrainer.java

private ImmutableMap<Token, Blob> buildBlobMap(Set<Blob> blobSet) {
    ImmutableMap.Builder<Token, Blob> builder = new ImmutableMap.Builder<>();
    for (Blob b : blobSet) {
        Token t = Utils.getBlobID(b);//from  w  w  w  .ja  va  2 s.c o  m
        if (t == null)
            throw new AssertionError("Blob with no identifier");

        builder.put(t, b);
    }
    ImmutableMap<Token, Blob> blobMap = builder.build();

    if (!blobMap.keySet().equals(blobGraph.getBlobIds()))
        throw new AssertionError("Not all blob nodes have matching blobs");

    return blobMap;
}

From source file:com.vmware.photon.controller.common.dcp.QueryTaskUtils.java

/**
 * Builds a QueryTask.QuerySpecification which will query for documents of type T.
 * Any other filter clauses are optional.
 * This allows for a query that returns all documents of type T.
 * This also expands the content of the resulting documents.
 *
 * @param documentType//from  www. ja  v  a2  s  .co m
 * @param terms
 * @return
 */
public static QueryTask.QuerySpecification buildQuerySpec(Class documentType,
        ImmutableMap<String, String> terms) {
    checkNotNull(documentType, "Cannot build query spec for unspecified documentType");
    QueryTask.QuerySpecification spec = new QueryTask.QuerySpecification();
    QueryTask.Query documentKindClause = new QueryTask.Query()
            .setTermPropertyName(ServiceDocument.FIELD_NAME_KIND)
            .setTermMatchValue(Utils.buildKind(documentType));

    if (terms == null || terms.isEmpty()) {
        // since there are no other clauses
        // skip adding boolean clauses
        // to workaround the DCP requirement to have at least 2
        // boolean clauses for a valid query
        spec.query = documentKindClause;
    } else {
        spec.query.addBooleanClause(documentKindClause);
        for (String key : terms.keySet()) {
            QueryTask.Query clause = new QueryTask.Query().setTermPropertyName(key)
                    .setTermMatchValue(terms.get(key));
            spec.query.addBooleanClause(clause);
        }
    }

    return spec;
}

From source file:com.vmware.photon.controller.common.xenon.QueryTaskUtils.java

/**
 * Builds a QueryTask.QuerySpecification which will query for documents of type T.
 * Any other filter clauses are optional.
 * This allows for a query that returns all documents of type T.
 * This also expands the content of the resulting documents.
 *
 * @param documentType//  w  ww  .j  a  va  2s. co m
 * @param terms
 * @return
 */
public static QueryTask.QuerySpecification buildQuerySpec(Class documentType,
        ImmutableMap<String, String> terms) {
    checkNotNull(documentType, "Cannot build query spec for unspecified documentType");
    QueryTask.QuerySpecification spec = new QueryTask.QuerySpecification();
    QueryTask.Query documentKindClause = new QueryTask.Query()
            .setTermPropertyName(ServiceDocument.FIELD_NAME_KIND)
            .setTermMatchValue(Utils.buildKind(documentType));

    if (terms == null || terms.isEmpty()) {
        // since there are no other clauses
        // skip adding boolean clauses
        // to workaround the Xenon requirement to have at least 2
        // boolean clauses for a valid query
        spec.query = documentKindClause;
    } else {
        spec.query.addBooleanClause(documentKindClause);
        for (String key : terms.keySet()) {
            QueryTask.Query clause = new QueryTask.Query().setTermPropertyName(key)
                    .setTermMatchValue(terms.get(key));
            spec.query.addBooleanClause(clause);
        }
    }

    return spec;
}

From source file:com.facebook.buck.cxx.CxxDescriptionEnhancer.java

/**
 * Create all build rules needed to generate the compilation database.
 *
 * @return the {@link CxxCompilationDatabase} rule representing the actual compilation database.
 *//*from   ww w.j  a v a 2 s.c om*/
public static CxxCompilationDatabase createCompilationDatabase(BuildRuleParams params,
        BuildRuleResolver ruleResolver, SourcePathResolver pathResolver, SourcePathRuleFinder ruleFinder,
        CxxBuckConfig cxxBuckConfig, CxxPlatform cxxPlatform, CxxConstructorArg arg)
        throws NoSuchBuildTargetException {
    BuildRuleParams paramsWithoutFlavor = params.withoutFlavor(CxxCompilationDatabase.COMPILATION_DATABASE);
    ImmutableMap<CxxPreprocessAndCompile, SourcePath> objects = requireObjects(paramsWithoutFlavor,
            ruleResolver, pathResolver, ruleFinder, cxxBuckConfig, cxxPlatform,
            CxxSourceRuleFactory.PicType.PIC, arg);
    return CxxCompilationDatabase.createCompilationDatabase(params, pathResolver, objects.keySet());
}

From source file:com.google.errorprone.scanner.ScannerSupplierImpl.java

ScannerSupplierImpl(ImmutableBiMap<String, BugCheckerInfo> checks,
        ImmutableMap<String, BugPattern.SeverityLevel> severities, ImmutableSet<String> disabled) {
    checkArgument(Sets.difference(severities.keySet(), checks.keySet()).isEmpty(),
            "enabledChecks must be a subset of allChecks");
    checkArgument(Sets.difference(disabled, checks.keySet()).isEmpty(),
            "disabled must be a subset of allChecks");
    this.checks = checks;
    this.severities = severities;
    this.disabled = disabled;
}