// Path: app/src/main/java/com/hexforhn/hex/model/Comment.java
// public class Comment {
// 
//     private final int mCommentCount;
//     private final String mText;
//     private final String mUser;
//     private final List<Comment> mChildComments;
//     private final Date mDate;
// 
//     public Comment(String text, String user, List<Comment> childComments, int commentCount,
//                    Date date) {
//         this.mText = text;
//         this.mUser = user;
//         this.mChildComments = childComments;
//         this.mCommentCount = commentCount;
//         this.mDate = date;
//     }
// 
//     public String getText(){
//         return this.mText;
//     }
// 
//     public String getUser() {
//         return this.mUser;
//     }
// 
//     public List<Comment> getChildComments() {
//         return this.mChildComments;
//     }
// 
//     public int getCommentCount() {
//         return mCommentCount;
//     }
// 
//     public Date getDate() {
//         return this.mDate;
//     }
// }
// 
// Path: app/src/main/java/com/hexforhn/hex/model/Story.java
// public class Story implements Item {
// 
//     private final String mId;
//     private final String mTitle;
//     private final String mUrl;
//     private final String mCommentsUrl;
//     private final String mUser;
//     private final String mDomain;
//     private final int mScore;
//     private final int mCommentCount;
//     private final Date mDate;
//     private final List<Comment> mComments;
// 
//     public Story(String id, String title, String url, String commentsUrl, String user, String domain,
//                  int score, int commentCount, Date date) {
//         this.mId = id;
//         this.mTitle = title;
//         this.mUrl = url;
//         this.mCommentsUrl = commentsUrl;
//         this.mUser = user;
//         this.mDomain = domain;
//         this.mScore = score;
//         this.mCommentCount = commentCount;
//         this.mDate = date;
//         this.mComments = new ArrayList<>();
//     }
// 
//     public Story(String id, String title, String url, String commentsUrl, String user, String domain,
//                  int score, int commentCount, Date date, List<Comment> comments) {
//         this.mId = id;
//         this.mTitle = title;
//         this.mUrl = url;
//         this.mCommentsUrl = commentsUrl;
//         this.mUser = user;
//         this.mDomain = domain;
//         this.mScore = score;
//         this.mCommentCount = commentCount;
//         this.mDate = date;
//         this.mComments = comments;
//     }
// 
//     public String getId() {
//         return this.mId;
//     }
// 
//     public String getTitle() {
//         return this.mTitle;
//     }
// 
//     public String getUrl() {
//         return this.mUrl;
//     }
// 
//     public String getCommentsUrl() {
//         return this.mCommentsUrl;
//     }
// 
//     public String getUser() {
//         return this.mUser;
//     }
// 
//     public String getDomain() {
//         return this.mDomain;
//     }
// 
//     public int getScore() {
//         return this.mScore;
//     }
// 
//     public int getCommentCount() {
//         return this.mCommentCount;
//     }
// 
//     public Date getDate() {
//         return this.mDate;
//     }
// 
//     public List<Comment> getComments() {
//         return this.mComments;
//     }
// }


import com.hexforhn.hex.model.Comment;
import com.hexforhn.hex.model.Story;
import org.joda.time.DateTime;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
package com.hexforhn.hex.net.hexapi.marshall;




public class StoryMarshaller {

