List of usage examples for com.google.common.collect ImmutableMap containsKey
@Override public boolean containsKey(@Nullable Object key)
From source file:com.facebook.buck.cxx.toolchain.nativelink.NativeLinkables.java
/** * Collect all the shared libraries generated by {@link NativeLinkable}s found by transitively * traversing all unbroken dependency chains of {@link NativeLinkable} objects found via the * passed in {@link BuildRule} roots.// w ww .j ava2 s .c o m * * @param alwaysIncludeRoots whether to include shared libraries from roots, even if they prefer * static linkage. * @return a mapping of library name to the library {@link SourcePath}. */ public static <T> ImmutableSortedMap<String, SourcePath> getTransitiveSharedLibraries(CxxPlatform cxxPlatform, ActionGraphBuilder graphBuilder, Iterable<? extends T> inputs, Function<? super T, Optional<Iterable<? extends T>>> passthrough, boolean alwaysIncludeRoots) { ImmutableMap<BuildTarget, NativeLinkable> roots = getNativeLinkableRoots(inputs, passthrough); ImmutableMap<BuildTarget, NativeLinkable> nativeLinkables = getTransitiveNativeLinkables(cxxPlatform, graphBuilder, roots.values()); SharedLibrariesBuilder builder = new SharedLibrariesBuilder(); nativeLinkables.entrySet().stream().filter( e -> e.getValue().getPreferredLinkage(cxxPlatform, graphBuilder) != NativeLinkable.Linkage.STATIC || (alwaysIncludeRoots && roots.containsKey(e.getKey()))) .forEach(e -> builder.add(cxxPlatform, e.getValue(), graphBuilder)); return builder.build(); }
From source file:com.siemens.sw360.importer.ComponentImportUtils.java
@Nullable private static List<AttachmentContent> getAttachmentContents( HashMap<String, List<String>> releaseIdentifierToDownloadURL, ImmutableMap<String, AttachmentContent> URLtoAttachment, String releaseIdentifier) { List<AttachmentContent> attachmentContents = null; if (releaseIdentifierToDownloadURL.containsKey(releaseIdentifier)) { final List<String> URLs = releaseIdentifierToDownloadURL.get(releaseIdentifier); attachmentContents = new ArrayList<>(URLs.size()); for (String url : URLs) { if (URLtoAttachment.containsKey(url)) { final AttachmentContent attachmentContent = URLtoAttachment.get(url); attachmentContents.add(attachmentContent); }//from w ww. ja va 2s . co m } } return attachmentContents; }
From source file:com.facebook.buck.apple.AppleBundle.java
static ImmutableMap<String, String> withDefaults(ImmutableMap<String, String> map, ImmutableMap<String, String> defaults) { ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String>builder().putAll(map); for (ImmutableMap.Entry<String, String> entry : defaults.entrySet()) { if (!map.containsKey(entry.getKey())) { builder = builder.put(entry.getKey(), entry.getValue()); }//from w w w.j a v a2 s. co m } return builder.build(); }
From source file:com.facebook.buck.features.haskell.HaskellGhciDescription.java
/** * @param omnibusRoots roots of the graph of nodes (including transitive deps) to include in the * omnibus link.//from w w w . java 2 s . c o m * @param excludedRoots roots of a the graph of nodes (including transitive deps) that cannot be * included in the omnibus link. * @return the {@link HaskellGhciOmnibusSpec} describing the omnibus link. */ public static HaskellGhciOmnibusSpec getOmnibusSpec(BuildTarget baseTarget, CxxPlatform cxxPlatform, ActionGraphBuilder graphBuilder, ImmutableMap<BuildTarget, ? extends NativeLinkable> omnibusRoots, ImmutableMap<BuildTarget, ? extends NativeLinkable> excludedRoots) { LOG.verbose("%s: omnibus roots: %s", baseTarget, omnibusRoots); LOG.verbose("%s: excluded roots: %s", baseTarget, excludedRoots); HaskellGhciOmnibusSpec.Builder builder = HaskellGhciOmnibusSpec.builder(); // Calculate excluded roots/deps, and add them to the link. ImmutableMap<BuildTarget, NativeLinkable> transitiveExcludedLinkables = NativeLinkables .getTransitiveNativeLinkables(cxxPlatform, graphBuilder, excludedRoots.values()); builder.setExcludedRoots(excludedRoots); builder.setExcludedTransitiveDeps(transitiveExcludedLinkables); // Calculate the body and first-order deps of omnibus. new AbstractBreadthFirstTraversal<NativeLinkable>(omnibusRoots.values()) { @Override public Iterable<? extends NativeLinkable> visit(NativeLinkable nativeLinkable) { // Excluded linkables can't be included in omnibus. if (transitiveExcludedLinkables.containsKey(nativeLinkable.getBuildTarget())) { LOG.verbose("%s: skipping excluded linkable %s", baseTarget, nativeLinkable.getBuildTarget()); return ImmutableSet.of(); } // We cannot include prebuilt SOs in omnibus. // // TODO(agallagher): We should also use `NativeLinkable.supportsOmnibusLinking()` to // determine if we can include the library, but this will need likely need to be updated for // a multi-pass walk first. if (isPrebuiltSO(nativeLinkable, cxxPlatform, graphBuilder)) { builder.putDeps(nativeLinkable.getBuildTarget(), nativeLinkable); LOG.verbose("%s: skipping prebuilt SO %s", baseTarget, nativeLinkable.getBuildTarget()); return ImmutableSet.of(); } // Include C/C++ libs capable of static linking in omnibus. // // TODO(agallagher): This should probably be *any* `NativeLinkable` that supports omnibus // linking. if (nativeLinkable instanceof CxxLibrary || nativeLinkable instanceof PrebuiltCxxLibrary) { builder.putBody(nativeLinkable.getBuildTarget(), nativeLinkable); LOG.verbose("%s: including C/C++ library %s", baseTarget, nativeLinkable.getBuildTarget()); return Iterables.concat( nativeLinkable.getNativeLinkableDepsForPlatform(cxxPlatform, graphBuilder), nativeLinkable.getNativeLinkableExportedDepsForPlatform(cxxPlatform, graphBuilder)); } // Unexpected node. Can this actually happen? // // TODO(agallagher): This should probably be an internal error/assertion, as silently // dropping libraries at this point will likely result in we're user errors. return ImmutableSet.of(); } }.start(); HaskellGhciOmnibusSpec spec = builder.build(); LOG.verbose("%s: built omnibus spec %s", spec); return spec; }
From source file:com.facebook.buck.halide.HalideBuckConfig.java
public String getHalideTargetForPlatform(CxxPlatform cxxPlatform) { String flavorName = cxxPlatform.getFlavor().toString(); ImmutableMap<String, String> targetMap = getHalideTargetMap(); if (!targetMap.containsKey(flavorName)) { throw new HumanReadableException("No halide target found for platform: '%s'\n" + "Add one in .buckconfig in the halide section.\n" + "\n" + "Example:\n" + "\n" + "[halide]" + "\n" + "target_%s = x86-64-osx-user_context", flavorName, flavorName); }//from w w w . j a v a 2 s. c o m return targetMap.get(flavorName); }
From source file:org.apache.gobblin.dataset.HiveToHdfsDatasetResolver.java
@Override public DatasetDescriptor resolve(DatasetDescriptor raw, State state) { ImmutableMap<String, String> metadata = raw.getMetadata(); Preconditions.checkArgument(metadata.containsKey(DatasetConstants.FS_SCHEME), String.format("Hive Dataset Descriptor must contain metadata %s to create Hdfs Dataset Descriptor", DatasetConstants.FS_SCHEME)); Preconditions.checkArgument(metadata.containsKey(DatasetConstants.FS_SCHEME), String.format("Hive Dataset Descriptor must contain metadata %s to create Hdfs Dataset Descriptor", DatasetConstants.FS_LOCATION)); DatasetDescriptor datasetDescriptor = new DatasetDescriptor(metadata.get(DatasetConstants.FS_SCHEME), metadata.get(DatasetConstants.FS_LOCATION)); datasetDescriptor.addMetadata(HIVE_TABLE, raw.getName()); return datasetDescriptor; }
From source file:mod.rankshank.arbitraria.client.item.spraybottle.ModelSprayBottleFluid.java
@Override public IModel retexture(ImmutableMap<String, String> data) { return new ModelSprayBottleFluid( data.containsKey("bottle") ? new ResourceLocation(data.get("bottle")) : this.bottle, data.containsKey("filler") ? new ResourceLocation(data.get("filler")) : this.filler, this.fluid); }
From source file:com.bigfatgun.fixjures.proxy.InterfaceProxy.java
public Object invoke(final Object object, final Method method, final Object[] parameters) throws Throwable { if (parameters != null && parameters.length == 1 && method.getName().equals("equals")) { return object == parameters[0]; }/*from w w w . java2 s . co m*/ if (parameters != null) { // TODO : make option for this exception throw new RuntimeException( "Proxied methods shall take no arguments. Call: " + callToString(method, parameters)); } final ImmutableMap<String, Supplier<?>> stubs = getStubs(); if (stubs.containsKey(method.getName())) { return stubs.get(method.getName()).get(); } else if (isOptionEnabled(Fixjure.Option.NULL_ON_UNMAPPED)) { return null; } else { throw new FixtureException("Method has not been stubbed. Call: " + callToString(method, parameters)); } }
From source file:com.mattjtodd.coherence.CoherenceCacheManager.java
/** * Create a new cache if required and return the new caches map state. * * @param caches the current state of the caches map * @param name the name of the cache to create * @return the new state of the caches map *//*from w w w.j a va 2 s . com*/ private ImmutableMap<String, CoherenceCache> createCache(ImmutableMap<String, CoherenceCache> caches, String name) { ImmutableMap<String, CoherenceCache> map = caches; if (!caches.containsKey(name)) { map = ImmutableMap.<String, CoherenceCache>builder().putAll(caches).put(name, cacheFactory.apply(name)) .build(); } return map; }
From source file:com.facebook.buck.cli.BuildCommandOptions.java
private void setNumThreadsFromConfig(BuckConfig buckConfig) { ImmutableMap<String, String> build = buckConfig.getEntriesForSection("build"); if (build.containsKey("threads")) { try {/* w w w . j a v a2 s . c o m*/ numThreads = Integer.parseInt(build.get("threads")); } catch (NumberFormatException e) { throw new HumanReadableException( "Unable to determine number of threads to use from building from buck config file. " + "Value used was '%s'", build.get("threads")); } } }