1 package com.netease.nimlib.sdk.chatroom.model;
3 import androidx.annotation.NonNull;
10 import org.json.JSONArray;
11 import org.json.JSONObject;
13 import java.util.ArrayList;
21 private static final String TAG_TARGET =
"target";
22 private static final String TAG_TARGET_NICK =
"tarNick";
23 private static final String TAG_OPERATOR =
"operator";
24 private static final String TAG_OPERATOR_NICK =
"opeNick";
25 private static final String TAG_EXTENSION =
"ext";
26 private static final String TAG_TAGS =
"tags";
31 private ArrayList<String> targets;
36 private ArrayList<String> targetNicks;
41 private String
operator;
46 private String operatorNick;
51 private Map<String, Object> extension;
55 private ArrayList<String> tags;
82 public void parse(JSONObject json) {
83 if (json.has(TAG_TARGET)) {
84 JSONArray array = JSONHelper.getJSONArray(json, TAG_TARGET);
85 targets =
new ArrayList<>(array.length());
86 for (
int i = 0; i < array.length(); ++i) {
87 targets.add(JSONHelper.getString(array, i));
91 if (json.has(TAG_TARGET_NICK)) {
92 JSONArray array = JSONHelper.getJSONArray(json, TAG_TARGET_NICK);
93 targetNicks =
new ArrayList<>(array.length());
94 for (
int i = 0; i < array.length(); ++i) {
95 targetNicks.add(JSONHelper.getString(array, i));
99 if (json.has(TAG_OPERATOR)) {
100 operator = JSONHelper.getString(json, TAG_OPERATOR);
103 if (json.has(TAG_OPERATOR_NICK)) {
104 operatorNick = JSONHelper.getString(json, TAG_OPERATOR_NICK);
107 if (json.has(TAG_EXTENSION)) {
108 extension = MsgHelper.getMapFromJsonString(JSONHelper.getString(json, TAG_EXTENSION));
111 if (json.has(TAG_TAGS)) {
112 String tagsString = JSONHelper.getString(json, TAG_TAGS);
113 JSONArray array = JSONHelper.parseArray(tagsString);
115 tags =
new ArrayList<>(array.length());
116 for (
int i = 0; i < array.length(); ++i) {
117 tags.add(JSONHelper.getString(array, i));
126 return "ChatRoomNotificationAttachment{" +
127 "targets=" + (targets == null ?
"null" : targets.toString()) +
128 ", targetNicks=" + (targetNicks == null ?
"null" : LogDesensitizationConfigHelper.getPrintTextOfNick(targetNicks.toString())) +
129 ", operator='" +
operator +
'\'' +
130 ", operatorNick='" + LogDesensitizationConfigHelper.getPrintTextOfNick(operatorNick) +
'\'' +
131 ", extension=" + extension +
132 ", tags=" + (tags == null ?
"null" : tags.toString()) +
Map< String, Object > getExtension()
ArrayList< String > getTargetNicks()
ArrayList< String > getTargets()
void parse(JSONObject json)
ArrayList< String > getTags()