diff options
-rw-r--r-- | org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/EventFormatter.java | 52 | ||||
-rw-r--r-- | org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/event/Event.java | 85 |
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; /** |