Created
August 20, 2015 02:35
-
-
Save Vannevelj/355330cccd3aa5dc193f to your computer and use it in GitHub Desktop.
Reddit json response POJO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JsonIgnoreProperties(ignoreUnknown = true) | |
public class JsonModel<T> { | |
@JsonProperty("data") | |
private Data<T> data; | |
@JsonProperty("kind") | |
private String kind; | |
public Data<T> getData() { | |
return data; | |
} | |
public String getKind() { | |
return kind; | |
} | |
} | |
@JsonIgnoreProperties(ignoreUnknown = true) | |
public class Data<T> { | |
@JsonProperty("modhash") | |
private String modHash; | |
@JsonProperty("children") | |
private ArrayList<Child<T>> children; | |
public String getModHash() { | |
return modHash; | |
} | |
public List<T> getChildren() { | |
List<T> flattenedList = new ArrayList<>(); | |
for(Child<T> child : children){ | |
flattenedList.add(child.getData()); | |
} | |
return flattenedList; | |
} | |
} | |
@JsonIgnoreProperties(ignoreUnknown = true) | |
public class Child<T> { | |
@JsonProperty("kind") | |
private String kind; | |
@JsonProperty("data") | |
private T data; | |
public String getKind() { | |
return kind; | |
} | |
public T getData() { | |
return data; | |
} | |
} | |
@JsonIgnoreProperties(ignoreUnknown = true) | |
public class Subreddit { | |
@JsonProperty("banner_img") | |
private String bannerImage; | |
@JsonProperty("id") | |
private String id; | |
@JsonProperty("header_img") | |
private String headerImage; | |
@JsonProperty("title") | |
private String title; | |
@JsonProperty("over18") | |
private boolean over18; | |
@JsonProperty("public_description") | |
private String description; | |
@JsonProperty("subscribers") | |
private long subscribers; | |
@JsonProperty("url") | |
private String url; | |
public String getBannerImage() { | |
return bannerImage; | |
} | |
public String getId() { | |
return id; | |
} | |
public String getHeaderImage() { | |
return headerImage; | |
} | |
public String getTitle() { | |
return title; | |
} | |
public boolean isOver18() { | |
return over18; | |
} | |
public String getDescription() { | |
return description; | |
} | |
public long getSubscribers() { | |
return subscribers; | |
} | |
public String getUrl() { | |
return url; | |
} | |
} | |
@JsonIgnoreProperties(ignoreUnknown = true) | |
public class Post { | |
@JsonProperty("domain") | |
private String domain; | |
@JsonProperty("subreddit") | |
private String subreddit; | |
@JsonProperty("id") | |
private String id; | |
@JsonProperty("gilded") | |
private int amountGilded; | |
@JsonProperty("author") | |
private String author; | |
@JsonProperty("score") | |
private int score; | |
@JsonProperty("subreddit_id") | |
private String subredditId; | |
@JsonProperty("permalink") | |
private String permalink; | |
@JsonProperty("created_utc") | |
private double createdOn; // JODATIME! | |
@JsonProperty("url") | |
private String url; | |
@JsonProperty("title") | |
private String title; | |
@JsonProperty("ups") | |
private int upvotes; | |
public String getDomain() { | |
return domain; | |
} | |
public String getSubreddit() { | |
return subreddit; | |
} | |
public String getId() { | |
return id; | |
} | |
public int getAmountGilded() { | |
return amountGilded; | |
} | |
public String getAuthor() { | |
return author; | |
} | |
public int getScore() { | |
return score; | |
} | |
public String getSubredditId() { | |
return subredditId; | |
} | |
public String getPermalink() { | |
return permalink; | |
} | |
public double getCreatedOn() { | |
return createdOn; | |
} | |
public String getUrl() { | |
return url; | |
} | |
public String getTitle() { | |
return title; | |
} | |
public int getUpvotes() { | |
return upvotes; | |
} | |
} | |
@JsonIgnoreProperties(ignoreUnknown = true) | |
public class Comment { | |
@JsonProperty("subreddit_id") | |
private String subredditId; | |
@JsonProperty("link_title") | |
private String linkTitle; | |
@JsonProperty("link_id") | |
private String linkId; | |
@JsonProperty("link_author") | |
private String linkAuthor; | |
@JsonProperty("id") | |
private String id; | |
@JsonProperty("author") | |
private String author; | |
@JsonProperty("parent_id") | |
private String parentId; | |
@JsonProperty("score") | |
private int score; | |
@JsonProperty("body") | |
private String body; | |
@JsonProperty("subreddit") | |
private String subreddit; | |
@JsonProperty("created") | |
private double createdOn; | |
@JsonProperty("link") | |
private String link; | |
@JsonProperty("ups") | |
private int upvotes; | |
public String getSubredditId() { | |
return subredditId; | |
} | |
public String getLinkTitle() { | |
return linkTitle; | |
} | |
public String getLinkId() { | |
return linkId; | |
} | |
public String getLinkAuthor() { | |
return linkAuthor; | |
} | |
public String getId() { | |
return id; | |
} | |
public String getAuthor() { | |
return author; | |
} | |
public String getParentId() { | |
return parentId; | |
} | |
public int getScore() { | |
return score; | |
} | |
public String getBody() { | |
return body; | |
} | |
public String getSubreddit() { | |
return subreddit; | |
} | |
public double getCreatedOn() { | |
return createdOn; | |
} | |
public String getLink() { | |
return link; | |
} | |
public int getUpvotes() { | |
return upvotes; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment