List of usage examples for com.google.common.collect ImmutableMap keySet
public ImmutableSet<K> keySet()
From source file:com.opengamma.strata.pricer.sensitivity.RatesFiniteDifferenceSensitivityCalculator.java
private <T> CurrencyParameterSensitivities sensitivity(ImmutableLegalEntityDiscountingProvider provider, Function<ImmutableLegalEntityDiscountingProvider, CurrencyAmount> valueFn, MetaProperty<ImmutableMap<Pair<T, Currency>, DiscountFactors>> metaProperty, CurrencyAmount valueInit) { ImmutableMap<Pair<T, Currency>, DiscountFactors> baseCurves = metaProperty.get(provider); CurrencyParameterSensitivities result = CurrencyParameterSensitivities.empty(); for (Pair<T, Currency> key : baseCurves.keySet()) { DiscountFactors discountFactors = baseCurves.get(key); Curve curve = checkDiscountFactors(discountFactors); int paramCount = curve.getParameterCount(); double[] sensitivity = new double[paramCount]; for (int i = 0; i < paramCount; i++) { Curve dscBumped = curve.withParameter(i, curve.getParameter(i) + shift); Map<Pair<T, Currency>, DiscountFactors> mapBumped = new HashMap<>(baseCurves); mapBumped.put(key, createDiscountFactors(discountFactors, dscBumped)); ImmutableLegalEntityDiscountingProvider providerDscBumped = provider.toBuilder() .set(metaProperty, mapBumped).build(); sensitivity[i] = (valueFn.apply(providerDscBumped).getAmount() - valueInit.getAmount()) / shift; }/* w w w . j av a 2 s.com*/ result = result.combinedWith( curve.createParameterSensitivity(valueInit.getCurrency(), DoubleArray.copyOf(sensitivity))); } return result; }
From source file:blusunrize.immersiveengineering.client.models.multilayer.MultiLayerModel.java
@Nonnull @Override/*from w w w.ja va 2 s . com*/ public IModel process(ImmutableMap<String, String> customData) { Map<BlockRenderLayer, List<ModelData>> newSubs = new HashMap<>(); JsonParser parser = new JsonParser(); Map<String, String> unused = new HashMap<>(); for (String layerStr : customData.keySet()) if (LAYERS_BY_NAME.containsKey(layerStr)) { BlockRenderLayer layer = LAYERS_BY_NAME.get(layerStr); JsonElement ele = parser.parse(customData.get(layerStr)); if (ele.isJsonObject()) { ModelData data = ModelData.fromJson(ele.getAsJsonObject(), ImmutableList.of(), ImmutableMap.of()); newSubs.put(layer, ImmutableList.of(data)); } else if (ele.isJsonArray()) { JsonArray array = ele.getAsJsonArray(); List<ModelData> models = new ArrayList<>(); for (JsonElement subEle : array) if (subEle.isJsonObject()) models.add(ModelData.fromJson(ele.getAsJsonObject(), ImmutableList.of(), ImmutableMap.of())); newSubs.put(layer, models); } } else unused.put(layerStr, customData.get(layerStr)); JsonObject unusedJson = ModelData.asJsonObject(unused); for (Entry<BlockRenderLayer, List<ModelData>> entry : newSubs.entrySet()) for (ModelData d : entry.getValue()) for (Entry<String, JsonElement> entryJ : unusedJson.entrySet()) if (!d.data.has(entryJ.getKey())) d.data.add(entryJ.getKey(), entryJ.getValue()); if (!newSubs.equals(subModels)) return new MultiLayerModel(newSubs); return this; }
From source file:com.facebook.buck.jvm.java.intellij.IjProjectWriter.java
private Optional<String> getFirstResourcePackageFromDependencies(IjModule module) { ImmutableMap<IjModule, DependencyType> deps = moduleGraph.getDependentModulesFor(module); for (IjModule dep : deps.keySet()) { Optional<IjModuleAndroidFacet> facet = dep.getAndroidFacet(); if (facet.isPresent()) { Optional<String> packageName = facet.get().getPackageName(); if (packageName.isPresent()) { return packageName; }//from www.jav a2 s. c o m } } return Optional.empty(); }
From source file:org.glowroot.agent.weaving.AdviceCache.java
private static ImmutableList<Advice> createReweavableAdvisors(List<InstrumentationConfig> reweavableConfigs, @Nullable Instrumentation instrumentation, File tmpDir, boolean cleanTmpDir) throws Exception { ImmutableMap<Advice, LazyDefinedClass> advisors = AdviceGenerator.createAdvisors(reweavableConfigs, null, false, true);//w ww .ja v a2 s . co m if (instrumentation == null) { // instrumentation is null when debugging with LocalContainer ClassLoader isolatedWeavingClassLoader = Thread.currentThread().getContextClassLoader(); checkNotNull(isolatedWeavingClassLoader); ClassLoaders.defineClasses(advisors.values(), isolatedWeavingClassLoader); } else { if (cleanTmpDir) { ClassLoaders.createDirectoryOrCleanPreviousContentsWithPrefix(tmpDir, "config-pointcuts"); } if (!advisors.isEmpty()) { String suffix = ""; int count = jarFileCounter.incrementAndGet(); if (count > 1) { suffix = "-" + count; } File jarFile = new File(tmpDir, "config-pointcuts" + suffix + ".jar"); ClassLoaders.defineClassesInBootstrapClassLoader(advisors.values(), instrumentation, jarFile); } } return advisors.keySet().asList(); }
From source file:springfox.documentation.schema.DefaultModelProvider.java
@Override public com.google.common.base.Optional<Model> modelFor(ModelContext modelContext) { ResolvedType propertiesHost = modelContext.alternateFor(modelContext.resolvedType(resolver)); if (isContainerType(propertiesHost) || isMapType(propertiesHost) || propertiesHost.getErasedType().isEnum() || isBaseType(propertiesHost) || modelContext.hasSeenBefore(propertiesHost)) { LOG.debug(//from ww w.java 2 s. co m "Skipping model of type {} as its either a container type, map, enum or base type, or its already " + "been handled", resolvedTypeSignature(propertiesHost).or("<null>")); return Optional.absent(); } ImmutableMap<String, ModelProperty> propertiesIndex = uniqueIndex(properties(modelContext, propertiesHost), byPropertyName()); LOG.debug("Inferred {} properties. Properties found {}", propertiesIndex.size(), Joiner.on(", ").join(propertiesIndex.keySet())); Map<String, ModelProperty> properties = newTreeMap(); properties.putAll(propertiesIndex); return Optional.of(modelBuilder(propertiesHost, properties, modelContext)); }
From source file:com.google.enterprise.connector.instantiator.ChangeDetectorImpl.java
@Override public synchronized void detect() { NDC.push("Change"); try {// ww w . jav a 2 s . c o m ImmutableMap<StoreContext, ConnectorStamps> persistentInventory = store.getInventory(); SortedSet<StoreContext> persistentInstances = new TreeSet<StoreContext>(persistentInventory.keySet()); // Compare the last known (inMemory) inventory with the new inventory // from the persistent store. Notify ChangeListeners of any differences. // Save in memory, the new inventory of unchanged items and successfully // applied changes. inMemoryInventory = compareInventoriesAndNotifyListeners(inMemoryInstances.iterator(), persistentInstances.iterator(), persistentInventory); inMemoryInstances = persistentInstances; } finally { NDC.pop(); } }
From source file:com.google.devtools.build.lib.skyframe.TraversalInfoRootPackageExtractor.java
private void collectPackagesUnder(WalkableGraph graph, ExtendedEventHandler eventHandler, final RepositoryName repository, Set<TraversalInfo> traversals, ImmutableList.Builder<PathFragment> builder) throws InterruptedException { Map<TraversalInfo, SkyKey> traversalToKeyMap = Maps.asMap(traversals, new Function<TraversalInfo, SkyKey>() { @Override//from www . j av a 2 s. com public SkyKey apply(TraversalInfo traversalInfo) { return CollectPackagesUnderDirectoryValue.key(repository, traversalInfo.rootedDir, traversalInfo.blacklistedSubdirectories); } }); Map<SkyKey, SkyValue> values = graph.getSuccessfulValues(traversalToKeyMap.values()); ImmutableSet.Builder<TraversalInfo> subdirTraversalBuilder = ImmutableSet.builder(); for (Map.Entry<TraversalInfo, SkyKey> entry : traversalToKeyMap.entrySet()) { TraversalInfo info = entry.getKey(); SkyKey key = entry.getValue(); SkyValue val = values.get(key); CollectPackagesUnderDirectoryValue collectPackagesValue = (CollectPackagesUnderDirectoryValue) val; if (collectPackagesValue != null) { if (collectPackagesValue.isDirectoryPackage()) { builder.add(info.rootedDir.getRootRelativePath()); } if (collectPackagesValue.getErrorMessage() != null) { eventHandler.handle(Event.error(collectPackagesValue.getErrorMessage())); } ImmutableMap<RootedPath, Boolean> subdirectoryTransitivelyContainsPackages = collectPackagesValue .getSubdirectoryTransitivelyContainsPackagesOrErrors(); for (RootedPath subdirectory : subdirectoryTransitivelyContainsPackages.keySet()) { if (subdirectoryTransitivelyContainsPackages.get(subdirectory)) { PathFragment subdirectoryRelativePath = subdirectory.getRootRelativePath(); ImmutableSet<PathFragment> blacklistedSubdirectoriesBeneathThisSubdirectory = info.blacklistedSubdirectories .stream().filter(pathFragment -> pathFragment.startsWith(subdirectoryRelativePath)) .collect(toImmutableSet()); ImmutableSet<PathFragment> excludedSubdirectoriesBeneathThisSubdirectory = info.excludedSubdirectories .stream().filter(pathFragment -> pathFragment.startsWith(subdirectoryRelativePath)) .collect(toImmutableSet()); if (!excludedSubdirectoriesBeneathThisSubdirectory.contains(subdirectoryRelativePath)) { subdirTraversalBuilder.add(new TraversalInfo(subdirectory, blacklistedSubdirectoriesBeneathThisSubdirectory, excludedSubdirectoriesBeneathThisSubdirectory)); } } } } } ImmutableSet<TraversalInfo> subdirTraversals = subdirTraversalBuilder.build(); if (!subdirTraversals.isEmpty()) { collectPackagesUnder(graph, eventHandler, repository, subdirTraversals, builder); } }
From source file:com.facebook.buck.java.intellij.IjModuleGraph.java
public ImmutableMap<IjModule, DependencyType> getDependentModulesFor(IjModule source) { final ImmutableMap<IjProjectElement, DependencyType> deps = getDepsFor(source); return FluentIterable.from(deps.keySet()).filter(IjModule.class) .toMap(new Function<IjModule, DependencyType>() { @Override//from w w w . j av a2 s . c o m public DependencyType apply(IjModule input) { return Preconditions.checkNotNull(deps.get(input)); } }); }
From source file:com.facebook.buck.java.intellij.IjModuleGraph.java
public ImmutableMap<IjLibrary, DependencyType> getDependentLibrariesFor(IjModule source) { final ImmutableMap<IjProjectElement, DependencyType> deps = getDepsFor(source); return FluentIterable.from(deps.keySet()).filter(IjLibrary.class) .toMap(new Function<IjLibrary, DependencyType>() { @Override/* w w w .j a va 2 s. c o m*/ public DependencyType apply(IjLibrary input) { return Preconditions.checkNotNull(deps.get(input)); } }); }
From source file:com.google.enterprise.connector.persist.MigrateStore.java
/** * Returns a Collection of the names of configured PersistentStores. *//*from w ww. j a v a2 s .co m*/ private Collection<String> getConnectorNames(PersistentStore sourceStore) { ImmutableMap<StoreContext, ConnectorStamps> inventory = sourceStore.getInventory(); TreeSet<String> names = new TreeSet<String>(); for (StoreContext context : inventory.keySet()) { names.add(context.getConnectorName()); } return names; }