package com.proxerme.library.connection.anime.entity;

import android.support.annotation.NonNull;

import com.proxerme.library.interfaces.IdItem;
import com.proxerme.library.interfaces.ImageItem;
import com.proxerme.library.interfaces.TimeItem;
import com.squareup.moshi.Json;

/**
 * TODO: Describe class
 *
 * @author Ruben Gees
 */
public class Stream implements IdItem, ImageItem, TimeItem {

    @Json(name = "id")
    private String id;
    @Json(name = "htype")
    private String hoster;
    @Json(name = "name")
    private String hosterName;
    @Json(name = "img")
    private String imageId;
    @Json(name = "uploader")
    private String uploaderId;
    @Json(name = "username")
    private String uploader;
    @Json(name = "timestamp")
    private long time;
    @Json(name = "tid")
    private String subgroupId;
    @Json(name = "tnime")
    private String subgroup;
    @Json(name = "htype")
    private String hosterType;

    public Stream(@NonNull String id, @NonNull String hoster, @NonNull String hosterName,
                  @NonNull String imageId, @NonNull String uploaderId, @NonNull String uploader,
                  long time, @NonNull String subgroupId, @NonNull String subgroup,
                  @NonNull String hosterType) {
        this.id = id;
        this.hoster = hoster;
        this.hosterName = hosterName;
        this.imageId = imageId;
        this.uploaderId = uploaderId;
        this.uploader = uploader;
        this.time = time;
        this.subgroupId = subgroupId;
        this.subgroup = subgroup;
        this.hosterType = hosterType;
    }

    @NonNull
    @Override
    public String getId() {
        return id;
    }

    @NonNull
    public String getHoster() {
        return hoster;
    }

    @NonNull
    public String getHosterName() {
        return hosterName;
    }

    @NonNull
    @Override
    public String getImageId() {
        return imageId;
    }

    @NonNull
    public String getUploaderId() {
        return uploaderId;
    }

    @NonNull
    public String getUploader() {
        return uploader;
    }

    @Override
    public long getTime() {
        return time;
    }

    @NonNull
    public String getSubgroupId() {
        return subgroupId;
    }

    @NonNull
    public String getSubgroup() {
        return subgroup;
    }

    @NonNull
    public String getHosterType() {
        return hosterType;
    }

    @SuppressWarnings("SimplifiableIfStatement")
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Stream stream = (Stream) o;

        if (time != stream.time) return false;
        if (!id.equals(stream.id)) return false;
        if (!hoster.equals(stream.hoster)) return false;
        if (!hosterName.equals(stream.hosterName)) return false;
        if (!imageId.equals(stream.imageId)) return false;
        if (!uploaderId.equals(stream.uploaderId)) return false;
        if (!uploader.equals(stream.uploader)) return false;
        if (!subgroupId.equals(stream.subgroupId)) return false;
        if (!subgroup.equals(stream.subgroup)) return false;
        return hosterType.equals(stream.hosterType);
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 31 * result + hoster.hashCode();
        result = 31 * result + hosterName.hashCode();
        result = 31 * result + imageId.hashCode();
        result = 31 * result + uploaderId.hashCode();
        result = 31 * result + uploader.hashCode();
        result = 31 * result + (int) (time ^ (time >>> 32));
        result = 31 * result + subgroupId.hashCode();
        result = 31 * result + subgroup.hashCode();
        result = 31 * result + hosterType.hashCode();
        return result;
    }
}

@@ -48,16 +48,72 @@
 ntity;%0A%0A
+import android.os.Parcel;%0Aimport android.os.Parcelable;%0A
 import a
@@ -147,16 +147,16 @@
 onNull;%0A
-
 %0Aimport 
@@ -442,18 +442,368 @@
 TimeItem
- %7B
+, Parcelable %7B%0A%0A    public static final Parcelable.Creator%3CStream%3E CREATOR = new Parcelable.Creator%3CStream%3E() %7B%0A        @Override%0A        public Stream createFromParcel(Parcel source) %7B%0A            return new Stream(source);%0A        %7D%0A%0A        @Override%0A        public Stream%5B%5D newArray(int size) %7B%0A            return new Stream%5Bsize%5D;%0A        %7D%0A    %7D;
 %0A%0A    @J
@@ -1989,32 +1989,476 @@
 terType;%0A    %7D%0A%0A
+    protected Stream(Parcel in) %7B%0A        this.id = in.readString();%0A        this.hoster = in.readString();%0A        this.hosterName = in.readString();%0A        this.imageId = in.readString();%0A        this.uploaderId = in.readString();%0A        this.uploader = in.readString();%0A        this.time = in.readLong();%0A        this.subgroupId = in.readString();%0A        this.subgroup = in.readString();%0A        this.hosterType = in.readString();%0A    %7D%0A%0A
     @NonNull%0A   
@@ -4631,32 +4631,32 @@
 ype.hashCode();%0A
-
         return r
@@ -4667,11 +4667,566 @@
 t;%0A    %7D
+%0A%0A    @Override%0A    public int describeContents() %7B%0A        return 0;%0A    %7D%0A%0A    @Override%0A    public void writeToParcel(Parcel dest, int flags) %7B%0A        dest.writeString(this.id);%0A        dest.writeString(this.hoster);%0A        dest.writeString(this.hosterName);%0A        dest.writeString(this.imageId);%0A        dest.writeString(this.uploaderId);%0A        dest.writeString(this.uploader);%0A        dest.writeLong(this.time);%0A        dest.writeString(this.subgroupId);%0A        dest.writeString(this.subgroup);%0A        dest.writeString(this.hosterType);%0A    %7D
 %0A%7D%0A

Implement Parcelable for Stream