/** * Parses GitHub JsonObject in accordance to the API * @param contributor Represent project contribution: https://developer.github.com/v3/repos/#list-contributors and * @param user Represent user: https://developer.github.com/v3/users/#get-a-single-user * @return Contributor object based on project contribution and user */ public static ProjectContributor toContributor(JsonObject contributor, JsonObject user) { String name = user.getString("name"); String login = user.getString("login"); String profileUrl = contributor.getString("html_url"); Integer numberOfContributors = contributor.getInteger("contributions"); return new DefaultProjectContributor(textOrEmpty(name), login, profileUrl, numberOfContributors); }
/** * Parses GitHub JsonObject in accordance to the API * @param contributor Represent project contribution: https://developer.github.com/v3/repos/#list-contributors and * @param user Represent user: https://developer.github.com/v3/users/#get-a-single-user * @return Contributor object based on project contribution and user */ public static ProjectContributor toContributor(JsonObject contributor, JsonObject user) { String name = user.getString("name"); String login = user.getString("login"); String profileUrl = contributor.getString("html_url"); Integer numberOfContributors = contributor.getInteger("contributions"); return new DefaultProjectContributor(textOrEmpty(name), login, profileUrl, numberOfContributors); }
/** * Parses GitHub JsonObject in accordance to the API * @param contributor Represent project contribution: https://developer.github.com/v3/repos/#list-contributors and * @param user Represent user: https://developer.github.com/v3/users/#get-a-single-user * @return Contributor object based on project contribution and user */ public static ProjectContributor toContributor(JsonObject contributor, JsonObject user) { String name = user.getString("name"); String login = user.getString("login"); String profileUrl = contributor.getString("html_url"); Integer numberOfContributors = contributor.getInteger("contributions"); return new DefaultProjectContributor(textOrEmpty(name), login, profileUrl, numberOfContributors); }
public ProjectContributorsSet deserialize(String json) { ProjectContributorsSet set = new DefaultProjectContributorsSet(); try { LOG.debug("Deserialize project contributors from: {}", json); JsonArray array = (JsonArray) Jsoner.deserialize(json); for (Object object : array) { JsonObject jsonObject = (JsonObject) object; String name = jsonObject.getString("name"); String login = jsonObject.getString("login"); String profileUrl = jsonObject.getString("profileUrl"); Integer numberOfContributions = jsonObject.getInteger("numberOfContributions"); set.addContributor(new DefaultProjectContributor(name, login, profileUrl, numberOfContributions)); } } catch (Exception e) { throw new RuntimeException("Can't deserialize JSON: " + json, e); } return set; } }
public ProjectContributorsSet deserialize(String json) { ProjectContributorsSet set = new DefaultProjectContributorsSet(); try { LOG.debug("Deserialize project contributors from: {}", json); JsonArray array = (JsonArray) Jsoner.deserialize(json); for (Object object : array) { JsonObject jsonObject = (JsonObject) object; String name = jsonObject.getString("name"); String login = jsonObject.getString("login"); String profileUrl = jsonObject.getString("profileUrl"); Integer numberOfContributions = jsonObject.getInteger("numberOfContributions"); set.addContributor(new DefaultProjectContributor(name, login, profileUrl, numberOfContributions)); } } catch (Exception e) { throw new RuntimeException("Can't deserialize JSON: " + json, e); } return set; } }
public ProjectContributorsSet deserialize(String json) { ProjectContributorsSet set = new DefaultProjectContributorsSet(); try { LOG.info("Deserialize project contributors from: {}", json); JsonArray array = (JsonArray) Jsoner.deserialize(json); for (Object object : array) { JsonObject jsonObject = (JsonObject) object; String name = jsonObject.getString("name"); String login = jsonObject.getString("login"); String profileUrl = jsonObject.getString("profileUrl"); Integer numberOfContributions = jsonObject.getInteger("numberOfContributions"); set.addContributor(new DefaultProjectContributor(name, login, profileUrl, numberOfContributions)); } } catch (Exception e) { throw new RuntimeException("Can't deserialize JSON: " + json, e); } return set; } }
public static PullRequest toPullRequest(JsonObject pullRequest) { JsonObject head = (JsonObject) pullRequest.get("head"); String url = pullRequest.getString("url"); int prNumber = pullRequest.getInteger("number"); PullRequest openPullRequest = new PullRequest(); openPullRequest.setRef(head.getString("ref")); openPullRequest.setSha(head.getString("sha")); openPullRequest.setNumber(prNumber); openPullRequest.setUrl(url); return openPullRequest; }
public static PullRequest toPullRequest(JsonObject pullRequest) { JsonObject head = (JsonObject) pullRequest.get("head"); String url = pullRequest.getString("url"); int prNumber = pullRequest.getInteger("number"); PullRequest openPullRequest = new PullRequest(); openPullRequest.setRef(head.getString("ref")); openPullRequest.setSha(head.getString("sha")); openPullRequest.setNumber(prNumber); openPullRequest.setUrl(url); return openPullRequest; }