// 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/FrontPageMarshaller.java
// public class FrontPageMarshaller {
// 
//     public static List<Story> marshall(JSONArray rawStories) {
//         List<Story> frontPageStories = new ArrayList<>();
// 
//         for (int i = 0; i < rawStories.length(); i++) {
//             try {
//                 frontPageStories.add(StoryMarshaller.marshall(rawStories.getJSONObject(i)));
//             } catch (Exception e) {
//                 e.printStackTrace();
//             }
//         }
// 
//         return frontPageStories;
//     }
// }
// 
// Path: app/src/main/java/com/hexforhn/hex/net/hexapi/util/RetryPolicyFactory.java
// public class RetryPolicyFactory {
//     private static final int SOCKET_TIMEOUT_MS = 2500;
//     private static final int MAX_RETRIES = 3;
//     private static final int BACKOFF_MULTIPLIER = 2;
// 
//     public static RetryPolicy build() {
//         return new DefaultRetryPolicy(SOCKET_TIMEOUT_MS, MAX_RETRIES, BACKOFF_MULTIPLIER);
//     }
// }


import com.android.volley.RequestQueue;
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.RequestFuture;
import com.hexforhn.hex.model.Story;
import com.hexforhn.hex.net.hexapi.marshall.FrontPageMarshaller;
import com.hexforhn.hex.net.hexapi.util.RetryPolicyFactory;
import org.json.JSONArray;
import java.util.List;
package com.hexforhn.hex.net.hexapi;




public class StoryCollectionService {

    private final RequestQueue mRequestQueue;
    private final String mApiBaseUrl;

    public enum Collection {
        Top, New, Ask, Show, Jobs
    }

    public StoryCollectionService(RequestQueue requestQueue, String apiBaseUrl) {
        mRequestQueue = requestQueue;
        mApiBaseUrl = apiBaseUrl;
    }

    public List<Story> getStories(Collection collection) {
        String apiUrl = getUrlForCollection(collection);

        RequestFuture<JSONArray> future = RequestFuture.newFuture();
        JsonArrayRequest request = new JsonArrayRequest(mApiBaseUrl + apiUrl, future, future);
        request.setRetryPolicy(RetryPolicyFactory.build());

        mRequestQueue.add(request);

        try {
            JSONArray response = future.get();
// 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/FrontPageMarshaller.java
// public class FrontPageMarshaller {
// 
//     public static List<Story> marshall(JSONArray rawStories) {
//         List<Story> frontPageStories = new ArrayList<>();
// 
//         for (int i = 0; i < rawStories.length(); i++) {
//             try {
//                 frontPageStories.add(StoryMarshaller.marshall(rawStories.getJSONObject(i)));
//             } catch (Exception e) {
//                 e.printStackTrace();
//             }
//         }
// 
//         return frontPageStories;
//     }
// }
// 
// Path: app/src/main/java/com/hexforhn/hex/net/hexapi/util/RetryPolicyFactory.java
// public class RetryPolicyFactory {
//     private static final int SOCKET_TIMEOUT_MS = 2500;
//     private static final int MAX_RETRIES = 3;
//     private static final int BACKOFF_MULTIPLIER = 2;
// 
//     public static RetryPolicy build() {
//         return new DefaultRetryPolicy(SOCKET_TIMEOUT_MS, MAX_RETRIES, BACKOFF_MULTIPLIER);
//     }
// }


// Path: app/src/main/java/com/hexforhn/hex/net/hexapi/StoryCollectionService.java
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.RequestFuture;
import com.hexforhn.hex.model.Story;
import com.hexforhn.hex.net.hexapi.marshall.FrontPageMarshaller;
import com.hexforhn.hex.net.hexapi.util.RetryPolicyFactory;
import org.json.JSONArray;
import java.util.List;

package com.hexforhn.hex.net.hexapi;




public class StoryCollectionService {

    private final RequestQueue mRequestQueue;
    private final String mApiBaseUrl;

    public enum Collection {
        Top, New, Ask, Show, Jobs
    }

    public StoryCollectionService(RequestQueue requestQueue, String apiBaseUrl) {
        mRequestQueue = requestQueue;
        mApiBaseUrl = apiBaseUrl;
    }

    public List<Story> getStories(Collection collection) {
        String apiUrl = getUrlForCollection(collection);

        RequestFuture<JSONArray> future = RequestFuture.newFuture();
        JsonArrayRequest request = new JsonArrayRequest(mApiBaseUrl + apiUrl, future, future);
        request.setRetryPolicy(RetryPolicyFactory.build());

        mRequestQueue.add(request);

        try {
            JSONArray response = future.get();
            return FrontPageMarshaller.marshall(response);