Source:
private List<ResponseOutput> buildResponses( List<FeedbackResponseAttributes> responses, FeedbackSessionResultsBundle bundle) { Map<String, List<FeedbackResponseAttributes>> responsesMap = new HashMap<>(); for (FeedbackResponseAttributes response : responses) { responsesMap.computeIfAbsent(response.recipient, k -> new ArrayList<>()).add(response); } List<ResponseOutput> output = new ArrayList<>(); responsesMap.forEach((recipient, responsesForRecipient) -> { String recipientName = removeAnonymousHash(bundle.getNameForEmail(recipient)); String recipientTeam = bundle.getTeamNameForEmail(recipient); for (FeedbackResponseAttributes response : responsesForRecipient) { String giverName = removeAnonymousHash(bundle.getGiverNameForResponse(response)); String giverEmail = bundle.getDisplayableEmailGiver(response); String recipientEmail = bundle.getDisplayableEmailRecipient(response); Map<String, Set<String>> teamNameToMembersEmailTable = bundle.rosterTeamNameMembersTable; String relatedGiverEmail = teamNameToMembersEmailTable.containsKey(response.giver) ? teamNameToMembersEmailTable.get(response.giver).iterator().next() : response.giver; String giverTeam = bundle.getTeamNameForEmail(response.giver); List<FeedbackResponseCommentAttributes> feedbackResponseComments = bundle.getResponseComments().getOrDefault(response.getId(), Collections.emptyList()); Queue<CommentOutput> comments = buildComments(feedbackResponseComments, bundle); output.add(new ResponseOutput(response.getId(), giverName, giverTeam, giverEmail, relatedGiverEmail, response.giverSection, recipientName, recipientTeam, recipientEmail, response.recipientSection, response.responseDetails, comments.poll(), new ArrayList<>(comments))); } }); return output; }

Target:
private List<ResponseOutput> buildResponses( List<FeedbackResponseAttributes> responses, FeedbackSessionResultsBundle bundle) { Map<String, List<FeedbackResponseAttributes>> responsesMap = new HashMap<>(); for (FeedbackResponseAttributes response : responses) { responsesMap.computeIfAbsent(response.recipient, k -> new ArrayList<>()).add(response); } List<ResponseOutput> output = new ArrayList<>(); responsesMap.forEach((recipient, responsesForRecipient) -> { String recipientName = removeAnonymousHash(bundle.getNameForEmail(recipient)); String recipientTeam = bundle.getTeamNameForEmail(recipient); for (FeedbackResponseAttributes response : responsesForRecipient) { String giverName = removeAnonymousHash(bundle.getGiverNameForResponse(response)); String giverEmail = bundle.isGiverVisible(response) ? (bundle.rosterTeamNameMembersTable.containsKey(response.giver) ? null : response.giver) : null; String recipientEmail = bundle.isRecipientVisible(response) ? (bundle.rosterTeamNameMembersTable.containsKey(response.recipient) ? null : response.recipient) : null; Map<String, Set<String>> teamNameToMembersEmailTable = bundle.rosterTeamNameMembersTable; String relatedGiverEmail = teamNameToMembersEmailTable.containsKey(response.giver) ? teamNameToMembersEmailTable.get(response.giver).iterator().next() : response.giver; String giverTeam = bundle.getTeamNameForEmail(response.giver); List<FeedbackResponseCommentAttributes> feedbackResponseComments = bundle.getResponseComments().getOrDefault(response.getId(), Collections.emptyList()); Queue<CommentOutput> comments = buildComments(feedbackResponseComments, bundle); output.add(new ResponseOutput(response.getId(), giverName, giverTeam, giverEmail, relatedGiverEmail, response.giverSection, recipientName, recipientTeam, recipientEmail, response.recipientSection, response.responseDetails, comments.poll(), new ArrayList<>(comments))); } }); return output; }