NIMSDK-AOS  10.9.90
V2NIMRemoveTopicsParams.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.v2.topic.params;
2 
3 import android.text.TextUtils;
5 import java.util.List;
6 
7 /**
8  * 批量删除 Topic 参数。
9  */
11  /**
12  * 待删除的 Topic 列表。
13  *
14  * <p>当前仅支持删除同一会话下的 Topic。</p>
15  */
16  private final List<V2NIMTopic> topicList;
17 
18  /**
19  * 构造批量删除 Topic 参数。
20  *
21  * @param topicList 待删除的 Topic 列表,且必须全部属于同一个会话
22  */
23  public V2NIMRemoveTopicsParams(List<V2NIMTopic> topicList) {
24  this.topicList = topicList;
25  }
26 
27  /**
28  * 返回待删除的 Topic 列表。
29  *
30  * @return 待删除的 Topic 列表
31  */
32  public List<V2NIMTopic> getTopicList() {
33  return topicList;
34  }
35 
36  /**
37  * 返回参数非法原因。
38  *
39  * @return 参数合法时返回 `null`,否则返回具体错误原因
40  */
41  public String isValidWithErrorMsg() {
42  if (topicList == null || topicList.isEmpty()) {
43  return "topicList is empty";
44  }
45  String conversationId = null;
46  for (V2NIMTopic topic : topicList) {
47  if (topic == null) {
48  return "topicList contains null topic";
49  }
50  if (TextUtils.isEmpty(topic.getConversationId())) {
51  return "topic conversationId is empty";
52  }
53  if (topic.getTopicId() <= 0) {
54  return "topicId must be greater than 0";
55  }
56  if (conversationId == null) {
57  conversationId = topic.getConversationId();
58  continue;
59  }
60  if (!TextUtils.equals(conversationId, topic.getConversationId())) {
61  return "only topics in the same conversation can be removed together";
62  }
63  }
64  return null;
65  }
66 
67  /**
68  * 参数是否合法。
69  *
70  * @return `true` 表示参数合法,否则为 `false`
71  */
72  public boolean isValid() {
73  return isValidWithErrorMsg() == null;
74  }
75 }
V2NIMRemoveTopicsParams(List< V2NIMTopic > topicList)
构造批量删除 Topic 参数。
List< V2NIMTopic > getTopicList()
返回待删除的 Topic 列表。