NIMSDK-AOS  10.10.13
V2NIMSendMessageParams.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.v2.message.params;
2 
9 
10 public class V2NIMSendMessageParams {
11  /**
12  * 消息相关配置
13  */
14  private final V2NIMMessageConfig messageConfig;
15 
16  /**
17  * 路由相关配置
18  */
19  private final V2NIMMessageRouteConfig routeConfig;
20 
21  /**
22  * 推送相关配置
23  */
24  private final V2NIMMessagePushConfig pushConfig;
25 
26  /**
27  * 反垃圾相关配置
28  */
29  private final V2NIMMessageAntispamConfig antispamConfig;
30 
31  /**
32  * 机器人相关配置
33  */
34  private final V2NIMMessageRobotConfig robotConfig;
35  /**
36  * 请求大模型的相关参数
37  */
38  private final V2NIMMessageAIConfigParams aiConfig;
39  /**
40  * 定向消息相关配置
41  * 用以控制在发送群组消息时,消息是否发送给指定的群组成员
42  */
43  private final V2NIMMessageTargetConfig targetConfig;
44 
45  /**
46  * 是否启用本地反垃圾
47  * 只针对文本消息生效
48  * 发送消息时候,如果改字段为true,文本消息则走本地反垃圾检测,检测后返回V2NIMClientAntispamOperateType,
49  * 返回0,直接发送该消息
50  * 返回1,发送替换后的文本消息
51  * 返回2,消息发送失败, 返回本地错误码
52  * 返回3,消息正常发送,由服务端拦截
53  */
54  private final boolean clientAntispamEnabled;
55 
56  /**
57  * 反垃圾命中后替换的文本
58  */
59  private final String clientAntispamReplace;
60 
61  private V2NIMSendMessageParams() {
62  this(
63  null,
64  null,
65  null,
66  null,
67  null,
68  null,
69  null,
70  DEFAULT_CLIENT_ANTISPAM_ENABLED,
71  DEFAULT_CLIENT_ANTISPAM_REPLACE);
72  }
73 
74  private V2NIMSendMessageParams(V2NIMMessageConfig messageConfig, V2NIMMessageRouteConfig routeConfig, V2NIMMessagePushConfig pushConfig, V2NIMMessageAntispamConfig antispamConfig, V2NIMMessageRobotConfig robotConfig,V2NIMMessageAIConfigParams aiConfig, V2NIMMessageTargetConfig targetConfig, boolean clientAntispamEnabled, String clientAntispamReplace) {
75  this.messageConfig = messageConfig;
76  this.routeConfig = routeConfig;
77  this.pushConfig = pushConfig;
78  this.antispamConfig = antispamConfig;
79  this.robotConfig = robotConfig;
80  this.aiConfig = aiConfig;
81  this.targetConfig = targetConfig;
82  this.clientAntispamEnabled = clientAntispamEnabled;
83  this.clientAntispamReplace = clientAntispamReplace;
84  }
85  /**
86  * 获取消息相关配置
87  * @return 消息相关配置
88  */
90  return messageConfig;
91  }
92  /**
93  * 获取路由相关配置
94  * @return 路由相关配置
95  */
97  return routeConfig;
98  }
99  /**
100  * 获取推送相关配置
101  * @return 推送相关配置
102  */
104  return pushConfig;
105  }
106  /**
107  * 获取反垃圾相关配置
108  * @return 反垃圾相关配置
109  */
111  return antispamConfig;
112  }
113  /**
114  * 获取机器人相关配置
115  * @return 机器人相关配置
116  */
118  return robotConfig;
119  }
120  /**
121  * 获取请求大模型的相关参数
122  * @return 请求大模型的相关参数
123  */
125  return aiConfig;
126  }
127  /**
128  * 获取定向消息相关配置
129  * @return 定向消息相关配置
130  */
132  return targetConfig;
133  }
134  /**
135  * 获取是否启用本地反垃圾
136  * @return 是否启用本地反垃圾
137  */
138  public boolean isClientAntispamEnabled() {
139  return clientAntispamEnabled;
140  }
141  /**
142  * 获取反垃圾命中后替换的文本
143  * @return 反垃圾命中后替换的文本
144  */
145  public String getClientAntispamReplace() {
146  return clientAntispamReplace;
147  }
148 
149  @Override
150  public String toString() {
151  return "V2NIMSendMessageParams{" +
152  "messageConfig=" + messageConfig +
153  ", routeConfig=" + routeConfig +
154  ", pushConfig=" + pushConfig +
155  ", antispamConfig=" + antispamConfig +
156  ", robotConfig=" + robotConfig +
157  ", clientAntispamEnabled=" + clientAntispamEnabled +
158  ", clientAntispamReplace='" + clientAntispamReplace + '\'' +
159  '}';
160  }
161 
162  private final static boolean DEFAULT_CLIENT_ANTISPAM_ENABLED = false;
163  private final static String DEFAULT_CLIENT_ANTISPAM_REPLACE = "";
164 
165  /**
166  * Builder for {@link V2NIMSendMessageParams}
167  */
168  public static final class V2NIMSendMessageParamsBuilder {
169  private V2NIMMessageConfig messageConfig;
170  private V2NIMMessageRouteConfig routeConfig;
171  private V2NIMMessagePushConfig pushConfig;
172  private V2NIMMessageAntispamConfig antispamConfig;
173  private V2NIMMessageRobotConfig robotConfig;
174  private V2NIMMessageAIConfigParams aiConfig;
175  private V2NIMMessageTargetConfig targetConfig;
176  private boolean clientAntispamEnabled = DEFAULT_CLIENT_ANTISPAM_ENABLED;
177  private String clientAntispamReplace = DEFAULT_CLIENT_ANTISPAM_REPLACE;
178 
179  private V2NIMSendMessageParamsBuilder() {
180  }
181 
182  /**
183  * Create a new {@link V2NIMSendMessageParamsBuilder} instance
184  * @return
185  */
186  public static V2NIMSendMessageParamsBuilder builder() {
187  return new V2NIMSendMessageParamsBuilder();
188  }
189 
190  /**
191  * Set the message config
192  * @param messageConfig the message config
193  * @return V2NIMSendMessageParamsBuilder
194  */
195  public V2NIMSendMessageParamsBuilder withMessageConfig(V2NIMMessageConfig messageConfig) {
196  this.messageConfig = messageConfig;
197  return this;
198  }
199 
200  /**
201  * Set the route config
202  * @param routeConfig the route config
203  * @return V2NIMSendMessageParamsBuilder
204  */
205  public V2NIMSendMessageParamsBuilder withRouteConfig(V2NIMMessageRouteConfig routeConfig) {
206  this.routeConfig = routeConfig;
207  return this;
208  }
209  /**
210  * Set the push config
211  * @param pushConfig the push config
212  * @return V2NIMSendMessageParamsBuilder
213  */
214  public V2NIMSendMessageParamsBuilder withPushConfig(V2NIMMessagePushConfig pushConfig) {
215  this.pushConfig = pushConfig;
216  return this;
217  }
218  /**
219  * Set the antispam config
220  * @param antispamConfig the antispam config
221  * @return V2NIMSendMessageParamsBuilder
222  */
223  public V2NIMSendMessageParamsBuilder withAntispamConfig(V2NIMMessageAntispamConfig antispamConfig) {
224  this.antispamConfig = antispamConfig;
225  return this;
226  }
227  /**
228  * Set the robot config
229  * @param robotConfig the robot config
230  * @return V2NIMSendMessageParamsBuilder
231  */
232  public V2NIMSendMessageParamsBuilder withRobotConfig(V2NIMMessageRobotConfig robotConfig) {
233  this.robotConfig = robotConfig;
234  return this;
235  }
236  /**
237  * Set the client antispam enabled
238  * @param clientAntispamEnabled the client antispam enabled
239  * @return V2NIMSendMessageParamsBuilder
240  */
241  public V2NIMSendMessageParamsBuilder withClientAntispamEnabled(boolean clientAntispamEnabled) {
242  this.clientAntispamEnabled = clientAntispamEnabled;
243  return this;
244  }
245  /**
246  * Set the client antispam replace
247  * @param clientAntispamReplace the client antispam replace
248  * @return V2NIMSendMessageParamsBuilder
249  */
250  public V2NIMSendMessageParamsBuilder withClientAntispamReplace(String clientAntispamReplace) {
251  this.clientAntispamReplace = clientAntispamReplace;
252  return this;
253  }
254  /**
255  * Set the AI config
256  * @param aiConfig the AI config
257  * @return V2NIMSendMessageParamsBuilder
258  */
259  public V2NIMSendMessageParamsBuilder withAIConfig(V2NIMMessageAIConfigParams aiConfig) {
260  this.aiConfig = aiConfig;
261  return this;
262  }
263  /**
264  * Set the target config
265  * @param targetConfig the target config
266  * @return V2NIMSendMessageParamsBuilder
267  */
268  public V2NIMSendMessageParamsBuilder withTargetConfig(V2NIMMessageTargetConfig targetConfig) {
269  this.targetConfig = targetConfig;
270  return this;
271  }
272 
273  public V2NIMSendMessageParams build() {
274  return new V2NIMSendMessageParams(messageConfig, routeConfig, pushConfig, antispamConfig, robotConfig,aiConfig,targetConfig, clientAntispamEnabled, clientAntispamReplace);
275  }
276  }
277 }
V2NIMMessagePushConfig getPushConfig()
获取推送相关配置
boolean isClientAntispamEnabled()
获取是否启用本地反垃圾
V2NIMMessageRobotConfig getRobotConfig()
获取机器人相关配置
V2NIMMessageAIConfigParams getAIConfig()
获取请求大模型的相关参数
V2NIMMessageRouteConfig getRouteConfig()
获取路由相关配置
String getClientAntispamReplace()
获取反垃圾命中后替换的文本
V2NIMMessageTargetConfig getTargetConfig()
获取定向消息相关配置
V2NIMMessageConfig getMessageConfig()
获取消息相关配置
V2NIMMessageAntispamConfig getAntispamConfig()
获取反垃圾相关配置