NIMSDK-AOS  10.9.80
V2NIMChatroomTagMessageOption.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.v2.chatroom.option;
2 
5 import com.netease.nimlib.util.CollectionUtil;
6 import java.io.Serializable;
7 import java.util.List;
8 
9 /**
10  * 根据tag查询消息参数
11  */
12 public class V2NIMChatroomTagMessageOption implements Serializable {
13 
14  /**
15  * 查询的tags, 为空,或者size为0, 返回参数错误
16  */
17  private List<String> tags;
18  /**
19  * 根据消息类型查询消息, 为null或空列表, 则表示查询所有消息类型
20  */
21  private List<V2NIMMessageType> messageTypes;
22  /**
23  * 消息查询开始时间,首次传0,单位毫秒
24  */
25  private Long beginTime;
26  /**
27  * 消息查询结束时间,默认当前时间,单位毫秒
28  */
29  private Long endTime;
30  /**
31  * 每次查询条数
32  * 必须大于 0, 小于等于0报参数错误
33  */
34  private Integer limit;
35  /**
36  * 消息查询方向, 默认为{@link V2NIMMessageQueryDirection#V2NIM_QUERY_DIRECTION_DESC}
37  */
38  private V2NIMMessageQueryDirection direction;
39 
40  /**
41  * 获取查询的tags
42  * @return 查询的tags, 为空,或者size为0, 返回参数错误
43  */
44  public List<String> getTags() {
45  return tags;
46  }
47 
48  /**
49  * 获取根据消息类型查询消息, 为null或空列表, 则表示查询所有消息类型
50  * @return 根据消息类型查询消息, 为null或空列表, 则表示查询所有消息类型
51  */
52  public List<V2NIMMessageType> getMessageTypes() {
53  return messageTypes;
54  }
55 
56  /**
57  * 获取消息查询开始时间,首次传0,单位毫秒
58  * @return 消息查询开始时间,首次传0,单位毫秒
59  */
60  public long getBeginTime() {
61  if(beginTime == null){
62  return 0;
63  }
64  return beginTime;
65  }
66 
67  /**
68  * 获取消息查询结束时间,默认当前时间,单位毫秒
69  * @return 消息查询结束时间,默认当前时间,单位毫秒
70  */
71  public long getEndTime() {
72  if(endTime == null){
73  return 0;
74  }
75  return endTime;
76  }
77 
78  /**
79  * 获取每次查询条数
80  * @return 每次查询条数
81  */
82  public Integer getLimit() {
83  if(limit == null){
84  return 100;
85  }
86  return limit;
87  }
88 
89  /**
90  * 获取消息查询方向, 默认为{@link V2NIMMessageQueryDirection#V2NIM_QUERY_DIRECTION_DESC}
91  * @return 消息查询方向, 默认为{@link V2NIMMessageQueryDirection#V2NIM_QUERY_DIRECTION_DESC}
92  */
94  if(direction == null){
96  }
97  return direction;
98  }
99 
100  /**
101  * 设置查询的tags, 为空,或者size为0, 返回参数错误
102  * @param tags
103  */
104  public void setTags(List<String> tags) {
105  this.tags = tags;
106  }
107 
108  /**
109  * 设置根据消息类型查询消息, 为null或空列表, 则表示查询所有消息类型
110  * @param messageTypes
111  */
112  public void setMessageTypes(List<V2NIMMessageType> messageTypes) {
113  this.messageTypes = messageTypes;
114  }
115 
116  /**
117  * 设置消息查询开始时间,首次传0,单位毫秒
118  * @param beginTime
119  */
120  public void setBeginTime(Long beginTime) {
121  this.beginTime = beginTime;
122  }
123 
124  /**
125  * 设置消息查询结束时间,默认当前时间,单位毫秒
126  * @param endTime
127  */
128  public void setEndTime(Long endTime) {
129  this.endTime = endTime;
130  }
131 
132  /**
133  * 设置每次查询条数
134  * @param limit
135  */
136  public void setLimit(Integer limit) {
137  this.limit = limit;
138  }
139 
140  /**
141  * 设置消息查询方向, 默认为{@link V2NIMMessageQueryDirection#V2NIM_QUERY_DIRECTION_DESC}
142  * @param direction
143  */
144  public void setDirection(V2NIMMessageQueryDirection direction) {
145  this.direction = direction;
146  }
147 
148  public boolean isValid() {
149  if(CollectionUtil.isEmpty(tags)){
150  return false;
151  }
152  if(getLimit() <= 0){
153  return false;
154  }
155  if(getEndTime() > 0 && getBeginTime() > getEndTime()){
156  return false;
157  }
158  if(messageTypes != null && messageTypes.contains(null)){
159  return false;
160  }
161  return true;
162  }
163 }
void setEndTime(Long endTime)
设置消息查询结束时间,默认当前时间,单位毫秒
List< V2NIMMessageType > getMessageTypes()
获取根据消息类型查询消息, 为null或空列表, 则表示查询所有消息类型
void setBeginTime(Long beginTime)
设置消息查询开始时间,首次传0,单位毫秒
void setDirection(V2NIMMessageQueryDirection direction)
设置消息查询方向, 默认为V2NIMMessageQueryDirection#V2NIM_QUERY_DIRECTION_DESC
long getBeginTime()
获取消息查询开始时间,首次传0,单位毫秒
void setMessageTypes(List< V2NIMMessageType > messageTypes)
设置根据消息类型查询消息, 为null或空列表, 则表示查询所有消息类型
V2NIMMessageQueryDirection getDirection()
获取消息查询方向, 默认为V2NIMMessageQueryDirection#V2NIM_QUERY_DIRECTION_DESC
long getEndTime()
获取消息查询结束时间,默认当前时间,单位毫秒
void setTags(List< String > tags)
设置查询的tags, 为空,或者size为0, 返回参数错误