NIMSDK-AOS  10.9.90
V2NIMModifyMessageParams.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.v2.message.params;
2 
7 
9  /** 消息子类型 */
10  private Integer subType;
11 
12  /** 消息内容 */
13  private String text;
14 
15  /** 消息附属附件,根据消息类型继承实现 */
16  private V2NIMMessageAttachment attachment;
17 
18  /** 消息服务端扩展,请使用
19  * Json 字符串 */
20  private String serverExtension;
21 
22  /** 反垃圾相关配置 */
23  private V2NIMMessageAntispamConfig antispamConfig;
24 
25  /** 路由抄送相关配置 */
26  private V2NIMMessageRouteConfig routeConfig;
27 
28  /** 推送相关配置 */
29  private V2NIMMessagePushConfig pushConfig;
30 
31  /**
32  * 是否启用本地反垃圾
33  * 只针对文本消息生效
34  * 发送消息时候,如果改字段为true,文本消息则走本地反垃圾检测,检测后返回V2NIMClientAntispamOperateType,
35  * 返回0,直接发送该消息
36  * 返回1,发送替换后的文本消息
37  * 返回2,消息发送失败, 返回本地错误码
38  * 返回3,消息正常发送,由服务端拦截
39  */
40  private boolean clientAntispamEnabled = false;
41 
42  /**
43  * 反垃圾命中后替换的文本
44  */
45  private String clientAntispamReplace = "";
46 
47  /**
48  * 获取消息子类型
49  * @return 消息子类型
50  */
51  public Integer getSubType() {
52  return this.subType;
53  }
54 
55  /**
56  * 设置消息子类型
57  * @param subType 消息子类型
58  */
59  public void setSubType(Integer subType) {
60  this.subType = subType;
61  }
62 
63  /**
64  * 获取消息内容
65  * @return 消息内容
66  */
67  public String getText() {
68  return this.text;
69  }
70 
71  /**
72  * 设置消息内容
73  * @param text 消息内容
74  */
75  public void setText(String text) {
76  this.text = text;
77  }
78 
79  /**
80  * 获取消息附属附件
81  * @return 消息附属附件
82  */
84  return this.attachment;
85  }
86 
87  /**
88  * 设置消息附属附件
89  * @param attachment 消息附属附件
90  */
91  public void setAttachment(V2NIMMessageAttachment attachment) {
92  this.attachment = attachment;
93  }
94 
95  /**
96  * 获取消息服务端扩展
97  * @return 消息服务端扩展
98  */
99  public String getServerExtension() {
100  return this.serverExtension;
101  }
102 
103  /**
104  * 设置消息服务端扩展
105  * @param serverExtension 消息服务端扩展
106  */
107  public void setServerExtension(String serverExtension) {
108  this.serverExtension = serverExtension;
109  }
110 
111  /**
112  * 获取反垃圾相关配置
113  * @return 反垃圾相关配置
114  */
116  if (this.antispamConfig == null) {
118  } else {
119  return this.antispamConfig;
120  }
121  }
122 
123  /**
124  * 设置反垃圾相关配置
125  * @param antispamConfig 反垃圾相关配置
126  */
127  public void setAntispamConfig(V2NIMMessageAntispamConfig antispamConfig) {
128  this.antispamConfig = antispamConfig;
129  }
130 
131  /**
132  * 获取路由抄送相关配置
133  * @return 路由抄送相关配置
134  */
136  if (this.routeConfig == null) {
138  } else {
139  return this.routeConfig;
140  }
141  }
142 
143  /**
144  * 设置路由抄送相关配置
145  * @param routeConfig 路由抄送相关配置
146  */
147  public void setRouteConfig(V2NIMMessageRouteConfig routeConfig) {
148  this.routeConfig = routeConfig;
149  }
150 
151  /**
152  * 获取推送相关配置
153  * @return 推送相关配置
154  */
156  if (this.pushConfig == null) {
157  return V2NIMMessagePushConfig.V2NIMMessagePushConfigBuilder.builder().build();
158  } else {
159  return this.pushConfig;
160  }
161  }
162 
163 
164  /**
165  * 设置推送相关配置
166  * @param pushConfig 推送相关配置
167  */
168  public void setPushConfig(V2NIMMessagePushConfig pushConfig) {
169  this.pushConfig = pushConfig;
170  }
171 
172  /**
173  * 获取是否启用本地反垃圾
174  * @return 是否启用本地反垃圾
175  */
176  public boolean isClientAntispamEnabled() {
177  return this.clientAntispamEnabled;
178  }
179 
180  /**
181  * 设置是否启用本地反垃圾
182  * @param clientAntispamEnabled 是否启用本地反垃圾
183  */
184  public void setClientAntispamEnabled(boolean clientAntispamEnabled) {
185  this.clientAntispamEnabled = clientAntispamEnabled;
186  }
187 
188  /**
189  * 获取反垃圾命中后替换的文本
190  * @return 反垃圾命中后替换的文本
191  */
192  public String getClientAntispamReplace() {
193  return this.clientAntispamReplace;
194  }
195 
196  /**
197  * 设置反垃圾命中后替换的文本
198  * @param clientAntispamReplace 反垃圾命中后替换的文本
199  */
200  public void setClientAntispamReplace(String clientAntispamReplace) {
201  this.clientAntispamReplace = clientAntispamReplace;
202  }
203 
204  public boolean isValid(){
205  if(subType != null && subType < 0){
206  return false;
207  }
208  if(subType != null){
209  return true;
210  }
211  if(text != null){
212  return true;
213  }
214  if(attachment != null){
215  return true;
216  }
217  if(serverExtension != null){
218  return true;
219  }
220  return false;
221  }
222 
223  /**
224  * V2NIMModifyMessageParams 构造器
225  */
226  public static final class V2NIMModifyMessageParamsBuilder {
227 
228  /** 消息子类型 */
229  private Integer subType;
230 
231  /** 消息内容 */
232  private String text;
233 
234  /** 消息附属附件,根据消息类型继承实现 */
235  private V2NIMMessageAttachment attachment;
236 
237  /** 消息服务端扩展,必须是Json 字符串 */
238  private String serverExtension;
239 
240  /** 反垃圾相关配置 */
241  private V2NIMMessageAntispamConfig antispamConfig;
242 
243  /** 路由抄送相关配置 */
244  private V2NIMMessageRouteConfig routeConfig;
245 
246  /** 推送相关配置 */
247  private V2NIMMessagePushConfig pushConfig;
248 
249  /**
250  * 是否启用本地反垃圾
251  * 只针对文本消息生效
252  * 发送消息时候,如果改字段为true,文本消息则走本地反垃圾检测,检测后返回V2NIMClientAntispamOperateType,
253  * 返回0,直接发送该消息
254  * 返回1,发送替换后的文本消息
255  * 返回2,消息发送失败, 返回本地错误码
256  * 返回3,消息正常发送,由服务端拦截
257  */
258  private boolean clientAntispamEnabled;
259 
260  /**
261  * 反垃圾命中后替换的文本
262  */
263  private String clientAntispamReplace;
264 
265  private V2NIMModifyMessageParamsBuilder() {
266  }
267 
268  /**
269  * V2NIMModifyMessageParams 构造器
270  * @return V2NIMModifyMessageParamsBuilder
271  */
272  public static V2NIMModifyMessageParamsBuilder builder() {
273  return new V2NIMModifyMessageParamsBuilder();
274  }
275 
276  /**
277  * 设置消息子类型
278  * @param subType 消息子类型
279  * @return V2NIMModifyMessageParamsBuilder
280  */
281  public V2NIMModifyMessageParamsBuilder withSubType(int subType) {
282  this.subType = subType;
283  return this;
284  }
285 
286  /**
287  * 设置消息内容
288  * @param text 消息内容
289  * @return V2NIMModifyMessageParamsBuilder
290  */
291  public V2NIMModifyMessageParamsBuilder withText(String text) {
292  this.text = text;
293  return this;
294  }
295 
296  /**
297  * 设置消息附属附件
298  * @param attachment 消息附属附件
299  * @return V2NIMModifyMessageParamsBuilder
300  */
301  public V2NIMModifyMessageParamsBuilder withAttachment(V2NIMMessageAttachment attachment) {
302  this.attachment = attachment;
303  return this;
304  }
305 
306  /**
307  * 设置消息服务端扩展
308  * @param serverExtension 消息服务端扩展
309  * @return V2NIMModifyMessageParamsBuilder
310  */
311  public V2NIMModifyMessageParamsBuilder withServerExtension(String serverExtension) {
312  this.serverExtension = serverExtension;
313  return this;
314  }
315 
316  /**
317  * 设置反垃圾相关配置
318  * @param antispamConfig 反垃圾相关配置
319  * @return V2NIMModifyMessageParamsBuilder
320  */
321  public V2NIMModifyMessageParamsBuilder withAntispamConfig(V2NIMMessageAntispamConfig antispamConfig) {
322  this.antispamConfig = antispamConfig;
323  return this;
324  }
325 
326  /**
327  * 设置路由抄送相关配置
328  * @param routeConfig 路由抄送相关配置
329  * @return V2NIMModifyMessageParamsBuilder
330  */
331  public V2NIMModifyMessageParamsBuilder withRouteConfig(V2NIMMessageRouteConfig routeConfig) {
332  this.routeConfig = routeConfig;
333  return this;
334  }
335 
336  /**
337  * 设置推送相关配置
338  * @param pushConfig 推送相关配置
339  * @return V2NIMModifyMessageParamsBuilder
340  */
341  public V2NIMModifyMessageParamsBuilder withPushConfig(V2NIMMessagePushConfig pushConfig) {
342  this.pushConfig = pushConfig;
343  return this;
344  }
345 
346  /**
347  * 设置是否启用本地反垃圾
348  * @param clientAntispamEnabled 是否启用本地反垃圾
349  * @return V2NIMModifyMessageParamsBuilder
350  */
351  public V2NIMModifyMessageParamsBuilder withClientAntispamEnabled(boolean clientAntispamEnabled) {
352  this.clientAntispamEnabled = clientAntispamEnabled;
353  return this;
354  }
355 
356  /**
357  * 设置反垃圾命中后替换的文本
358  * @param clientAntispamReplace 反垃圾命中后替换的文本
359  * @return V2NIMModifyMessageParamsBuilder
360  */
361  public V2NIMModifyMessageParamsBuilder withClientAntispamReplace(String clientAntispamReplace) {
362  this.clientAntispamReplace = clientAntispamReplace;
363  return this;
364  }
365 
366  /**
367  * 构建 V2NIMModifyMessageParams 对象
368  * @return V2NIMModifyMessageParams
369  */
370  public V2NIMModifyMessageParams build() {
372  params.setSubType(subType);
373  params.setText(text);
374  params.setAttachment(attachment);
375  params.setServerExtension(serverExtension);
376  params.setAntispamConfig(antispamConfig);
377  params.setRouteConfig(routeConfig);
378  params.setPushConfig(pushConfig);
379  params.setClientAntispamEnabled(clientAntispamEnabled);
380  params.setClientAntispamReplace(clientAntispamReplace);
381  return params;
382  }
383  }
384 }
void setClientAntispamEnabled(boolean clientAntispamEnabled)
设置是否启用本地反垃圾
V2NIMMessageAntispamConfig getAntispamConfig()
获取反垃圾相关配置
void setAttachment(V2NIMMessageAttachment attachment)
设置消息附属附件
String getClientAntispamReplace()
获取反垃圾命中后替换的文本
void setServerExtension(String serverExtension)
设置消息服务端扩展
void setPushConfig(V2NIMMessagePushConfig pushConfig)
设置推送相关配置
void setAntispamConfig(V2NIMMessageAntispamConfig antispamConfig)
设置反垃圾相关配置
V2NIMMessageAttachment getAttachment()
获取消息附属附件
void setRouteConfig(V2NIMMessageRouteConfig routeConfig)
设置路由抄送相关配置
void setClientAntispamReplace(String clientAntispamReplace)
设置反垃圾命中后替换的文本
V2NIMMessagePushConfig getPushConfig()
获取推送相关配置
V2NIMMessageRouteConfig getRouteConfig()
获取路由抄送相关配置