NIMSDK-AOS  10.9.76
V2NIMChatroomMessageListOption.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.v2.chatroom.option;
2 
5 import java.io.Serializable;
6 import java.util.List;
7 
8 /**
9  * 聊天室消息查询选项
10  */
11 public class V2NIMChatroomMessageListOption implements Serializable {
12  /**
13  * 消息查询方向, 默认为{@link V2NIMMessageQueryDirection#V2NIM_QUERY_DIRECTION_DESC}
14  */
15  private V2NIMMessageQueryDirection direction;
16  /**
17  * 根据消息类型查询消息, 为null或空列表, 则表示查询所有消息类型
18  */
19  private List<V2NIMMessageType> messageTypes;
20  /**
21  * 消息查询开始时间,首次传0,单位毫秒
22  */
23  private Long beginTime;
24  /**
25  * 每次查询条数
26  */
27  private Integer limit;
28 
30  }
31 
32  /**
33  *
34  * @param direction 消息查询方向
35  * @param messageTypes 根据消息类型查询消息, 为null或空列表, 则表示查询所有消息类型
36  * @param beginTime 消息查询开始时间,首次传0,单位毫秒
37  * @param limit 每次查询条数
38  */
39  public V2NIMChatroomMessageListOption(V2NIMMessageQueryDirection direction, List<V2NIMMessageType> messageTypes, long beginTime, int limit) {
40  this.direction = direction;
41  this.messageTypes = messageTypes;
42  this.beginTime = beginTime;
43  this.limit = limit;
44  }
45 
46  /**
47  * 获取消息查询方向
48  * @return 消息查询方向
49  */
51  if(direction == null) {
53  }
54  else {
55  return direction;
56  }
57  }
58 
59  /**
60  * 获取查询消息的类型列表
61  * @return 查询消息的类型列表
62  */
63  public List<V2NIMMessageType> getMessageTypes() {
64  return messageTypes;
65  }
66 
67  /**
68  * 获取消息查询开始时间
69  * @return 消息查询开始时间
70  */
71  public long getBeginTime() {
72  if (beginTime == null) {
73  return 0;
74  }
75  return beginTime;
76  }
77 
78  /**
79  * 获取每次查询条数
80  * @return 每次查询条数
81  */
82  public int getLimit() {
83  if (limit == null) {
84  return 100;
85  }
86  return limit;
87  }
88 
89  /**
90  * 设置消息查询方向
91  * @param direction 消息查询方向
92  */
93  public void setDirection(V2NIMMessageQueryDirection direction) {
94  this.direction = direction;
95  }
96 
97  /**
98  * 设置查询消息的类型列表
99  * @param messageTypes 查询消息的类型列表
100  */
101  public void setMessageTypes(List<V2NIMMessageType> messageTypes) {
102  this.messageTypes = messageTypes;
103  }
104 
105  /**
106  * 设置消息查询开始时间
107  * @param beginTime 消息查询开始时间
108  */
109  public void setBeginTime(long beginTime) {
110  this.beginTime = beginTime;
111  }
112 
113  /**
114  * 设置每次查询条数
115  * @param limit 每次查询条数
116  */
117  public void setLimit(int limit) {
118  this.limit = limit;
119  }
120 
121  public boolean isValid() {
122  if(messageTypes != null && messageTypes.contains(null)){
123  return false;
124  }
125  if(getLimit() <= 0){
126  return false;
127  }
128  return true;
129  }
130 }
List< V2NIMMessageType > getMessageTypes()
获取查询消息的类型列表
void setDirection(V2NIMMessageQueryDirection direction)
设置消息查询方向
V2NIMChatroomMessageListOption(V2NIMMessageQueryDirection direction, List< V2NIMMessageType > messageTypes, long beginTime, int limit)
void setMessageTypes(List< V2NIMMessageType > messageTypes)
设置查询消息的类型列表