From 68012947a4e811cde2640d9ba993f74b1f8806f2 Mon Sep 17 00:00:00 2001 From: Jon Ander Peñalba Date: Wed, 2 Dec 2015 18:13:27 +0100 Subject: Add the ReleaseEvent and its corresponding Payload https://developer.github.com/v3/activity/events/types/#releaseevent Change-Id: I94832a0f2ab7a69697d839086f57ff29302fbaf7 Signed-off-by: Jon Ander Peñalba Signed-off-by: Matthias Sohn --- .../src/org/eclipse/egit/github/core/Release.java | 315 +++++++++++++++++++++ .../egit/github/core/client/EventFormatter.java | 4 + .../org/eclipse/egit/github/core/event/Event.java | 5 + .../egit/github/core/event/ReleasePayload.java | 60 ++++ 4 files changed, 384 insertions(+) create mode 100644 org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Release.java create mode 100644 org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/ReleasePayload.java diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Release.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Release.java new file mode 100644 index 00000000..8f653c1e --- /dev/null +++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Release.java @@ -0,0 +1,315 @@ +/******************************************************************************* + * Copyright (c) 2015 Jon Ander Peñalba . + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Jon Ander Peñalba - initial API and implementation + *******************************************************************************/ +package org.eclipse.egit.github.core; + +import java.io.Serializable; +import java.util.Date; + +import com.google.gson.annotations.SerializedName; + +/** + * Release model class + * @since 4.2 + */ +public class Release implements Serializable { + + private static final long serialVersionUID = 1L; + + private String url; + + private String htmlUrl; + + private String assetsUrl; + + private String uploadUrl; + + private String tarballUrl; + + private String zipballUrl; + + private long id; + + private String tagName; + + private String targetCommitish; + + private String name; + + private String body; + + @SerializedName("draft") + private boolean isDraft; + + @SerializedName("prerelease") + private boolean isPrerelease; + + private Date createdAt; + + private Date publishedAt; + + private User author; + + /** + * @return url + */ + public String getUrl() { + return url; + } + + /** + * @param url + * @return this release + */ + public Release setUrl(String url) { + this.url = url; + return this; + } + + /** + * @return htmlUrl + */ + public String getHtmlUrl() { + return htmlUrl; + } + + /** + * @param htmlUrl + * @return this release + */ + public Release setHtmlUrl(String htmlUrl) { + this.htmlUrl = htmlUrl; + return this; + } + + /** + * @return assetsUrl + */ + public String getAssetsUrl() { + return assetsUrl; + } + + /** + * @param assetsUrl + * @return this release + */ + public Release setAssetsUrl(String assetsUrl) { + this.assetsUrl = assetsUrl; + return this; + } + + /** + * @return uploadUrl + */ + public String getUploadUrl() { + return uploadUrl; + } + + /** + * @param uploadUrl + * @return this release + */ + public Release setUploadUrl(String uploadUrl) { + this.uploadUrl = uploadUrl; + return this; + } + + /** + * @return tarballUrl + */ + public String getTarballUrl() { + return tarballUrl; + } + + /** + * @param tarballUrl + * @return this release + */ + public Release setTarballUrl(String tarballUrl) { + this.tarballUrl = tarballUrl; + return this; + } + + /** + * @return zipballUrl + */ + public String getZipballUrl() { + return zipballUrl; + } + + /** + * @param zipballUrl + * @return this release + */ + public Release setZipballUrl(String zipballUrl) { + this.zipballUrl = zipballUrl; + return this; + } + + /** + * @return id + */ + public long getId() { + return id; + } + + /** + * @param id + * @return this release + */ + public Release setId(long id) { + this.id = id; + return this; + } + + /** + * @return tagName + */ + public String getTagName() { + return tagName; + } + + /** + * @param tagName + * @return this release + */ + public Release setTagName(String tagName) { + this.tagName = tagName; + return this; + } + + /** + * @return targetCommitish + */ + public String getTargetCommitish() { + return targetCommitish; + } + + /** + * @param targetCommitish + * @return this release + */ + public Release setTargetCommitish(String targetCommitish) { + this.targetCommitish = targetCommitish; + return this; + } + + /** + * @return name + */ + public String getName() { + return name; + } + + /** + * @param name + * @return this release + */ + public Release setName(String name) { + this.name = name; + return this; + } + + /** + * @return body + */ + public String getBody() { + return body; + } + + /** + * @param body + * @return this release + */ + public Release setBody(String body) { + this.body = body; + return this; + } + + /** + * @return isDraft + */ + public boolean isDraft() { + return isDraft; + } + + /** + * @param isDraft + * @return this release + */ + public Release setDraft(boolean isDraft) { + this.isDraft = isDraft; + return this; + } + + /** + * @return isPrerelease + */ + public boolean isPrerelease() { + return isPrerelease; + } + + /** + * @param isPrerelease + * @return this release + */ + public Release setPrerelease(boolean isPrerelease) { + this.isPrerelease = isPrerelease; + return this; + } + + /** + * @return createdAt + */ + public Date getCreatedAt() { + return createdAt; + } + + /** + * @param createdAt + * @return this release + */ + public Release setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * @return publishedAt + */ + public Date getPublishedAt() { + return publishedAt; + } + + /** + * @param publishedAt + * @return this release + */ + public Release setPublishedAt(Date publishedAt) { + this.publishedAt = publishedAt; + return this; + } + + /** + * @return author + */ + public User getAuthor() { + return author; + } + + /** + * @param author + * @return this release + */ + public Release setAuthor(User author) { + this.author = author; + return this; + } +} diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java index cc53bcad..7943b8ee 100644 --- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java +++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java @@ -27,6 +27,7 @@ import static org.eclipse.egit.github.core.event.Event.TYPE_PUBLIC; import static org.eclipse.egit.github.core.event.Event.TYPE_PULL_REQUEST; import static org.eclipse.egit.github.core.event.Event.TYPE_PULL_REQUEST_REVIEW_COMMENT; import static org.eclipse.egit.github.core.event.Event.TYPE_PUSH; +import static org.eclipse.egit.github.core.event.Event.TYPE_RELEASE; import static org.eclipse.egit.github.core.event.Event.TYPE_TEAM_ADD; import static org.eclipse.egit.github.core.event.Event.TYPE_WATCH; @@ -58,6 +59,7 @@ import org.eclipse.egit.github.core.event.PublicPayload; import org.eclipse.egit.github.core.event.PullRequestPayload; import org.eclipse.egit.github.core.event.PullRequestReviewCommentPayload; import org.eclipse.egit.github.core.event.PushPayload; +import org.eclipse.egit.github.core.event.ReleasePayload; import org.eclipse.egit.github.core.event.TeamAddPayload; import org.eclipse.egit.github.core.event.WatchPayload; @@ -116,6 +118,8 @@ public class EventFormatter implements JsonDeserializer { payloadClass = PullRequestReviewCommentPayload.class; else if (TYPE_PUSH.equals(type)) payloadClass = PushPayload.class; + else if (TYPE_RELEASE.equals(type)) + payloadClass = ReleasePayload.class; else if (TYPE_TEAM_ADD.equals(type)) payloadClass = TeamAddPayload.class; else if (TYPE_WATCH.equals(type)) diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/Event.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/Event.java index 4883e909..1435e4fd 100644 --- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/Event.java +++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/Event.java @@ -103,6 +103,11 @@ public class Event implements Serializable { */ public static final String TYPE_PUSH = "PushEvent"; + /** + * Event type denoting a {@link ReleasePayload} + */ + public static final String TYPE_RELEASE = "ReleaseEvent"; + /** * Event type denoting a {@link TeamAddPayload} */ diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/ReleasePayload.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/ReleasePayload.java new file mode 100644 index 00000000..b08778d8 --- /dev/null +++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/ReleasePayload.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2015 Jon Ander Peñalba . + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Jon Ander Peñalba - initial API and implementation + *******************************************************************************/ +package org.eclipse.egit.github.core.event; + +import java.io.Serializable; + +import org.eclipse.egit.github.core.Release; + +/** + * ReleaseEvent payload model class. + * @since 4.2 + */ +public class ReleasePayload extends EventPayload implements Serializable { + + private static final long serialVersionUID = 3309944674574815351L; + + private String action; + + private Release release; + + /** + * @return action + */ + public String getAction() { + return action; + } + + /** + * @param action + * @return this ReleasePayload + */ + public ReleasePayload setAction(String action) { + this.action = action; + return this; + } + + /** + * @return release + */ + public Release getRelease() { + return release; + } + + /** + * @param release + * @return this ReleasePayload + */ + public ReleasePayload setRelease(Release release) { + this.release = release; + return this; + } +} -- cgit v1.2.3 From 045a78cc165dfcee5e4450361a2282a1f69b193b Mon Sep 17 00:00:00 2001 From: Jon Ander Peñalba Date: Wed, 2 Dec 2015 18:12:32 +0100 Subject: Remove useless import Change-Id: I998f1db2173ac2036b13c44dbdc71bc77d147645 Signed-off-by: Jon Ander Peñalba --- .../src/org/eclipse/egit/github/core/Rename.java | 1 - 1 file changed, 1 deletion(-) diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Rename.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Rename.java index 80110205..5048cfae 100644 --- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Rename.java +++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Rename.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.egit.github.core; -import java.io.ObjectStreamClass; import java.io.Serializable; /** -- cgit v1.2.3