NIMSDK-AOS  10.9.90
V2NIMUpdateLocalMessageParams.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.v2.message.params;
2 
5 
6 /**
7  * 本地消息更新参数类
8  */
10 
11  /**
12  * 消息子类型,需要 >= 0
13  */
14  private Integer subType;
15 
16  /**
17  * 消息内容
18  */
19  private String text;
20 
21  /**
22  * 消息附属附件,附件类型需要和原始消息附件类型保持一致
23  */
24  private V2NIMMessageAttachment attachment;
25 
26  /**
27  * 消息本地扩展字段
28  */
29  private String localExtension;
30  /**
31  * 消息发送状态
32  * 仅支持成功和失败, 其它状态返回参数报错
33  */
34  private V2NIMMessageSendingState sendingState;
35 
37  }
38 
39  /**
40  * 构造函数
41  *
42  * @param subType 消息子类型,需要 >= 0
43  * @param text 消息内容
44  * @param attachment 消息附属附件
45  * @param localExtension 消息本地扩展字段
46  * @param sendingState 消息发送状态, 仅支持成功和失败, 其它状态返回参数报错
47  */
48  public V2NIMUpdateLocalMessageParams(Integer subType, String text, V2NIMMessageAttachment attachment, String localExtension, V2NIMMessageSendingState sendingState) {
49  this.subType = subType;
50  this.text = text;
51  this.attachment = attachment;
52  this.localExtension = localExtension;
53  this.sendingState = sendingState;
54  }
55 
56 
57 
58  /**
59  * 获取消息子类型
60  *
61  * @return 消息子类型,可能为 null
62  */
63  public Integer getSubType() {
64  return subType;
65  }
66 
67  /**
68  * 设置消息子类型
69  *
70  * @param subType 消息子类型,必须 >= 0
71  */
72  public void setSubType(Integer subType) {
73  this.subType = subType;
74  }
75 
76  /**
77  * 获取消息内容
78  *
79  * @return 消息文本内容,可能为 null
80  */
81  public String getText() {
82  return text;
83  }
84 
85  /**
86  * 设置消息内容
87  *
88  * @param text 消息文本内容
89  */
90  public void setText(String text) {
91  this.text = text;
92  }
93 
94  /**
95  * 获取消息附属附件
96  *
97  * @return 消息附件对象,可能为 null
98  */
100  return attachment;
101  }
102 
103  /**
104  * 设置消息附属附件
105  *
106  * @param attachment 消息附件对象
107  */
108  public void setAttachment(V2NIMMessageAttachment attachment) {
109  this.attachment = attachment;
110  }
111 
112  /**
113  * 获取消息本地扩展字段
114  *
115  * @return 本地扩展信息,可能为 null
116  */
117  public String getLocalExtension() {
118  return localExtension;
119  }
120 
121  /**
122  * 设置消息本地扩展字段
123  *
124  * @param localExtension 本地扩展字段
125  */
126  public void setLocalExtension(String localExtension) {
127  this.localExtension = localExtension;
128  }
129  /**
130  * 获取消息发送状态
131  *
132  * @return 消息发送状态
133  */
135  return sendingState;
136  }
137 
138  /**
139  * 设置消息发送状态, 仅支持成功和失败, 其它状态返回参数报错
140  * @param sendingState 消息发送状态
141  */
142  public void setSendingState(V2NIMMessageSendingState sendingState) {
143  this.sendingState = sendingState;
144  }
145 
146  public boolean isValid() {
147  if(subType != null && subType < 0){
148  return false;
149  }
150 
152  return false;
153  }
154 
155  if(subType != null){
156  return true;
157  }
158 
159  if(text != null){
160  return true;
161  }
162 
163  if(attachment != null){
164  return true;
165  }
166 
167  if(localExtension != null){
168  return true;
169  }
170 
171  if(sendingState != null){
172  return true;
173  }
174 
175  return false;
176  }
177 
178  /**
179  * Builder 模式构建器,用于链式创建 V2NIMUpdateLocalMessageParams 实例
180  */
181  public static class V2NIMUpdateLocalMessageParamsBuilder {
182  private Integer subType;
183  private String text;
184  private V2NIMMessageAttachment attachment;
185  private String localExtension;
186  private V2NIMMessageSendingState sendingState;
187 
188 
189  private V2NIMUpdateLocalMessageParamsBuilder() {}
190 
191  public static V2NIMUpdateLocalMessageParamsBuilder builder() {
192  return new V2NIMUpdateLocalMessageParamsBuilder();
193  }
194 
195  /**
196  * 设置消息子类型
197  *
198  * @param subType 消息子类型,必须 >= 0
199  * @return Builder 自身实例
200  */
201  public V2NIMUpdateLocalMessageParamsBuilder withSubType(Integer subType) {
202  this.subType = subType;
203  return this;
204  }
205 
206  /**
207  * 设置消息内容
208  *
209  * @param text 消息文本内容
210  * @return Builder 自身实例
211  */
212  public V2NIMUpdateLocalMessageParamsBuilder withText(String text) {
213  this.text = text;
214  return this;
215  }
216 
217  /**
218  * 设置消息附件
219  *
220  * @param attachment 消息附件对象
221  * @return Builder 自身实例
222  */
223  public V2NIMUpdateLocalMessageParamsBuilder withAttachment(V2NIMMessageAttachment attachment) {
224  this.attachment = attachment;
225  return this;
226  }
227 
228  /**
229  * 设置消息本地扩展字段
230  *
231  * @param localExtension 本地扩展字段
232  * @return Builder 自身实例
233  */
234  public V2NIMUpdateLocalMessageParamsBuilder withLocalExtension(String localExtension) {
235  this.localExtension = localExtension;
236  return this;
237  }
238 
239  public V2NIMUpdateLocalMessageParamsBuilder withSendingState(V2NIMMessageSendingState sendingState) {
240  this.sendingState = sendingState;
241  return this;
242  }
243 
244  /**
245  * 构建最终的 V2NIMUpdateLocalMessageParams 对象
246  *
247  * @return 构造完成的对象
248  */
249  public V2NIMUpdateLocalMessageParams build() {
250  return new V2NIMUpdateLocalMessageParams(subType, text, attachment, localExtension, sendingState);
251  }
252  }
253 }
V2NIMUpdateLocalMessageParams(Integer subType, String text, V2NIMMessageAttachment attachment, String localExtension, V2NIMMessageSendingState sendingState)
构造函数
void setSendingState(V2NIMMessageSendingState sendingState)
设置消息发送状态, 仅支持成功和失败, 其它状态返回参数报错
void setAttachment(V2NIMMessageAttachment attachment)
设置消息附属附件
void setLocalExtension(String localExtension)
设置消息本地扩展字段