1 package com.netease.nimlib.sdk.msg.model;
3 import androidx.annotation.NonNull;
4 import androidx.annotation.Nullable;
13 import java.io.Serializable;
14 import java.util.ArrayList;
15 import java.util.List;
25 private final String sessionId;
34 private long fromTime;
46 private long anchorServerId;
51 private String anchorClientId;
64 private List<MsgTypeEnum> messageTypes;
65 private boolean strictMode;
72 this(sessionId, sessionType, fromTime, toTime, anchorServerId, anchorClientId, limit, direction, null,
false);
76 this.sessionId = sessionId;
77 this.sessionType = sessionType;
78 this.fromTime = fromTime;
80 this.anchorServerId = anchorServerId;
81 this.anchorClientId = anchorClientId;
83 this.direction = direction;
84 this.messageTypes = messageTypes;
85 this.strictMode = strictMode;
103 this.fromTime = fromTime;
111 this.toTime = toTime;
115 return anchorServerId;
119 this.anchorServerId = anchorServerId;
123 return anchorClientId;
127 this.anchorClientId = anchorClientId;
143 this.direction = direction;
151 this.messageTypes = messageTypes;
159 this.strictMode = strictMode;
168 if (StringUtil.isNotEmpty(clientId)) {
169 IMMessage anchor = MsgDBHelper.queryMessageByUuid(clientId);
170 if (anchor != null) {
186 String formedSessionId = this.sessionId;
188 long formedFromTime = this.fromTime;
189 long formedToTime = this.toTime;
190 long formedExcludeServerId = this.anchorServerId;
191 String formedExcludeClientId = this.anchorClientId;
192 int formedLimit = this.limit;
198 List<MsgTypeEnum>msgTypes = this.messageTypes == null ?
new ArrayList<>(0) : this.messageTypes;
199 return new GetMessagesDynamicallyParam(formedSessionId, formedSessionType, formedFromTime, formedToTime, formedExcludeServerId, formedExcludeClientId, formedLimit, formedDirection, msgTypes, this.strictMode);
208 return StringUtil.isNotEmpty(sessionId)
212 && (toTime == 0 || toTime >= fromTime)
213 && limit >= 0 && limit <= MAX_LIMIT
214 && (anchorServerId == 0 || StringUtil.isNotEmpty(anchorClientId));
219 return "GetMessagesDynamicallyParam{" +
220 "sessionId='" + sessionId +
'\'' +
221 ", sessionType=" + sessionType +
222 ", fromTime=" + fromTime +
223 ", toTime=" + toTime +
224 ", excludeServerId=" + anchorServerId +
225 ", excludeClientId='" + anchorClientId +
'\'' +
227 ", direction=" + direction +
228 ", messageTypes=" + messageTypes +
229 ", strictMode=" + strictMode +
void setAnchorServerId(long anchorServerId)
GetMessagesDynamicallyParam(@NonNull String sessionId, @NonNull SessionTypeEnum sessionType, long fromTime, long toTime, long anchorServerId, String anchorClientId, int limit, @Nullable GetMessageDirectionEnum direction, @Nullable List< MsgTypeEnum > messageTypes, boolean strictMode)
void setStrictMode(boolean strictMode)
void setFromTime(long fromTime)
云信 IM 消息构造器,提供构建各类型消息的接口。
void setAnchorClientId(String anchorClientId)
String getAnchorClientId()
NIM消息实体数据结构。 第三方APP不要调用设置类接口,调用之后不会被持久化
GetMessageDirectionEnum getDirection()
GetMessagesDynamicallyParam createStandardizedParam(boolean checkLimit)
static final int MAX_LIMIT
最大数量限制
static IMMessage createEmptyMessage(String sessionId, SessionTypeEnum sessionType, long time)
创建一条空消息。
boolean isValid()
参数合法的初阶判断函数
GetMessagesDynamicallyParam createStandardizedParam()
void setMessageTypes(List< MsgTypeEnum > messageTypes)
void setToTime(long toTime)
GetMessagesDynamicallyParam(@NonNull String sessionId, @NonNull SessionTypeEnum sessionType, long fromTime, long toTime, long anchorServerId, String anchorClientId, int limit, @Nullable GetMessageDirectionEnum direction)
void setDirection(GetMessageDirectionEnum direction)
IMMessage getAnchor()
可能会查询数据库
List< MsgTypeEnum > getMessageTypes()
GetMessagesDynamicallyParam(@NonNull String sessionId, @NonNull SessionTypeEnum sessionType)
SessionTypeEnum getSessionType()