Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2012-04-05 20:02:29 -0400
committerKevin Sawicki2012-04-05 20:02:29 -0400
commit6bcc10b1dd2c86626b242e286596ec9424d7f8f1 (patch)
treea2718c7c8e9cc2f41f8bc3a8512c343a919e929f
parent9927ec62eed38dac4e84ad5a342ee29b76b1e620 (diff)
downloadegit-github-6bcc10b1dd2c86626b242e286596ec9424d7f8f1.tar.gz
egit-github-6bcc10b1dd2c86626b242e286596ec9424d7f8f1.tar.xz
egit-github-6bcc10b1dd2c86626b242e286596ec9424d7f8f1.zip
Add event types as static fields on Event class
These can be used to determine the payload class to expect to be provided by the event. Change-Id: Ided3a379ea383b44b1ed03317333375818b0aeb0
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java52
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/Event.java85
2 files changed, 120 insertions, 17 deletions
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 74a3ec12..94b12a0e 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
@@ -10,6 +10,24 @@
*******************************************************************************/
package org.eclipse.egit.github.core.client;
+import static org.eclipse.egit.github.core.event.Event.TYPE_COMMIT_COMMENT;
+import static org.eclipse.egit.github.core.event.Event.TYPE_CREATE;
+import static org.eclipse.egit.github.core.event.Event.TYPE_DELETE;
+import static org.eclipse.egit.github.core.event.Event.TYPE_DOWNLOAD;
+import static org.eclipse.egit.github.core.event.Event.TYPE_FOLLOW;
+import static org.eclipse.egit.github.core.event.Event.TYPE_FORK;
+import static org.eclipse.egit.github.core.event.Event.TYPE_FORK_APPLY;
+import static org.eclipse.egit.github.core.event.Event.TYPE_GIST;
+import static org.eclipse.egit.github.core.event.Event.TYPE_GOLLUM;
+import static org.eclipse.egit.github.core.event.Event.TYPE_ISSUES;
+import static org.eclipse.egit.github.core.event.Event.TYPE_ISSUE_COMMENT;
+import static org.eclipse.egit.github.core.event.Event.TYPE_MEMBER;
+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_PUSH;
+import static org.eclipse.egit.github.core.event.Event.TYPE_TEAM_ADD;
+import static org.eclipse.egit.github.core.event.Event.TYPE_WATCH;
+
import com.google.gson.InstanceCreator;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
@@ -50,39 +68,39 @@ public class EventFormatter {
JsonDeserializationContext context) throws JsonParseException {
String type = event.get().getType();
Class<? extends EventPayload> clazz = EventPayload.class;
- if ("CommitCommentEvent".equals(type))
+ if (TYPE_COMMIT_COMMENT.equals(type))
clazz = CommitCommentPayload.class;
- else if ("CreateEvent".equals(type))
+ else if (TYPE_CREATE.equals(type))
clazz = CreatePayload.class;
- else if ("DeleteEvent".equals(type))
+ else if (TYPE_DELETE.equals(type))
clazz = DeletePayload.class;
- else if ("DownloadEvent".equals(type))
+ else if (TYPE_DOWNLOAD.equals(type))
clazz = DownloadPayload.class;
- else if ("FollowEvent".equals(type))
+ else if (TYPE_FOLLOW.equals(type))
clazz = FollowPayload.class;
- else if ("ForkEvent".equals(type))
+ else if (TYPE_FORK.equals(type))
clazz = ForkPayload.class;
- else if ("ForkApplyEvent".equals(type))
+ else if (TYPE_FORK_APPLY.equals(type))
clazz = ForkApplyPayload.class;
- else if ("GistEvent".equals(type))
+ else if (TYPE_GIST.equals(type))
clazz = GistPayload.class;
- else if ("GollumEvent".equals(type))
+ else if (TYPE_GOLLUM.equals(type))
clazz = GollumPayload.class;
- else if ("IssueCommentEvent".equals(type))
+ else if (TYPE_ISSUE_COMMENT.equals(type))
clazz = IssueCommentPayload.class;
- else if ("IssuesEvent".equals(type))
+ else if (TYPE_ISSUES.equals(type))
clazz = IssuesPayload.class;
- else if ("MemberEvent".equals(type))
+ else if (TYPE_MEMBER.equals(type))
clazz = MemberPayload.class;
- else if ("PublicEvent".equals(type))
+ else if (TYPE_PUBLIC.equals(type))
clazz = PublicPayload.class;
- else if ("PullRequestEvent".equals(type))
+ else if (TYPE_PULL_REQUEST.equals(type))
clazz = PullRequestPayload.class;
- else if ("PushEvent".equals(type))
+ else if (TYPE_PUSH.equals(type))
clazz = PushPayload.class;
- else if ("TeamAddEvent".equals(type))
+ else if (TYPE_TEAM_ADD.equals(type))
clazz = TeamAddPayload.class;
- else if ("WatchEvent".equals(type))
+ else if (TYPE_WATCH.equals(type))
clazz = WatchPayload.class;
// payload not recognized
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 4d1904e9..1b24a12d 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
@@ -23,6 +23,91 @@ import org.eclipse.egit.github.core.util.DateUtils;
*/
public class Event implements Serializable {
+ /**
+ * Event type denoting a {@link CommitCommentPayload}
+ */
+ public static final String TYPE_COMMIT_COMMENT = "CommitCommentEvent";
+
+ /**
+ * Event type denoting a {@link CreatePayload}
+ */
+ public static final String TYPE_CREATE = "CreateEvent";
+
+ /**
+ * Event type denoting a {@link DeletePayload}
+ */
+ public static final String TYPE_DELETE = "DeleteEvent";
+
+ /**
+ * Event type denoting a {@link DownloadPayload}
+ */
+ public static final String TYPE_DOWNLOAD = "DownloadEvent";
+
+ /**
+ * Event type dneoting a {@link FollowPayload}
+ */
+ public static final String TYPE_FOLLOW = "FollowEvent";
+
+ /**
+ * Event type denoting a {@link ForkPayload}
+ */
+ public static final String TYPE_FORK = "ForkEvent";
+
+ /**
+ * Event type denoting a {@link ForkApplyPayload}
+ */
+ public static final String TYPE_FORK_APPLY = "ForkApplyEvent";
+
+ /**
+ * Event type denoting a {@link GistPayload}
+ */
+ public static final String TYPE_GIST = "GistEvent";
+
+ /**
+ * Event type denoting a {@link GollumPayload}
+ */
+ public static final String TYPE_GOLLUM = "GollumEvent";
+
+ /**
+ * Event type denoting a {@link IssueCommentPayload}
+ */
+ public static final String TYPE_ISSUE_COMMENT = "IssueCommentEvent";
+
+ /**
+ * Event type denoting a {@link IssuesPayload}
+ */
+ public static final String TYPE_ISSUES = "IssuesEvent";
+
+ /**
+ * Event type denoting a {@link MemberPayload}
+ */
+ public static final String TYPE_MEMBER = "MemberEvent";
+
+ /**
+ * Event type denoting a {@link PublicPayload}
+ */
+ public static final String TYPE_PUBLIC = "PublicEvent";
+
+ /**
+ * Event type denoting a {@link PullRequestPayload}
+ */
+ public static final String TYPE_PULL_REQUEST = "PullRequestEvent";
+
+ /**
+ * Event type denoting a {@link PushPayload}
+ */
+ public static final String TYPE_PUSH = "PushEvent";
+
+ /**
+ * Event type denoting a {@link TeamAddPayload}
+ */
+ public static final String TYPE_TEAM_ADD = "TeamAddEvent";
+
+ /**
+ * Event type denoting a {@link WatchPayload}
+ */
+ public static final String TYPE_WATCH = "WatchEvent";
+
private static final long serialVersionUID = 3633702964380402233L;
/**

Back to the top