Skip to content

Commit

Permalink
Merge pull request #2868 from wordpress-mobile/analysis/add-missing-n…
Browse files Browse the repository at this point in the history
…ullability-annotations-to-comment-clients

[Nullability Annotations to Java Classes] Add Missing Nullability Annotations to `Comment` Network Client Classes (`safe`)
  • Loading branch information
ParaskP7 authored Oct 18, 2023
2 parents 6701153 + da3eaf6 commit 0867b48
Show file tree
Hide file tree
Showing 16 changed files with 413 additions and 473 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.wordpress.android.fluxc.model;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.Locale;

public enum CommentStatus {
Expand All @@ -22,7 +25,8 @@ public String toString() {
return this.name().toLowerCase(Locale.US);
}

public static CommentStatus fromString(String string) {
@NonNull
public static CommentStatus fromString(@Nullable String string) {
if (string != null) {
for (CommentStatus v : CommentStatus.values()) {
if (string.equalsIgnoreCase(v.name())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CommentsMapper @Inject constructor(
}
},
authorProfileImageUrl = commentDto.author?.avatar_URL,
remotePostId = commentDto.post?.ID ?: 0,
remotePostId = commentDto.post?.ID ?: 0L,
postTitle = StringEscapeUtils.unescapeHtml4(commentDto.post?.title),
status = commentDto.status,
datePublished = commentDto.date,
Expand All @@ -46,7 +46,7 @@ class CommentsMapper @Inject constructor(
url = commentDto.URL,
authorId = commentDto.author?.ID ?: 0L,
hasParent = commentDto.parent != null,
parentId = commentDto.parent?.ID ?: 0,
parentId = commentDto.parent?.ID ?: 0L,
iLike = commentDto.i_like
)
}
Expand Down Expand Up @@ -139,7 +139,7 @@ class CommentsMapper @Inject constructor(
content = XMLRPCUtils.safeGetMapValue(commentMap, "content", ""),
url = XMLRPCUtils.safeGetMapValue(commentMap, "link", ""),
hasParent = remoteParentCommentId > 0,
parentId = if (remoteParentCommentId > 0) remoteParentCommentId else 0,
parentId = if (remoteParentCommentId > 0) remoteParentCommentId else 0L,
iLike = false
)
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
package org.wordpress.android.fluxc.network.rest.wpcom.comment;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.List;

@SuppressWarnings("NotNullFieldNotInitialized")
public class CommentWPComRestResponse {
public class CommentsWPComRestResponse {
public List<CommentWPComRestResponse> comments;
public static class CommentsWPComRestResponse {
@Nullable public List<CommentWPComRestResponse> comments;
}

public class Post {
public static class Post {
public long ID;
public String title;
public String type;
public String link;
@NonNull public String title;
@NonNull public String type;
@NonNull public String link;
}

public class Author {
public static class Author {
public long ID;
public String email; // can be boolean "false" if not set
public String name;
public String URL;
public String avatar_URL;
@NonNull public String email; // can be boolean "false" if not set
@NonNull public String name;
@NonNull public String URL;
@NonNull public String avatar_URL;
}

public long ID;
public CommentParent parent;
public Post post;
public Author author;
public String date;
public String status;
public String content;
@Nullable public CommentParent parent;
@Nullable public Post post;
@Nullable public Author author;
@NonNull public String date;
@NonNull public String status;
@NonNull public String content;
public boolean i_like;
public String URL;
@NonNull public String URL;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import javax.inject.Inject
import javax.inject.Named
import javax.inject.Singleton

@Suppress("LongParameterList")
@Singleton
class CommentsRestClient @Inject constructor(
appContext: Context?,
Expand Down
Loading

0 comments on commit 0867b48

Please sign in to comment.