Source:
private void populateSummaryStatisticsFromResponses( List<FeedbackResponseAttributes> responses, Map<String, Double> min, Map<String, Double> max, Map<String, Double> average, Map<String, Double> averageExcludingSelf, Map<String, Double> total, Map<String, Double> totalExcludingSelf, Map<String, Integer> numResponses, Map<String, Integer> numResponsesExcludingSelf) { for (FeedbackResponseAttributes response : responses) { FeedbackNumericalScaleResponseDetails responseDetails = (FeedbackNumericalScaleResponseDetails) response.getResponseDetails(); double answer = responseDetails.getAnswer(); String giverEmail = response.giver; String recipientEmail = response.recipient; numResponses.put(recipientEmail, numResponses.getOrDefault(recipientEmail, 0) + 1); numResponsesExcludingSelf.putIfAbsent(recipientEmail, 0); boolean isSelfResponse = giverEmail.equalsIgnoreCase(recipientEmail); if (!isSelfResponse) { numResponsesExcludingSelf.put(recipientEmail, numResponsesExcludingSelf.get(recipientEmail) + 1); } min.put(recipientEmail, Math.min(answer, min.getOrDefault(recipientEmail, answer))); max.put(recipientEmail, Math.max(answer, max.getOrDefault(recipientEmail, answer))); total.put(recipientEmail, total.getOrDefault(recipientEmail, 0.0) + answer); totalExcludingSelf.putIfAbsent(recipientEmail, null); if (!isSelfResponse) { Double totalScoreExcludingSelf = totalExcludingSelf.get(recipientEmail); totalExcludingSelf.put(recipientEmail, totalScoreExcludingSelf == null ? answer : totalScoreExcludingSelf + answer); } average.put(recipientEmail, total.get(recipientEmail) / numResponses.get(recipientEmail)); averageExcludingSelf.putIfAbsent(recipientEmail, null); if (!isSelfResponse && totalExcludingSelf.get(recipientEmail) != null) { averageExcludingSelf.put(recipientEmail, totalExcludingSelf.get(recipientEmail) / numResponsesExcludingSelf.get(recipientEmail)); } } }

Target:
private void populateSummaryStatisticsFromResponses( List<FeedbackResponseAttributes> responses, Map<String, Double> min, Map<String, Double> max, Map<String, Double> average, Map<String, Double> averageExcludingSelf, Map<String, Double> total, Map<String, Double> totalExcludingSelf, Map<String, Integer> numResponses, Map<String, Integer> numResponsesExcludingSelf) { for (FeedbackResponseAttributes response : responses) { FeedbackNumericalScaleResponseDetails responseDetails = (FeedbackNumericalScaleResponseDetails) response.getResponseDetails(); double answer = responseDetails.getAnswer(); String giverEmail = response.giver; String recipientEmail = response.recipient; int numOfResponses = numResponses.getOrDefault(recipientEmail, 0) + 1; numResponses.put(recipientEmail, numOfResponses); numResponsesExcludingSelf.putIfAbsent(recipientEmail, 0); boolean isSelfResponse = giverEmail.equalsIgnoreCase(recipientEmail); if (!isSelfResponse) { int numOfResponsesExcludingSelf = numResponsesExcludingSelf.get(recipientEmail) + 1; numResponsesExcludingSelf.put(recipientEmail, numOfResponsesExcludingSelf); } double minScoreReceived = Math.min(answer, min.getOrDefault(recipientEmail, answer)); min.put(recipientEmail, minScoreReceived); double maxScoreReceived = Math.max(answer, max.getOrDefault(recipientEmail, answer)); max.put(recipientEmail, maxScoreReceived); double totalScore = total.getOrDefault(recipientEmail, 0.0) + answer; total.put(recipientEmail, totalScore); totalExcludingSelf.putIfAbsent(recipientEmail, null); if (!isSelfResponse) { Double totalScoreExcludingSelf = totalExcludingSelf.get(recipientEmail); totalExcludingSelf.put(recipientEmail, totalScoreExcludingSelf == null ? answer : totalScoreExcludingSelf + answer); } double averageReceived = total.get(recipientEmail) / numResponses.get(recipientEmail); average.put(recipientEmail, averageReceived); averageExcludingSelf.putIfAbsent(recipientEmail, null); if (!isSelfResponse && totalExcludingSelf.get(recipientEmail) != null) { double averageReceivedExcludingSelf = totalExcludingSelf.get(recipientEmail) / numResponsesExcludingSelf.get(recipientEmail); averageExcludingSelf.put(recipientEmail, averageReceivedExcludingSelf); } } }