Created
March 27, 2019 01:38
-
-
Save mitchtabian/e352269eab9515f5794ea867423c198f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Post implements Parcelable { | |
@SerializedName("userId") | |
@Expose() | |
private int userId; | |
@SerializedName("id") | |
@Expose() | |
private int id; | |
@SerializedName("title") | |
@Expose() | |
private String title; | |
@SerializedName("body") | |
@Expose() | |
private String body; | |
private List<Comment> comments; | |
public Post(int userId, int id, String title, String body, List<Comment> comments) { | |
this.userId = userId; | |
this.id = id; | |
this.title = title; | |
this.body = body; | |
this.comments = comments; | |
} | |
protected Post(Parcel in) { | |
userId = in.readInt(); | |
id = in.readInt(); | |
title = in.readString(); | |
body = in.readString(); | |
} | |
public static final Creator<Post> CREATOR = new Creator<Post>() { | |
@Override | |
public Post createFromParcel(Parcel in) { | |
return new Post(in); | |
} | |
@Override | |
public Post[] newArray(int size) { | |
return new Post[size]; | |
} | |
}; | |
public int getUserId() { | |
return userId; | |
} | |
public void setUserId(int userId) { | |
this.userId = userId; | |
} | |
public int getId() { | |
return id; | |
} | |
public void setId(int id) { | |
this.id = id; | |
} | |
public String getTitle() { | |
return title; | |
} | |
public void setTitle(String title) { | |
this.title = title; | |
} | |
public String getBody() { | |
return body; | |
} | |
public void setBody(String body) { | |
this.body = body; | |
} | |
public List<Comment> getComments() { | |
return comments; | |
} | |
public void setComments(List<Comment> comments) { | |
this.comments = comments; | |
} | |
@Override | |
public String toString() { | |
return "Post{" + | |
"userId=" + userId + | |
", id=" + id + | |
", title='" + title + '\'' + | |
", body='" + body + '\'' + | |
'}'; | |
} | |
@Override | |
public int describeContents() { | |
return 0; | |
} | |
@Override | |
public void writeToParcel(Parcel dest, int flags) { | |
dest.writeInt(userId); | |
dest.writeInt(id); | |
dest.writeString(title); | |
dest.writeString(body); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment