package com.setiawanpaiman.sunnyreader.data.model;

import android.support.annotation.NonNull;

import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;
import java.util.List;

public class Story {

    @SerializedName("id")
    private long mId;

    @SerializedName("time")
    private long mTimestamp;

    @SerializedName("by")
    private String mAuthor;

    @SerializedName("title")
    private String mTitle;

    @SerializedName("url")
    private String mUrl;

    @SerializedName("score")
    private long mScore;

    @SerializedName("kids")
    private List<Long> mCommentIds;

    protected Story(Builder builder) {
        mId = builder.mId;
        mTimestamp = builder.mTimestamp;
        mAuthor = builder.mAuthor;
        mTitle = builder.mTitle;
        mUrl = builder.mUrl;
        mScore = builder.mScore;
        mCommentIds = builder.mCommentIds;
    }

    public long getId() {
        return mId;
    }

    public long getTimestamp() {
        return mTimestamp;
    }

    public String getAuthor() {
        return mAuthor;
    }

    public String getTitle() {
        return mTitle;
    }

    public String getUrl() {
        return mUrl;
    }

    public long getScore() {
        return mScore;
    }

    @NonNull
    public List<Long> getCommentIds() {
        // defensive copy
        if (mCommentIds == null) return new ArrayList<>();
        else return new ArrayList<>(mCommentIds);
    }

    public static Builder newBuilder(long id) {
        return new Builder(id);
    }

    public static class Builder {
        private long mId;
        private long mTimestamp;
        private String mAuthor;
        private String mTitle;
        private String mUrl;
        private long mScore;
        private List<Long> mCommentIds;

        public Builder(long id) {
            mId = id;
            mCommentIds = new ArrayList<>();
        }

        public Builder setTimestamp(long timestamp) {
            mTimestamp = timestamp;
            return this;
        }

        public Builder setAuthor(String author) {
            mAuthor = author;
            return this;
        }

        public Builder setTitle(String title) {
            mTitle = title;
            return this;
        }

        public Builder setUrl(String url) {
            mUrl = url;
            return this;
        }

        public Builder setScore(long score) {
            mScore = score;
            return this;
        }

        public Builder setCommentIds(List<Long> commentIds) {
            mCommentIds.clear();
            if (commentIds != null) mCommentIds.addAll(commentIds);
            return this;
        }

        public Story build() {
            return new Story(this);
        }
    }
}
@@ -41,24 +41,80 @@
 ata.model;%0A%0A
+import android.os.Parcel;%0Aimport android.os.Parcelable;%0A
 import andro
@@ -268,16 +268,38 @@
 s Story 
+implements Parcelable 
 %7B%0A%0A    @
@@ -694,281 +694,1405 @@
    p
-rotected Story(Builder builder) %7B%0A        mId = builder.mId;%0A        mTimestamp = builder.mTimestamp;%0A        mAuthor = builder.mAuthor;%0A        mTitle = builder.mTitle;%0A        mUrl = builder.mUrl;%0A        mScore = builder.mScore;%0A        mCommentIds = builder.mCommentIds
+ublic static final Parcelable.Creator%3CStory%3E CREATOR = new Parcelable.Creator%3CStory%3E() %7B%0A        @Override%0A        public Story createFromParcel(Parcel source) %7B%0A            return new Story(source);%0A        %7D%0A%0A        @Override%0A        public Story%5B%5D newArray(int size) %7B%0A            return new Story%5Bsize%5D;%0A        %7D%0A    %7D;%0A%0A    protected Story(Builder builder) %7B%0A        mId = builder.mId;%0A        mTimestamp = builder.mTimestamp;%0A        mAuthor = builder.mAuthor;%0A        mTitle = builder.mTitle;%0A        mUrl = builder.mUrl;%0A        mScore = builder.mScore;%0A        mCommentIds = builder.mCommentIds;%0A    %7D%0A%0A    protected Story(Parcel in) %7B%0A        this.mId = in.readLong();%0A        this.mTimestamp = in.readLong();%0A        this.mAuthor = in.readString();%0A        this.mTitle = in.readString();%0A        this.mUrl = in.readString();%0A        this.mScore = in.readLong();%0A        this.mCommentIds = new ArrayList%3C%3E();%0A        in.readList(this.mCommentIds, Long.class.getClassLoader());%0A    %7D%0A%0A    @Override%0A    public int describeContents() %7B return 0; %7D%0A%0A    @Override%0A    public void writeToParcel(Parcel dest, int flags) %7B%0A        dest.writeLong(this.mId);%0A        dest.writeLong(this.mTimestamp);%0A        dest.writeString(this.mAuthor);%0A        dest.writeString(this.mTitle);%0A        dest.writeString(this.mUrl);%0A        dest.writeLong(this.mScore);%0A        dest.writeList(this.mCommentIds)
 ;%0A  
@@ -2643,32 +2643,158 @@
 entIds);%0A    %7D%0A%0A
+    public int getTotalComments() %7B%0A        if (mCommentIds == null) return 0;%0A        else return mCommentIds.size();%0A    %7D%0A%0A
     public stati

Implement Parcelable in Story and add getTotalComments