Skip to content

Commit 6c36b79

Browse files
committed
Fix the type field of Comment being NonNull even if it can be
1 parent ebb8ad2 commit 6c36b79

1 file changed

Lines changed: 38 additions & 43 deletions

File tree

  • library/src/main/java/com/proxerme/library/connection/info/entity

library/src/main/java/com/proxerme/library/connection/info/entity/Comment.java

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public class Comment implements Parcelable, IdItem, ImageItem, TimeItem {
2020

2121
public static final Creator<Comment> CREATOR = new Creator<Comment>() {
2222
@Override
23-
public Comment createFromParcel(Parcel in) {
24-
return new Comment(in);
23+
public Comment createFromParcel(Parcel source) {
24+
return new Comment(source);
2525
}
2626

2727
@Override
@@ -81,11 +81,10 @@ private Comment() {
8181
* @param imageId The image id.
8282
*/
8383
public Comment(@NonNull String id, @NonNull String entryId, @NonNull String userId,
84-
@NonNull String type, @CommentState int state,
85-
@NonNull RatingDetails ratingDetails, @NonNull String comment,
86-
@IntRange(from = 0, to = 10) int rating, @IntRange(from = 0) int episode,
87-
@IntRange(from = 0) int helpfulVotes, long time, @NonNull String username,
88-
@NonNull String imageId) {
84+
String type, @CommentState int state, @NonNull RatingDetails ratingDetails,
85+
@NonNull String comment, @IntRange(from = 0, to = 10) int rating,
86+
@IntRange(from = 0) int episode, @IntRange(from = 0) int helpfulVotes, long time,
87+
@NonNull String username, @NonNull String imageId) {
8988
this.id = id;
9089
this.entryId = entryId;
9190
this.userId = userId;
@@ -101,25 +100,20 @@ public Comment(@NonNull String id, @NonNull String entryId, @NonNull String user
101100
this.imageId = imageId;
102101
}
103102

104-
/**
105-
* The constructor to read in the parcel.
106-
*
107-
* @param in The parcel to parse.
108-
*/
109103
protected Comment(Parcel in) {
110-
id = in.readString();
111-
entryId = in.readString();
112-
userId = in.readString();
113-
type = in.readString();
114-
state = in.readInt();
115-
ratingDetails = in.readParcelable(RatingDetails.class.getClassLoader());
116-
comment = in.readString();
117-
rating = in.readInt();
118-
episode = in.readInt();
119-
helpfulVotes = in.readInt();
120-
time = in.readLong();
121-
username = in.readString();
122-
imageId = in.readString();
104+
this.id = in.readString();
105+
this.entryId = in.readString();
106+
this.userId = in.readString();
107+
this.type = in.readString();
108+
this.state = in.readInt();
109+
this.ratingDetails = in.readParcelable(RatingDetails.class.getClassLoader());
110+
this.comment = in.readString();
111+
this.rating = in.readInt();
112+
this.episode = in.readInt();
113+
this.helpfulVotes = in.readInt();
114+
this.time = in.readLong();
115+
this.username = in.readString();
116+
this.imageId = in.readString();
123117
}
124118

125119
@NonNull
@@ -183,7 +177,6 @@ public RatingDetails getRatingDetails() {
183177
*
184178
* @return The Comment.
185179
**/
186-
@NonNull
187180
public String getComment() {
188181
return comment;
189182
}
@@ -238,6 +231,9 @@ public String getUsername() {
238231
return username;
239232
}
240233

234+
/**
235+
* {@inheritDoc}
236+
*/
241237
@NonNull
242238
@Override
243239
public String getImageId() {
@@ -250,20 +246,20 @@ public int describeContents() {
250246
}
251247

252248
@Override
253-
public void writeToParcel(Parcel parcel, int i) {
254-
parcel.writeString(id);
255-
parcel.writeString(entryId);
256-
parcel.writeString(userId);
257-
parcel.writeString(type);
258-
parcel.writeInt(state);
259-
parcel.writeParcelable(ratingDetails, i);
260-
parcel.writeString(comment);
261-
parcel.writeInt(rating);
262-
parcel.writeInt(episode);
263-
parcel.writeInt(helpfulVotes);
264-
parcel.writeLong(time);
265-
parcel.writeString(username);
266-
parcel.writeString(imageId);
249+
public void writeToParcel(Parcel dest, int flags) {
250+
dest.writeString(this.id);
251+
dest.writeString(this.entryId);
252+
dest.writeString(this.userId);
253+
dest.writeString(this.type);
254+
dest.writeInt(this.state);
255+
dest.writeParcelable(this.ratingDetails, flags);
256+
dest.writeString(this.comment);
257+
dest.writeInt(this.rating);
258+
dest.writeInt(this.episode);
259+
dest.writeInt(this.helpfulVotes);
260+
dest.writeLong(this.time);
261+
dest.writeString(this.username);
262+
dest.writeString(this.imageId);
267263
}
268264

269265
@SuppressWarnings("SimplifiableIfStatement")
@@ -282,20 +278,19 @@ public boolean equals(Object o) {
282278
if (!id.equals(comment1.id)) return false;
283279
if (!entryId.equals(comment1.entryId)) return false;
284280
if (!userId.equals(comment1.userId)) return false;
285-
if (!type.equals(comment1.type)) return false;
281+
if (type != null ? !type.equals(comment1.type) : comment1.type != null) return false;
286282
if (!ratingDetails.equals(comment1.ratingDetails)) return false;
287283
if (!comment.equals(comment1.comment)) return false;
288284
if (!username.equals(comment1.username)) return false;
289285
return imageId.equals(comment1.imageId);
290-
291286
}
292287

293288
@Override
294289
public int hashCode() {
295290
int result = id.hashCode();
296291
result = 31 * result + entryId.hashCode();
297292
result = 31 * result + userId.hashCode();
298-
result = 31 * result + type.hashCode();
293+
result = 31 * result + (type != null ? type.hashCode() : 0);
299294
result = 31 * result + state;
300295
result = 31 * result + ratingDetails.hashCode();
301296
result = 31 * result + comment.hashCode();

0 commit comments

Comments
 (0)