    public static Story marshall(JSONObject rawStory) {
        try {
            String id = rawStory.getString("id");
            String title = rawStory.getString("title");
            String url = rawStory.getString("url");
            String commentsUrl = rawStory.getString("commentsUrl");
            String author = rawStory.getString("author");
            String domain = rawStory.getString("domain");
            int score = rawStory.getInt("score");
            int commentCount = rawStory.getInt("commentCount");
            Date date = new DateTime(rawStory.getString("time")).toDate();

            JSONArray rawComments = rawStory.has("comments") ? rawStory.getJSONArray("comments") : null;
            List<Comment> comments =  new ArrayList<>();
            if (rawComments != null) {
                comments = marshallComments(rawComments);
            }

// Path: app/src/main/java/com/hexforhn/hex/model/Comment.java
// public class Comment {
// 
//     private final int mCommentCount;
//     private final String mText;
//     private final String mUser;
//     private final List<Comment> mChildComments;
//     private final Date mDate;
// 
//     public Comment(String text, String user, List<Comment> childComments, int commentCount,
//                    Date date) {
//         this.mText = text;
//         this.mUser = user;
//         this.mChildComments = childComments;
//         this.mCommentCount = commentCount;
//         this.mDate = date;
//     }
// 
//     public String getText(){
//         return this.mText;
//     }
// 
//     public String getUser() {
//         return this.mUser;
//     }
// 
//     public List<Comment> getChildComments() {
//         return this.mChildComments;
//     }
// 
//     public int getCommentCount() {
//         return mCommentCount;
//     }
// 
//     public Date getDate() {
//         return this.mDate;
//     }
// }
// 
// Path: app/src/main/java/com/hexforhn/hex/model/Story.java
// public class Story implements Item {
// 
//     private final String mId;
//     private final String mTitle;
//     private final String mUrl;
//     private final String mCommentsUrl;
//     private final String mUser;
//     private final String mDomain;
//     private final int mScore;
//     private final int mCommentCount;
//     private final Date mDate;
//     private final List<Comment> mComments;
// 
//     public Story(String id, String title, String url, String commentsUrl, String user, String domain,
//                  int score, int commentCount, Date date) {
//         this.mId = id;
//         this.mTitle = title;
//         this.mUrl = url;
//         this.mCommentsUrl = commentsUrl;
//         this.mUser = user;
//         this.mDomain = domain;
//         this.mScore = score;
//         this.mCommentCount = commentCount;
//         this.mDate = date;
//         this.mComments = new ArrayList<>();
//     }
// 
//     public Story(String id, String title, String url, String commentsUrl, String user, String domain,
//                  int score, int commentCount, Date date, List<Comment> comments) {
//         this.mId = id;
//         this.mTitle = title;
//         this.mUrl = url;
//         this.mCommentsUrl = commentsUrl;
//         this.mUser = user;
//         this.mDomain = domain;
//         this.mScore = score;
//         this.mCommentCount = commentCount;
//         this.mDate = date;
//         this.mComments = comments;
//     }
// 
//     public String getId() {
//         return this.mId;
//     }
// 
//     public String getTitle() {
//         return this.mTitle;
//     }
// 
//     public String getUrl() {
//         return this.mUrl;
//     }
// 
//     public String getCommentsUrl() {
//         return this.mCommentsUrl;
//     }
// 
//     public String getUser() {
//         return this.mUser;
//     }
// 
//     public String getDomain() {
//         return this.mDomain;
//     }
// 
//     public int getScore() {
//         return this.mScore;
//     }
// 
//     public int getCommentCount() {
//         return this.mCommentCount;
//     }
// 
//     public Date getDate() {
//         return this.mDate;
//     }
// 
//     public List<Comment> getComments() {
//         return this.mComments;
//     }
// }


// Path: app/src/main/java/com/hexforhn/hex/net/hexapi/marshall/StoryMarshaller.java
import com.hexforhn.hex.model.Comment;
import com.hexforhn.hex.model.Story;
import org.joda.time.DateTime;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

package com.hexforhn.hex.net.hexapi.marshall;




public class StoryMarshaller {

    public static Story marshall(JSONObject rawStory) {
        try {
            String id = rawStory.getString("id");
            String title = rawStory.getString("title");
            String url = rawStory.getString("url");
            String commentsUrl = rawStory.getString("commentsUrl");
            String author = rawStory.getString("author");
            String domain = rawStory.getString("domain");
            int score = rawStory.getInt("score");
            int commentCount = rawStory.getInt("commentCount");
            Date date = new DateTime(rawStory.getString("time")).toDate();

            JSONArray rawComments = rawStory.has("comments") ? rawStory.getJSONArray("comments") : null;
            List<Comment> comments =  new ArrayList<>();
            if (rawComments != null) {
                comments = marshallComments(rawComments);
            }

            return new Story(id, title, url, commentsUrl, author, domain, score, commentCount, date, comments);