List of usage examples for com.google.common.collect ImmutableMultimap keySet
@Override
public ImmutableSet<K> keySet()
From source file:org.smartloli.kafka.eagle.core.sql.schema.JSqlSchema.java
@Override protected Multimap<String, Function> getFunctionMultimap() { ImmutableMultimap<String, ScalarFunction> funcs = ScalarFunctionImpl.createAll(JSONFunction.class); Multimap<String, Function> functions = HashMultimap.create(); for (String key : funcs.keySet()) { for (ScalarFunction func : funcs.get(key)) { functions.put(key, func);// w w w . ja v a2 s .co m } } return functions; }
From source file:org.prebake.service.tools.ext.JunitHtmlReportGenerator.java
private static Map<String, Integer> generateHtmlReportOnePackage(String packageName, Collection<Map<?, ?>> tests, Path reportDir, List<String> resultTypes) throws IOException { ImmutableMultimap<String, Map<?, ?>> byClass = groupBy(tests, new Function<Map<?, ?>, String>() { public String apply(Map<?, ?> test) { String className = getIfOfType(test, ReportKey.CLASS_NAME, String.class); int lastDot = className.lastIndexOf('.'); return lastDot >= 0 ? className.substring(lastDot + 1) : className; }/*from w w w. ja v a2 s .c om*/ }); Map<String, Integer> summary = Maps.newHashMap(); ImmutableList.Builder<Html> table = ImmutableList.builder(); Path outFile = reportDir.resolve(packageName + PACKAGE_FILE_SUFFIX + ".html"); mkdirs(outFile.getParent()); String[] classNames = byClass.keySet().toArray(NO_STRINGS); Arrays.sort(classNames); for (String className : classNames) { Collection<Map<?, ?>> classTests = byClass.get(className); Map<String, Integer> itemSummary = generateHtmlReportOneClass(packageName, className, classTests, reportDir.resolve(packageName), resultTypes); bagPutAll(itemSummary, summary); table.add(htmlLink(packageName + "/" + className + ".html", className)) .add(htmlSpan("summary", summaryToHtml(itemSummary, resultTypes))); } writeReport(outFile, "package " + packageName, KEY_VAL, table.build(), summary, tests, resultTypes, "index", packageName + PACKAGE_FILE_SUFFIX); return summary; }
From source file:com.facebook.buck.ide.intellij.BaseIjModuleRule.java
private void addDeps(ImmutableMultimap<Path, Path> foldersToInputsIndex, TargetNode<T, ?> targetNode, DependencyType dependencyType, ModuleBuildContext context) { context.addDeps(foldersToInputsIndex.keySet(), targetNode.getBuildDeps(), dependencyType); }
From source file:google.registry.tools.CreateAuctionCreditsCommand.java
/** * Stages the creation of RegistrarCredit and RegistrarCreditBalance instances for each * registrar in the provided multimap of credit amounts by registrar. The balance instance * created is the total of all the credit amounts for a given registrar. */// w w w.j ava2 s . co m private void stageCreditCreations(ImmutableMultimap<Registrar, BigMoney> creditMap) { DateTime now = DateTime.now(UTC); CurrencyUnit currency = Registry.get(tld).getCurrency(); for (Registrar registrar : creditMap.keySet()) { // Use RoundingMode.UP to be nice and give registrars the extra fractional units. Money totalAmount = BigMoney.total(currency, creditMap.get(registrar)).toMoney(RoundingMode.UP); System.out.printf("Total auction credit balance for %s: %s\n", registrar.getClientId(), totalAmount); // Create the actual credit and initial credit balance. RegistrarCredit credit = new RegistrarCredit.Builder().setParent(registrar).setType(CreditType.AUCTION) .setCreationTime(now).setCurrency(currency).setTld(tld).build(); RegistrarCreditBalance creditBalance = new RegistrarCreditBalance.Builder().setParent(credit) .setEffectiveTime(effectiveTime).setWrittenTime(now).setAmount(totalAmount).build(); stageEntityChange(null, credit); stageEntityChange(null, creditBalance); } }
From source file:com.facebook.buck.android.exopackage.NativeExoHelper.java
private ImmutableMap<String, ImmutableMultimap<String, Path>> getFilesByHashForAbis() throws IOException { List<String> deviceAbis = abiSupplier.get(); ImmutableMap.Builder<String, ImmutableMultimap<String, Path>> filesByHashForAbisBuilder = ImmutableMap .builder();//from www.ja va2 s .com ImmutableMultimap<String, Path> allLibraries = getAllLibraries(); ImmutableSet.Builder<String> providedLibraries = ImmutableSet.builder(); for (String abi : deviceAbis) { ImmutableMultimap<String, Path> filesByHash = getRequiredLibrariesForAbi(allLibraries, abi, providedLibraries.build()); if (filesByHash.isEmpty()) { continue; } providedLibraries.addAll(filesByHash.keySet()); filesByHashForAbisBuilder.put(abi, filesByHash); } return filesByHashForAbisBuilder.build(); }
From source file:com.facebook.buck.features.project.intellij.BaseIjModuleRule.java
private void addDeps(ImmutableMultimap<Path, Path> foldersToInputsIndex, TargetNode<T> targetNode, DependencyType dependencyType, ModuleBuildContext context) { context.addDeps(foldersToInputsIndex.keySet(), targetNode.getBuildDeps(), dependencyType); }
From source file:org.prebake.service.tools.ext.JunitHtmlReportGenerator.java
private static Map<String, Integer> generateHtmlReportOneClass(String packageName, String className, Collection<Map<?, ?>> tests, Path reportDir, List<String> resultTypes) throws IOException { ImmutableMultimap<String, Map<?, ?>> byTestName = groupBy(tests, new Function<Map<?, ?>, String>() { int counter = 0; public String apply(Map<?, ?> test) { String methodName = getIfOfType(test, ReportKey.METHOD_NAME, String.class); if (methodName != null) { return methodName; }/*from w w w .j ava2s .co m*/ String testName = getIfOfType(test, ReportKey.TEST_NAME, String.class); if (testName != null) { return testName; } return "#" + (counter++); } }); ImmutableList.Builder<Html> table = ImmutableList.builder(); Map<String, Integer> summary = Maps.newHashMap(); Path outFile = reportDir.resolve(className + ".html"); mkdirs(outFile.getParent()); String[] testNames = byTestName.keySet().toArray(NO_STRINGS); Arrays.sort(testNames); for (String testName : testNames) { int counter = 0; for (Map<?, ?> test : byTestName.get(testName)) { int testIndex = counter++; Map<String, Integer> itemSummary = generateHtmlReportOneTest(packageName, className, testName, testIndex, test, reportDir.resolve(className), resultTypes); bagPutAll(itemSummary, summary); table.add(htmlLink(className + "/" + testName + "_" + testIndex + ".html", testName)) .add(htmlSpan("summary", summaryToHtml(itemSummary, resultTypes))); Object cause = test.get(ReportKey.FAILURE_MESSAGE); table.add(htmlFromString(cause instanceof String ? (String) cause : "")); } } writeReport(outFile, "class " + className, KEY_VAL_PREVIEW, table.build(), summary, tests, resultTypes, "index", packageName + PACKAGE_FILE_SUFFIX, className); return summary; }
From source file:com.facebook.buck.apple.xcode.ProjectGenerator.java
/** * For all inputs by name, verify every entry has identical project level config, and pick one * such config to return.//from w w w .ja va2 s .co m * * @param configInXcodeLayoutMultimap input mapping of { Config Name -> Config List } * @throws com.facebook.buck.util.HumanReadableException * if project-level configs are not identical for a named configuration */ private static ImmutableMap<String, ConfigInXcodeLayout> collectProjectLevelConfigsIfIdenticalOrFail( ImmutableMultimap<String, ConfigInXcodeLayout> configInXcodeLayoutMultimap) { ImmutableMap.Builder<String, ConfigInXcodeLayout> builder = ImmutableMap.builder(); for (String configName : configInXcodeLayoutMultimap.keySet()) { ConfigInXcodeLayout firstConfig = null; for (ConfigInXcodeLayout config : configInXcodeLayoutMultimap.get(configName)) { if (firstConfig == null) { firstConfig = config; } else if (!firstConfig.projectLevelConfigFile.equals(config.projectLevelConfigFile) || !firstConfig.projectLevelInlineSettings.equals(config.projectLevelInlineSettings)) { throw new HumanReadableException(String.format( "Project level configurations should be identical:\n" + " Config named: `%s` in `%s` and `%s` ", configName, firstConfig.buildTarget, config.buildTarget)); } } Preconditions.checkNotNull(firstConfig); builder.put(configName, firstConfig); } return builder.build(); }
From source file:com.facebook.buck.android.CompileStringsStep.java
@Override public int execute(ExecutionContext context) { ProjectFilesystem filesystem = context.getProjectFilesystem(); try {//from ww w. j a v a 2 s. c o m buildResourceNameToIdMap(filesystem, rDotJavaSrcDir.resolve("R.txt"), resourceNameToIdMap); } catch (IOException e) { context.logError(e, "Failure parsing R.txt file."); return 1; } ImmutableMultimap<String, Path> filesByLocale = groupFilesByLocale(filteredStringFiles); Map<String, StringResources> resourcesByLocale = Maps.newHashMap(); for (String locale : filesByLocale.keySet()) { try { resourcesByLocale.put(locale, compileStringFiles(filesystem, filesByLocale.get(locale))); } catch (IOException e) { context.logError(e, "Error parsing string file for locale: %s", locale); return 1; } } // Merge region specific locale resources with the corresponding base locale resources. // // For example, if there are separate string resources in an android project for locale // "es" and "es_US", when an application running on a device with locale set to "Spanish // (United States)" requests for a string, the Android runtime first looks for the string in // "es_US" set of resources, and if not found, returns the resource from the "es" set. // We merge these because we want the individual string json files to be self contained for // simplicity. for (String regionSpecificLocale : regionSpecificToBaseLocaleMap.keySet()) { String baseLocale = regionSpecificToBaseLocaleMap.get(regionSpecificLocale); if (!resourcesByLocale.containsKey(baseLocale)) { continue; } resourcesByLocale.put(regionSpecificLocale, resourcesByLocale.get(regionSpecificLocale) .getMergedResources(resourcesByLocale.get(baseLocale))); } for (String locale : filesByLocale.keySet()) { try { filesystem.writeBytesToPath(resourcesByLocale.get(locale).getBinaryFileContent(), destinationDir.resolve(locale + ".fbstr")); } catch (IOException e) { context.logError(e, "Error creating binary file for locale: %s", locale); return 1; } } return 0; }
From source file:com.facebook.buck.android.apkmodule.APKModuleGraph.java
private void verifyNoSharedSeeds() { ImmutableMultimap<BuildTarget, String> sharedSeeds = sharedSeedsSupplier.get(); if (!sharedSeeds.isEmpty()) { StringBuilder errorMessage = new StringBuilder(); for (BuildTarget seed : sharedSeeds.keySet()) { errorMessage.append("BuildTarget: ").append(seed).append(" is used as seed in multiple modules: "); for (String module : sharedSeeds.get(seed)) { errorMessage.append(module).append(' '); }/*from w w w . j ava2 s . c o m*/ errorMessage.append('\n'); } throw new IllegalArgumentException(errorMessage.toString()); } }