aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java
diff options
context:
space:
mode:
authorJonathan Brachthäuser <jonathan@b-studios.de>2015-09-03 22:37:59 +0200
committerJonathan Brachthäuser <jonathan@b-studios.de>2015-09-04 11:38:42 +0200
commit69baef38cbde57293451dc841b1b370ec0708e88 (patch)
tree62cea9821a2691ba8dae5faa7a7f3e65541de403 /src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java
parent636cb7acb982f351f36005cbb71292e1c92ff52a (diff)
downloadbbprb-69baef38cbde57293451dc841b1b370ec0708e88.tar.gz
Refactored: Only have one file for JSON POJOs
Diffstat (limited to 'src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java')
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java345
1 files changed, 345 insertions, 0 deletions
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java
new file mode 100644
index 0000000..1e8bf5c
--- /dev/null
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java
@@ -0,0 +1,345 @@
+package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket;
+
+import java.util.List;
+import java.util.Comparator;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * POJOs representing the pull-requests extracted from the
+ * JSON response of the Bitbucket API V2.
+ *
+ * @see https://confluence.atlassian.com/bitbucket/pullrequests-resource-423626332.html#pullrequestsResource-GETaspecificpullrequest
+ */
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Pullrequest {
+
+ private String description;
+ private Boolean closeSourceBranch;
+ private String title;
+ private Revision destination;
+ private String reason;
+ private String closedBy;
+ private Revision source;
+ private String state;
+ private String createdOn;
+ private String updatedOn;
+ private String mergeCommit;
+ private String id;
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Response {
+ private int pageLength;
+ private List<Pullrequest> pullrequests;
+ private int page;
+ private int size;
+
+ @JsonProperty("pagelen")
+ public int getPageLength() {
+ return pageLength;
+ }
+ @JsonProperty("pagelen")
+ public void setPageLength(int pageLength) {
+ this.pageLength = pageLength;
+ }
+ @JsonProperty("values")
+ public List<Pullrequest> getPullrequests() {
+ return pullrequests;
+ }
+ @JsonProperty("values")
+ public void setPullrequests(List<Pullrequest> pullrequests) {
+ this.pullrequests = pullrequests;
+ }
+ public int getPage() {
+ return page;
+ }
+ public void setPage(int page) {
+ this.page = page;
+ }
+ public int getSize() {
+ return size;
+ }
+ public void setSize(int size) {
+ this.size = size;
+ }
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Revision {
+ private Repository repository;
+ private Branch branch;
+ private Commit commit;
+
+ public Repository getRepository() {
+ return repository;
+ }
+ public void setRepository(Repository repository) {
+ this.repository = repository;
+ }
+ public Branch getBranch() {
+ return branch;
+ }
+ public void setBranch(Branch branch) {
+ this.branch = branch;
+ }
+ public Commit getCommit() {
+ return commit;
+ }
+ public void setCommit(Commit commit) {
+ this.commit = commit;
+ }
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Repository {
+ private String fullName;
+ private String name;
+ private String ownerName;
+ private String repositoryName;
+
+ @JsonProperty("full_name")
+ public String getFullName() {
+ return fullName;
+ }
+ @JsonProperty("full_name")
+ public void setFullName(String fullName) {
+ // Also extract owner- and reponame
+ if (name != null) {
+ this.ownerName = fullName.split("/")[0];
+ this.repositoryName = fullName.split("/")[1];
+ }
+ this.fullName = fullName;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getOwnerName() {
+ return ownerName;
+ }
+ public String getRepositoryName() {
+ return repositoryName;
+ }
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Branch {
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Commit {
+ private String hash;
+
+ public String getHash() {
+ return hash;
+ }
+
+ public void setHash(String hash) {
+ this.hash = hash;
+ }
+ }
+
+ // Was: Approval
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Participant {
+ private String role;
+ private Boolean approved;
+
+ public String getRole() {
+ return role;
+ }
+ public void setRole(String role) {
+ this.role = role;
+ }
+ public Boolean getApproved() {
+ return approved;
+ }
+ public void setApproved(Boolean approved) {
+ this.approved = approved;
+ }
+ }
+
+ // https://confluence.atlassian.com/bitbucket/pullrequests-resource-1-0-296095210.html#pullrequestsResource1.0-POSTanewcomment
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Comment implements Comparable<Comment> {
+ private Integer id;
+ private String filename;
+ private String content;
+ private String updatedOn;
+ private String createdOn;
+
+ public int compareTo(Comment target) {
+ if (this.getId() > target.getId()) {
+ return 1;
+ } else if (this.getId().equals(target.getId())) {
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+
+ @JsonProperty("comment_id")
+ public Integer getId() {
+ return id;
+ }
+
+ @JsonProperty("comment_id")
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getFilename() {
+ return filename;
+ }
+
+ public void setFilename(String filename) {
+ this.filename = filename;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+ @JsonProperty("utc_last_updated")
+ public String getUpdatedOn() {
+ return updatedOn;
+ }
+ @JsonProperty("utc_last_updated")
+ public void setUpdatedOn(String updatedOn) {
+ this.updatedOn = updatedOn;
+ }
+ @JsonProperty("utc_created_on")
+ public String getCreatedOn() {
+ return createdOn;
+ }
+ @JsonProperty("utc_created_on")
+ public void setCreatedOn(String createdOn) {
+ this.createdOn = createdOn;
+ }
+ }
+
+ //-------------------- only getters and setters follow -----------------
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @JsonProperty("close_source_branch")
+ public Boolean getCloseSourceBranch() {
+ return closeSourceBranch;
+ }
+
+ @JsonProperty("close_source_branch")
+ public void setCloseSourceBranch(Boolean closeSourceBranch) {
+ this.closeSourceBranch = closeSourceBranch;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public Revision getDestination() {
+ return destination;
+ }
+
+ public void setDestination(Revision destination) {
+ this.destination = destination;
+ }
+
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ @JsonProperty("closed_by")
+ public String getClosedBy() {
+ return closedBy;
+ }
+
+ @JsonProperty("closed_by")
+ public void setClosedBy(String closedBy) {
+ this.closedBy = closedBy;
+ }
+
+ public Revision getSource() {
+ return source;
+ }
+
+ public void setSource(Revision source) {
+ this.source = source;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ @JsonProperty("created_on")
+ public String getCreatedOn() {
+ return createdOn;
+ }
+
+ @JsonProperty("created_on")
+ public void setCreatedOn(String createdOn) {
+ this.createdOn = createdOn;
+ }
+
+ @JsonProperty("updated_on")
+ public String getUpdatedOn() {
+ return updatedOn;
+ }
+
+ @JsonProperty("updated_on")
+ public void setUpdatedOn(String updatedOn) {
+ this.updatedOn = updatedOn;
+ }
+
+ @JsonProperty("merge_commit")
+ public String getMergeCommit() {
+ return mergeCommit;
+ }
+
+ @JsonProperty("merge_commit")
+ public void setMergeCommit(String mergeCommit) {
+ this.mergeCommit = mergeCommit;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+}