Source:
private GenericRecord convertToPullRequestMergedGenericRecord(JsonNode event) throws IOException { GenericRecord genericRecord = null; String type = event.get("type").asText(); if ("PullRequestEvent".equals(type)) { JsonNode payload = event.get("payload"); if (payload != null) { String action = payload.get("action").asText(); JsonNode pullRequest = payload.get("pull_request"); String merged = pullRequest.get("merged").asText(); if ("closed".equals(action) && "true".equals(merged)) { JsonNode commits = null; String commitsURL = pullRequest.get("commits_url").asText(); GitHubAPICaller.GitHubAPIResponse commitsResponse = _gitHubAPICaller.callAPI(commitsURL); if (commitsResponse.responseString != null) { commits = OBJECT_MAPPER.reader().readTree(commitsResponse.responseString); } JsonNode reviewComments = null; String reviewCommentsURL = pullRequest.get("review_comments_url").asText(); GitHubAPICaller.GitHubAPIResponse reviewCommentsResponse = _gitHubAPICaller.callAPI(reviewCommentsURL); if (reviewCommentsResponse.responseString != null) { reviewComments = OBJECT_MAPPER.reader().readTree(reviewCommentsResponse.responseString); } JsonNode comments = null; String commentsURL = pullRequest.get("comments_url").asText(); GitHubAPICaller.GitHubAPIResponse commentsResponse = _gitHubAPICaller.callAPI(commentsURL); if (commentsResponse.responseString != null) { comments = OBJECT_MAPPER.reader().readTree(commentsResponse.responseString); } PullRequestMergedEvent pullRequestMergedEvent = new PullRequestMergedEvent(event, commits, reviewComments, comments); genericRecord = convertToGenericRecord(pullRequestMergedEvent); } } } return genericRecord; }

Target:
private GenericRecord convertToPullRequestMergedGenericRecord(JsonNode event) throws IOException { GenericRecord genericRecord = null; String type = event.get("type").asText(); if ("PullRequestEvent".equals(type)) { JsonNode payload = event.get("payload"); if (payload != null) { String action = payload.get("action").asText(); JsonNode pullRequest = payload.get("pull_request"); String merged = pullRequest.get("merged").asText(); if ("closed".equals(action) && "true".equals(merged)) { JsonNode commits = null; String commitsURL = pullRequest.get("commits_url").asText(); GitHubAPICaller.GitHubAPIResponse commitsResponse = _gitHubAPICaller.callAPI(commitsURL); if (commitsResponse.responseString != null) { commits = JsonUtils.stringToJsonNode(commitsResponse.responseString); } JsonNode reviewComments = null; String reviewCommentsURL = pullRequest.get("review_comments_url").asText(); GitHubAPICaller.GitHubAPIResponse reviewCommentsResponse = _gitHubAPICaller.callAPI(reviewCommentsURL); if (reviewCommentsResponse.responseString != null) { reviewComments = JsonUtils.stringToJsonNode(reviewCommentsResponse.responseString); } JsonNode comments = null; String commentsURL = pullRequest.get("comments_url").asText(); GitHubAPICaller.GitHubAPIResponse commentsResponse = _gitHubAPICaller.callAPI(commentsURL); if (commentsResponse.responseString != null) { comments = JsonUtils.stringToJsonNode(commentsResponse.responseString); } PullRequestMergedEvent pullRequestMergedEvent = new PullRequestMergedEvent(event, commits, reviewComments, comments); genericRecord = convertToGenericRecord(pullRequestMergedEvent); } } } return genericRecord; }