package de.fu_berlin.cdv.chasingpictures.api;

import android.os.Parcel;
import android.os.Parcelable;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Date;

/**
 * @author Simon Kalt
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class UserData implements Parcelable {
    private Integer id;
    private String provider;
    private String uid;
    private String name;
    private String nickname;
    private String image;
    private String email;
    @JsonProperty("created_at")
    private Date createdAt;
    @JsonProperty("updated_at")
    private Date updatedAt;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getProvider() {
        return provider;
    }

    public void setProvider(String provider) {
        this.provider = provider;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public Date getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Date updatedAt) {
        this.updatedAt = updatedAt;
    }

    public UserData() { }

    public UserData(Parcel in) {
        readFromParcel(in);
    }

    private void readFromParcel(Parcel in) {
        setId(in.readInt());
        setProvider(in.readString());
        setUid(in.readString());
        setName(in.readString());
        setNickname(in.readString());
        setImage(in.readString());
        setEmail(in.readString());
        setCreatedAt(new Date(in.readLong()));
        setUpdatedAt(new Date(in.readLong()));
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(provider);
        dest.writeString(uid);
        dest.writeString(name);
        dest.writeString(nickname);
        dest.writeString(image);
        dest.writeString(email);
        dest.writeLong(createdAt == null ? 0 : createdAt.getTime());
        dest.writeLong(updatedAt == null ? 0 : updatedAt.getTime());
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Parcelable.Creator CREATOR =
            new Parcelable.Creator() {
                public UserData createFromParcel(Parcel in) {
                    return new UserData(in);
                }

                public UserData[] newArray(int size) {
                    return new UserData[size];
                }
            };

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

        UserData userData = (UserData) o;

        if (id != null ? !id.equals(userData.id) : userData.id != null) return false;
        if (provider != null ? !provider.equals(userData.provider) : userData.provider != null)
            return false;
        if (uid != null ? !uid.equals(userData.uid) : userData.uid != null) return false;
        if (name != null ? !name.equals(userData.name) : userData.name != null) return false;
        if (nickname != null ? !nickname.equals(userData.nickname) : userData.nickname != null)
            return false;
        if (image != null ? !image.equals(userData.image) : userData.image != null) return false;
        if (email != null ? !email.equals(userData.email) : userData.email != null) return false;
        if (createdAt != null ? !createdAt.equals(userData.createdAt) : userData.createdAt != null)
            return false;
        return !(updatedAt != null ? !updatedAt.equals(userData.updatedAt) : userData.updatedAt != null);

    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (provider != null ? provider.hashCode() : 0);
        result = 31 * result + (uid != null ? uid.hashCode() : 0);
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (nickname != null ? nickname.hashCode() : 0);
        result = 31 * result + (image != null ? image.hashCode() : 0);
        result = 31 * result + (email != null ? email.hashCode() : 0);
        result = 31 * result + (createdAt != null ? createdAt.hashCode() : 0);
        result = 31 * result + (updatedAt != null ? updatedAt.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "UserData{" +
                "id=" + id +
                ", provider='" + provider + '\'' +
                ", uid='" + uid + '\'' +
                ", name='" + name + '\'' +
                ", nickname='" + nickname + '\'' +
                ", image='" + image + '\'' +
                ", email='" + email + '\'' +
                ", createdAt=" + createdAt +
                ", updatedAt=" + updatedAt +
                '}';
    }
}

@@ -44,117 +44,8 @@
 i;%0A%0A
-import android.os.Parcel;%0Aimport android.os.Parcelable;%0A%0Aimport com.fasterxml.jackson.annotation.JsonIgnore;%0A
 impo
@@ -102,16 +102,16 @@
 erties;%0A
+
 import c
@@ -157,16 +157,45 @@
 perty;%0A%0A
+import java.io.Serializable;%0A
 import j
@@ -317,22 +317,24 @@
 lements 
-Parcel
+Serializ
 able %7B%0A 
@@ -1899,1370 +1899,15 @@
 At;%0A
+
     %7D%0A%0A
-    public UserData() %7B %7D%0A%0A    public UserData(Parcel in) %7B%0A        readFromParcel(in);%0A    %7D%0A%0A    private void readFromParcel(Parcel in) %7B%0A        setId(in.readInt());%0A        setProvider(in.readString());%0A        setUid(in.readString());%0A        setName(in.readString());%0A        setNickname(in.readString());%0A        setImage(in.readString());%0A        setEmail(in.readString());%0A        setCreatedAt(new Date(in.readLong()));%0A        setUpdatedAt(new Date(in.readLong()));%0A    %7D%0A%0A    @Override%0A    public void writeToParcel(Parcel dest, int flags) %7B%0A        dest.writeInt(id);%0A        dest.writeString(provider);%0A        dest.writeString(uid);%0A        dest.writeString(name);%0A        dest.writeString(nickname);%0A        dest.writeString(image);%0A        dest.writeString(email);%0A        dest.writeLong(createdAt == null ? 0 : createdAt.getTime());%0A        dest.writeLong(updatedAt == null ? 0 : updatedAt.getTime());%0A    %7D%0A%0A    @Override%0A    public int describeContents() %7B%0A        return 0;%0A    %7D%0A%0A    public static final Parcelable.Creator CREATOR =%0A            new Parcelable.Creator() %7B%0A                public UserData createFromParcel(Parcel in) %7B%0A                    return new UserData(in);%0A                %7D%0A%0A                public UserData%5B%5D newArray(int size) %7B%0A                    return new UserData%5Bsize%5D;%0A                %7D%0A            %7D;%0A%0A
     

Make UserData serializable instead of parcelable