private static TelemetryAnalyzerPerformancePayload toPayload(Map.Entry<String, TelemetryAnalyzerPerformance> entry) { TelemetryAnalyzerPerformance analyzerPerformance = entry.getValue(); String language = entry.getKey(); int analysisCount = analyzerPerformance.analysisCount(); Map<String, BigDecimal> distribution = analyzerPerformance .frequencies().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> { if (analysisCount == 0) { return BigDecimal.ZERO.setScale(2); } return BigDecimal.valueOf(100) .multiply(BigDecimal.valueOf(e.getValue())) .divide(BigDecimal.valueOf(analysisCount), 2, RoundingMode.HALF_EVEN); }, throwingMerger(), LinkedHashMap::new)); return new TelemetryAnalyzerPerformancePayload(language, distribution); }