Skip to content

Commit

Permalink
Null check when parsing strings
Browse files Browse the repository at this point in the history
Mostly relevant to malformed icons where for some reason, requiring an image results in null.
  • Loading branch information
guyca committed Feb 6, 2019
1 parent 5abea28 commit eda4b9c
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

import org.json.JSONObject;

import javax.annotation.*;

public class TextParser {
public static Text parse(JSONObject json, String text) {
return json.has(text) ? new Text(json.optString(text)) : new NullText();
public static Text parse(@Nullable JSONObject json, String text) {
return json != null && json.has(text) ? new Text(json.optString(text)) : new NullText();
}
}

0 comments on commit eda4b9c

Please sign in to comment.