List of usage examples for com.google.common.collect ImmutableMap keySet
public ImmutableSet<K> keySet()
From source file:com.facebook.buck.core.resources.AbstractResourcesConfig.java
@Value.Lazy public ImmutableMap<String, ResourceAmounts> getResourceAmountsPerRuleType() { ImmutableMap.Builder<String, ResourceAmounts> result = ImmutableMap.builder(); ImmutableMap<String, String> entries = getDelegate() .getEntriesForSection(RESOURCES_PER_RULE_SECTION_HEADER); for (String ruleName : entries.keySet()) { ImmutableList<String> configAmounts = getDelegate() .getListWithoutComments(RESOURCES_PER_RULE_SECTION_HEADER, ruleName); Preconditions.checkArgument(configAmounts.size() == ResourceAmounts.RESOURCE_TYPE_COUNT, "Buck config entry [%s].%s contains %s values, but expected to contain %s values " + "in the following order: cpu, memory, disk_io, network_io", RESOURCES_PER_RULE_SECTION_HEADER, ruleName, configAmounts.size(), ResourceAmounts.RESOURCE_TYPE_COUNT); ResourceAmounts amounts = ResourceAmounts.of(Integer.parseInt(configAmounts.get(0)), Integer.parseInt(configAmounts.get(1)), Integer.parseInt(configAmounts.get(2)), Integer.parseInt(configAmounts.get(3))); result.put(ruleName, amounts);/*from w w w .ja v a2 s . c om*/ } return result.build(); }
From source file:com.google.devtools.build.android.ParsedAndroidDataSubject.java
private <T extends DataValue> void compareDataValues(Iterable<Entry<DataKey, T>> actual, Iterable<Entry<DataKey, T>> expected, List<String> out, String valueType) { List<String> errors = new ArrayList<>(); ImmutableMap<DataKey, T> actualMap = ImmutableMap.copyOf(actual); ImmutableMap<DataKey, T> expectedMap = ImmutableMap.copyOf(expected); for (DataKey key : Sets.union(actualMap.keySet(), expectedMap.keySet())) { if (!(actualMap.containsKey(key) && expectedMap.containsKey(key))) { if (!actualMap.containsKey(key)) { errors.add(error("\tExpected %s.", key.toPrettyString())); }//from ww w.j a v a2 s. co m if (!expectedMap.containsKey(key)) { errors.add(error("\tHad unexpected %s.", key.toPrettyString())); } } else { T actualValue = actualMap.get(key); T expectedValue = expectedMap.get(key); if (!actualValue.equals(expectedValue)) { errors.add(error("\t%s is not equal", key.toPrettyString())); if (!actualValue.source().equals(expectedValue.source())) { if (!actualValue.source().getPath().equals(expectedValue.source().getPath())) { errors.add(error("\t\t%-10s: %s", "Expected path", expectedValue.source().getPath())); errors.add(error("\t\t%-10s: %s", "Actual path", actualValue.source().getPath())); } if (!actualValue.source().overrides().equals(expectedValue.source().overrides())) { errors.add(error("\t\t%-10s: %s", "Expected overrides", expectedValue.source())); errors.add(error("\t\t%-10s: %s", "Actual overrides", actualValue.source())); } } if (!actualValue.getClass().equals(expectedValue.getClass())) { errors.add(error("\t\t%-10s: %s", "Expected class", expectedValue.getClass())); errors.add(error("\t\t%-10s: %s", "Actual class", actualValue.getClass())); } else if (actualValue instanceof DataResourceXml) { errors.add(error("\t\t%-10s: %s", "Expected xml", expectedValue)); errors.add(error("\t\t%-10s: %s", "Actual xml", actualValue)); } } } } if (errors.isEmpty()) { return; } out.add(valueType); out.add(Joiner.on("\n").join(errors)); }
From source file:com.facebook.buck.apple.toolchain.AbstractProvisioningProfileMetadata.java
public ImmutableMap<String, NSObject> getMergeableEntitlements() { ImmutableSet<String> includedKeys = ImmutableSet.of("application-identifier", "beta-reports-active", "get-task-allow", "com.apple.developer.aps-environment", "com.apple.developer.team-identifier"); ImmutableMap<String, NSObject> allEntitlements = getEntitlements(); ImmutableMap.Builder<String, NSObject> filteredEntitlementsBuilder = ImmutableMap.builder(); for (String key : allEntitlements.keySet()) { if (includedKeys.contains(key)) { filteredEntitlementsBuilder.put(key, allEntitlements.get(key)); }/*from w w w. ja v a2 s . co m*/ } return filteredEntitlementsBuilder.build(); }
From source file:uk.q3c.krail.core.navigate.sitemap.UserSitemapCopyExtension.java
/** * All the standard pages are always copied, even though they may not appear in the main uriMap. The standard pages are often used for comparison in * things//from w ww .j av a2s . c om * like {@link LoginNavigationRule}s, so need always to be available, even though they are not necessarily displayed in navigation components */ private void copyStandardPages() { log.debug("copying standard pages"); ImmutableMap<StandardPageKey, MasterSitemapNode> sourcePages = masterSitemap.getStandardPages(); Collator collator = Collator.getInstance(currentLocale.getLocale()); for (StandardPageKey spk : sourcePages.keySet()) { MasterSitemapNode masterNode = sourcePages.get(spk); UserSitemapNode userNode = new UserSitemapNode(masterNode); userNode.setLabel(translate.from(masterNode.getLabelKey())); userNode.setCollationKey(collator.getCollationKey(userNode.getLabel())); userSitemap.addStandardPage(userNode, masterSitemap.uri(masterNode)); } }
From source file:org.spongepowered.granite.mixin.block.state.MixinBlockState.java
@Override @SuppressWarnings("unchecked") public Collection<String> getPropertyNames() { ImmutableMap<IProperty, Comparable<?>> properties = ((IBlockState) this).getProperties(); List<String> names = Lists.newArrayListWithCapacity(properties.size()); for (IProperty property : properties.keySet()) { names.add(property.getName());//w w w.j a va2 s. c om } return Collections.unmodifiableCollection(names); }
From source file:com.epam.dlab.configuration.LoggingConfigurationFactory.java
/** Set the list of logging levels for appenders. */ @JsonProperty//from w w w.j av a 2 s . c o m public void setLoggers(ImmutableMap<String, JsonNode> loggers) throws InitializationException { ImmutableMap.Builder<String, Level> levels = new ImmutableMap.Builder<String, Level>(); for (String key : loggers.keySet()) { JsonNode node = loggers.get(key); levels.put(key, toLevel(node.asText())); } this.loggers = levels.build(); }
From source file:com.facebook.buck.rules.coercer.StringWithMacrosTypeCoercer.java
private StringWithMacrosTypeCoercer(ImmutableMap<String, Class<? extends Macro>> macros, ImmutableMap<Class<? extends Macro>, MacroTypeCoercer<? extends Macro>> coercers) { Preconditions.checkArgument(Sets.difference(coercers.keySet(), new HashSet<>(macros.values())).isEmpty()); this.macros = macros; this.coercers = coercers; }
From source file:org.glowroot.agent.weaving.ClassAnalyzer.java
private static List<AnalyzedClass> hack(ThinClass thinClass, ClassLoader loader, List<AnalyzedClass> superAnalyzedClasses, Set<String> ejbRemoteInterfaces) { Map<String, List<String>> superInterfaceNames = Maps.newHashMap(); for (AnalyzedClass analyzedClass : superAnalyzedClasses) { if (analyzedClass.isInterface()) { superInterfaceNames.put(analyzedClass.name(), analyzedClass.interfaceNames()); }//from w w w .j a v a 2 s .c o m } Map<String, String> interfaceNamesToInstrument = Maps.newHashMap(); for (String ejbRemoteInterface : ejbRemoteInterfaces) { addToInterfaceNamesToInstrument(ejbRemoteInterface, superInterfaceNames, interfaceNamesToInstrument, ejbRemoteInterface); } List<InstrumentationConfig> instrumentationConfigs = Lists.newArrayList(); for (Map.Entry<String, String> entry : interfaceNamesToInstrument.entrySet()) { String shortClassName = entry.getValue(); int index = shortClassName.lastIndexOf('.'); if (index != -1) { shortClassName = shortClassName.substring(index + 1); } index = shortClassName.lastIndexOf('$'); if (index != -1) { shortClassName = shortClassName.substring(index + 1); } instrumentationConfigs.add(ImmutableInstrumentationConfig.builder().className(entry.getKey()) .subTypeRestriction(ClassNames.fromInternalName(thinClass.name())).methodName("*") .addMethodParameterTypes("..").captureKind(CaptureKind.TRANSACTION).transactionType("Web") .transactionNameTemplate("EJB remote: " + shortClassName + "#{{methodName}}") .traceEntryMessageTemplate("EJB remote: " + entry.getValue() + ".{{methodName}}()") .timerName("ejb remote").build()); } ImmutableMap<Advice, LazyDefinedClass> newAdvisors = AdviceGenerator.createAdvisors(instrumentationConfigs, null, false, false); try { ClassLoaders.defineClasses(newAdvisors.values(), loader); } catch (Exception e) { logger.error(e.getMessage(), e); } Map<String, Advice> newAdvisorsByRemoteInterface = Maps.newHashMap(); for (Advice advice : newAdvisors.keySet()) { newAdvisorsByRemoteInterface.put(advice.pointcut().className(), advice); } List<AnalyzedClass> ejbHackedSuperAnalyzedClasses = Lists.newArrayList(); for (AnalyzedClass superAnalyzedClass : superAnalyzedClasses) { Advice advice = newAdvisorsByRemoteInterface.get(superAnalyzedClass.name()); if (advice == null) { ejbHackedSuperAnalyzedClasses.add(superAnalyzedClass); } else { ImmutableAnalyzedClass.Builder builder = ImmutableAnalyzedClass.builder() .copyFrom(superAnalyzedClass); List<AnalyzedMethod> analyzedMethods = Lists.newArrayList(); for (AnalyzedMethod analyzedMethod : superAnalyzedClass.analyzedMethods()) { analyzedMethods.add(ImmutableAnalyzedMethod.builder().copyFrom(analyzedMethod) .addSubTypeRestrictedAdvisors(advice).build()); } builder.analyzedMethods(analyzedMethods); ejbHackedSuperAnalyzedClasses.add(builder.build()); } } return ejbHackedSuperAnalyzedClasses; }
From source file:com.radeonsys.data.querystore.support.properties.PropertiesQueryStore.java
/** * Copies queries from the specified properties object into this query * store/* w ww .ja v a2 s .c o m*/ * * @param props reference to an instance of {@link Properties} which * contains query definitions to copy * * @throws IllegalArgumentException * if the specified properties is {@code null} */ private final void copyQueriesToStore(Properties props) { Preconditions.checkArgument(props != null, "A valid set of properties must be specified."); if (props.isEmpty()) return; ImmutableMap<String, String> propMap = Maps.fromProperties(props); for (String queryName : propMap.keySet()) addQuery(queryName, propMap.get(queryName).trim()); if (logger.isTraceEnabled()) logger.trace(String.format("Copied %d queries into query store", props.size())); }
From source file:com.facebook.buck.android.exopackage.NativeExoHelper.java
/** * @return a mapping from destinationPathOnDevice -> contents of file for all native-libs metadata * files (one per abi)/* w w w . j a va 2 s. c o m*/ */ public ImmutableMap<Path, String> getMetadataToInstall() throws IOException { ImmutableMap<String, ImmutableMultimap<String, Path>> filesByHashForAbis = getFilesByHashForAbis(); ImmutableMap.Builder<Path, String> metadataBuilder = ImmutableMap.builder(); for (String abi : filesByHashForAbis.keySet()) { ImmutableMultimap<String, Path> filesByHash = Objects.requireNonNull(filesByHashForAbis.get(abi)); Path abiDir = NATIVE_LIBS_DIR.resolve(abi); metadataBuilder.put(abiDir.resolve("metadata.txt"), getNativeLibraryMetadataContents(filesByHash)); } return metadataBuilder.build(); }