Skip to content

Commit

Permalink
added AbstractEvent to the GithubEvent inheritance chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomis committed Jan 21, 2015
1 parent f9d4cf3 commit b6060b1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*
* @author Frank van Heeswijk
*/
@JsonTypeInfo(use = Id.CUSTOM, property = "type", include = As.PROPERTY)
@JsonTypeIdResolver(MessageTypeIdResolver.class)
public abstract class AnySetterJSONObject {
@JsonAnySetter
protected void anySetter(final String name, final Object value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.skiwi.githubhooksechatservice.events.github;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver;
import com.skiwi.githubhooksechatservice.events.AnySetterJSONObject;
import com.skiwi.githubhooksechatservice.jackson.MessageTypeIdResolver;

@JsonTypeInfo(use = Id.CUSTOM, property = "type", include = As.PROPERTY)
@JsonTypeIdResolver(MessageTypeIdResolver.class)
public class AbstractEvent extends AnySetterJSONObject {

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.skiwi.githubhooksechatservice.events.github;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.skiwi.githubhooksechatservice.events.AnySetterJSONObject;
import com.skiwi.githubhooksechatservice.events.github.classes.Organization;
import com.skiwi.githubhooksechatservice.events.github.classes.Repository;

public abstract class GithubEvent extends AnySetterJSONObject {
public abstract class GithubEvent extends AbstractEvent {

@JsonProperty
protected Repository repository;
Expand All @@ -20,6 +19,9 @@ public final Repository getRepository() {
public final Organization getOrganization() {
return organization;
}


public void setRepo(Repository repository) {
this.repository = repository;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,20 @@
import java.net.URL;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.skiwi.githubhooksechatservice.events.AnySetterJSONObject;
import com.skiwi.githubhooksechatservice.events.github.AbstractEvent;

public class GithubUtils {



public AnySetterJSONObject[] data(String name, String repository) {
public AbstractEvent[] data(String name, String repository) {
ObjectMapper mapper = new ObjectMapper(); // just need one
try {
URL url = new URL("https://api.github.com/repos/" + name + "/" + repository + "/events");
AnySetterJSONObject[] data = mapper.readValue(url, AnySetterJSONObject[].class);
AbstractEvent[] data = mapper.readValue(url, AbstractEvent[].class);
return data;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}



}

0 comments on commit b6060b1

Please sign in to comment.