List of usage examples for com.google.common.collect Multimap asMap
Map<K, Collection<V>> asMap();
From source file:com.google.devrel.gmscore.tools.apk.arsc.ArscDumper.java
private void dumpEntries(Writer writer, Multimap<ResourceEntry, TypeChunk.Entry> entries) throws IOException { collector.compute();/*from w w w . j a v a 2 s. co m*/ try (AutoCloseableCsvWriter csvWriter = new AutoCloseableCsvWriter(writer)) { csvWriter.writeNext(ENTRIES_COLUMNS); for (Entry<ResourceEntry, Collection<TypeChunk.Entry>> entry : entries.asMap().entrySet()) { csvWriter.writeNext(dumpEntry(entry, collector.getStats(entry.getKey()))); } } }
From source file:com.foundationdb.server.types.service.ResolvablesRegistry.java
private static <R extends TOverload, V extends TValidatedOverload> ListMultimap<String, ScalarsGroup<V>> createScalars( InstanceFinder finder, TCastResolver castResolver, Class<R> plainClass, Function<R, V> validator) { Multimap<String, V> overloadsByName = ArrayListMultimap.create(); int errors = 0; for (R scalar : finder.find(plainClass)) { try {// www .j a v a2 s . com V validated = validator.apply(scalar); String[] names = validated.registeredNames(); for (int i = 0; i < names.length; ++i) names[i] = names[i].toLowerCase(); for (String name : names) overloadsByName.put(name, validated); } catch (RuntimeException e) { rejectTOverload(scalar, e); ++errors; } catch (AssertionError e) { rejectTOverload(scalar, e); ++errors; } } if (errors > 0) { StringBuilder sb = new StringBuilder("Found ").append(errors).append(" error"); if (errors != 1) sb.append('s'); sb.append(" while collecting scalar functions. Check logs for details."); throw new AkibanInternalException(sb.toString()); } ArrayListMultimap<String, ScalarsGroup<V>> results = ArrayListMultimap.create(); for (Map.Entry<String, Collection<V>> entry : overloadsByName.asMap().entrySet()) { String overloadName = entry.getKey(); Collection<V> allOverloads = entry.getValue(); for (Collection<V> priorityGroup : scalarsByPriority(allOverloads)) { ScalarsGroup<V> scalarsGroup = new ScalarsGroupImpl<>(priorityGroup, castResolver); results.put(overloadName, scalarsGroup); } } results.trimToSize(); return Multimaps.unmodifiableListMultimap(results); }
From source file:org.sonar.server.computation.task.projectanalysis.step.QualityGateMeasuresStep.java
private void updateMeasures(Component project, Set<Condition> conditions, QualityGateDetailsDataBuilder builder) { Multimap<Metric, Condition> conditionsPerMetric = conditions.stream() .collect(MoreCollectors.index(Condition::getMetric, java.util.function.Function.identity())); for (Map.Entry<Metric, Collection<Condition>> entry : conditionsPerMetric.asMap().entrySet()) { Metric metric = entry.getKey();/*from ww w . j a v a2s. c om*/ Optional<Measure> measure = measureRepository.getRawMeasure(project, metric); if (!measure.isPresent()) { continue; } MetricEvaluationResult metricEvaluationResult = evaluateQualityGate(measure.get(), entry.getValue()); String text = evaluationResultTextConverter.asText(metricEvaluationResult.condition, metricEvaluationResult.evaluationResult); builder.addLabel(text); Measure updatedMeasure = Measure.updatedMeasureBuilder(measure.get()) .setQualityGateStatus( new QualityGateStatus(metricEvaluationResult.evaluationResult.getLevel(), text)) .create(); measureRepository.update(project, metric, updatedMeasure); builder.addEvaluatedCondition(metricEvaluationResult); } }
From source file:com.android.example.leanback.fastlane.LeanbackBrowseFragment.java
public void init(Multimap<String, Gde> gdeProducts) { mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); setAdapter(mRowsAdapter);//from w w w. j av a2 s.co m setBrandColor(getResources().getColor(R.color.primary)); setBadgeDrawable(getResources().getDrawable(R.drawable.filmi)); int position = 0; Set<Map.Entry<String, Collection<Gde>>> entries = gdeProducts.asMap().entrySet(); for (Map.Entry<String, Collection<Gde>> entry : entries) { HeaderItem headerItem = new HeaderItem(position++, entry.getKey(), null); mRowsAdapter.add(new ListRow(headerItem, new GdeObjectAdapter(new CardPresenter(), entry.getValue()))); } setOnItemViewClickedListener(getDefaultItemViewClickedListener()); setOnItemViewSelectedListener(getDefaultItemSelectedListener()); bgHelper = new BackgroundHelper(getActivity()); bgHelper.prepareBackgroundManager(); }
From source file:dmg.cells.services.CoreRoutingManager.java
private void println(PrintWriter pw, Multimap<String, String> map) { for (Map.Entry<String, Collection<String>> e : map.asMap().entrySet()) { pw.append(" ").append(e.getKey()).append(" : ").println(e.getValue()); }//from ww w . ja va 2s. com }
From source file:com.wasteofplastic.askyblock.ASkyBlockAPI.java
/** * Get a copy of the ownership map of islands * @return Hashmap of owned islands with owner UUID as a key *//*from w w w . j a v a 2s . c om*/ public Map<UUID, Collection<Island>> getOwnedIslands() { //System.out.println("DEBUG: getOwnedIslands"); if (plugin.getGrid() != null) { Map<UUID, Collection<Island>> islands = plugin.getGrid().getOwnedIslands(); if (islands != null) { //plugin.getLogger().info("DEBUG: getOwnedIslands is not null"); return islands; } //plugin.getLogger().info("DEBUG: getOwnedIslands is null"); } Multimap<UUID, Island> newIslandMap = HashMultimap.create(); return newIslandMap.asMap(); }
From source file:com.gdn.x.ui.controller.CommonController.java
protected Map<String, List<String>> saveMultiMaptoMongo(Multimap<String, String> fileUpload, String fileName) { Map<String, List<String>> goldenListParameter = new HashMap<String, List<String>>(); DBObject eachObject = new BasicDBObject(); String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new java.util.Date()); for (Map.Entry<String, Collection<String>> entry : fileUpload.asMap().entrySet()) { List<String> value = new ArrayList<String>(); String key = ""; if (!entry.getKey().equalsIgnoreCase("QUERY")) { ContentGoldenList document = new ContentGoldenList(); key = entry.getKey();//from w ww.j a v a2s. c o m value.addAll(entry.getValue()); document.setQuery(entry.getKey()); document.setExpectedResult((List<String>) entry.getValue()); document.setTimeStamp(timeStamp); document_file.setFileName(fileName); document_file.setTimeStamp(timeStamp); contentGoldenListService.insert(document); } goldenListParameter.put(key, value); } fileGoldenListService.insert(document_file); return goldenListParameter; }
From source file:com.qcadoo.mes.deviationCausesReporting.print.DeviationsProtocolPdf.java
private VerticalLayout createDetailedSummarySection(final DeviationsReportCriteria criteria, final Locale locale) { Multimap<String, DeviationSummary> summariesByType = deviationSummariesDataProvider .getDeviationsByCauseType(criteria); if (summariesByType.isEmpty()) { return VerticalLayout.empty(); }//from www. j ava2s. co m Map<String, PdfPTable> deviationCausesWithSummary = Maps.transformValues(summariesByType.asMap(), getSummariesToTableConverter(locale)); List<VerticalLayout> causeAndSummaryLayouts = FluentIterable.from(deviationCausesWithSummary.entrySet()) .transform(CAUSE_AND_SUMMARY_TABLE_IN_VERTICAL_LAYOUT).toList(); VerticalLayout tables = Fold.fold(causeAndSummaryLayouts, VerticalLayout.create(), VerticalLayout.REDUCE_BY_MERGE); Paragraph header = Headers .big(translate("deviationCausesReporting.report.deviationDetailsByType.header", locale)); return VerticalLayout.create().append(header).merge(tables); }
From source file:io.druid.indexing.common.TaskToolbox.java
public void pushSegments(Iterable<DataSegment> segments) throws IOException { // Request segment pushes for each set final Multimap<Interval, DataSegment> segmentMultimap = Multimaps.index(segments, new Function<DataSegment, Interval>() { @Override/*from w w w . j a v a 2 s. com*/ public Interval apply(DataSegment segment) { return segment.getInterval(); } }); for (final Collection<DataSegment> segmentCollection : segmentMultimap.asMap().values()) { getTaskActionClient().submit(new SegmentInsertAction(ImmutableSet.copyOf(segmentCollection))); } }
From source file:org.tomitribe.beryllium.mocks.CallsSteps.java
@Given("^The call to external service should be:$") public void theCallToExternalServiceShouldBe(final DataTable data) throws Throwable { final Multimap<Call, Call> calls = Multimaps.index(data.asList(Call.class), new com.google.common.base.Function<Call, Call>() { @Override// ww w .j a va 2 s . c o m public Call apply(Call call) { return new Call(call.getMethod(), call.getUrl(), -1, null); } }); for (final Map.Entry<Call, Collection<Call>> groupedCalls : calls.asMap().entrySet()) { final List<Action> actions = new ArrayList<>(groupedCalls.getValue().size()); for (Call call : groupedCalls.getValue()) { actions.add(composite(status(HttpStatus.getHttpStatus(call.getStatusCode())), resourceContent(Thread .currentThread().getContextClassLoader().getResource("fixtures/" + call.getFilename())))); } final Call key = groupedCalls.getKey(); stubHttp.match(key.getHttpMethod(), key.buildQueryParams()).then(sequential(actions)); } }