NIMSDK-AOS  9.16.0
QChatSearchServerByPageParam.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.qchat.param;
2 
3 import androidx.annotation.NonNull;
4 import androidx.annotation.Nullable;
7 import com.netease.nimlib.util.CollectionUtil;
8 import com.netease.nimlib.util.StringUtil;
9 import java.util.List;
10 
15 
19  @NonNull
20  private final String keyword;
21 
25  private final boolean asc;
26 
30  @NonNull
31  private final QChatSearchServerTypeEnum searchType;
32 
36  @Nullable
37  private Long startTime;
38 
42  @Nullable
43  private Long endTime;
44 
48  @Nullable
49  private Integer limit;
50 
54  @Nullable
55  private List<Integer> serverTypes;
59  private QChatServerSearchSortEnum sort;
63  private String cursor;
64 
72  public QChatSearchServerByPageParam(@NonNull String keyword, boolean asc, @NonNull QChatSearchServerTypeEnum searchType) {
73  this(keyword, asc, searchType, null, null, null, null);
74  }
75 
87  public QChatSearchServerByPageParam(@NonNull String keyword, boolean asc, @NonNull QChatSearchServerTypeEnum searchType, @Nullable Long startTime, @Nullable Long endTime, @Nullable Integer limit, @Nullable List<Integer> serverTypes) {
88  this.keyword = keyword;
89  this.asc = asc;
90  this.searchType = searchType;
91  this.startTime = startTime;
92  this.endTime = endTime;
93  this.limit = limit;
94  this.serverTypes = serverTypes;
95  }
96 
109  public QChatSearchServerByPageParam(@NonNull String keyword, boolean asc, @NonNull QChatSearchServerTypeEnum searchType, @Nullable Long startTime, @Nullable Long endTime, @Nullable Integer limit, @Nullable List<Integer> serverTypes,@Nullable String cursor) {
110  this.keyword = keyword;
111  this.asc = asc;
112  this.searchType = searchType;
113  this.startTime = startTime;
114  this.endTime = endTime;
115  this.limit = limit;
116  this.serverTypes = serverTypes;
117  this.cursor = cursor;
118  }
119 
133  public QChatSearchServerByPageParam(@NonNull String keyword, boolean asc,
134  @NonNull QChatSearchServerTypeEnum searchType, @Nullable Long startTime, @Nullable Long endTime, @Nullable Integer limit,
135  @Nullable List<Integer> serverTypes, QChatServerSearchSortEnum sort,@Nullable String cursor) {
136  this.keyword = keyword;
137  this.asc = asc;
138  this.searchType = searchType;
139  this.startTime = startTime;
140  this.endTime = endTime;
141  this.limit = limit;
142  this.serverTypes = serverTypes;
143  this.sort = sort;
144  this.cursor = cursor;
145  }
146 
150  public String getKeyword() {
151  return keyword;
152  }
153 
157  public boolean isAsc() {
158  return asc;
159  }
160 
165  return searchType;
166  }
167 
171  @Nullable
172  public Long getStartTime() {
173  return startTime;
174  }
175 
180  public void setStartTime(@Nullable Long startTime) {
181  this.startTime = startTime;
182  }
183 
187  @Nullable
188  public Long getEndTime() {
189  return endTime;
190  }
191 
196  public void setEndTime(@Nullable Long endTime) {
197  this.endTime = endTime;
198  }
199 
203  @Nullable
204  public Integer getLimit() {
205  return limit;
206  }
207 
212  public void setLimit(@Nullable Integer limit) {
213  this.limit = limit;
214  }
215 
219  @Nullable
220  public List<Integer> getServerTypes() {
221  return serverTypes;
222  }
223 
228  public void setServerTypes(@Nullable List<Integer> serverTypes) {
229  this.serverTypes = serverTypes;
230  }
231 
237  return sort;
238  }
239 
244  public void setSort(QChatServerSearchSortEnum sort) {
245  this.sort = sort;
246  }
247 
252  public String getCursor() {
253  return cursor;
254  }
255 
260  public void setCursor(String cursor) {
261  this.cursor = cursor;
262  }
263 
267  public boolean isValid() {
268  if (StringUtil.isEmpty(keyword)) {
269  return false;
270  }
271  if (searchType == null || searchType == QChatSearchServerTypeEnum.undefined) {
272  return false;
273  }
274  if (startTime != null && startTime < 0) {
275  return false;
276  }
277 
278  if (endTime != null && endTime < 0) {
279  return false;
280  }
281 
282  if (limit != null && limit < 0) {
283  return false;
284  }
285 
286  if (CollectionUtil.isBlank(serverTypes)) {
287  return false;
288  } else if (CollectionUtil.contains(serverTypes, value -> value == null || value <= 0)){
289  return false;
290  }
291 
292  return true;
293  }
294 
295  @Override
296  public String toString() {
297  return "QChatSearchServerByPageParam{" +
298  "keyword='" + keyword + '\'' +
299  ", asc=" + asc +
300  ", searchType=" + searchType +
301  ", startTime=" + startTime +
302  ", endTime=" + endTime +
303  ", limit=" + limit +
304  ", serverTypes=" + serverTypes +
305  ", sort=" + sort +
306  ", cursor='" + cursor + '\'' +
307  '}';
308  }
309 }
QChatSearchServerByPageParam(@NonNull String keyword, boolean asc, @NonNull QChatSearchServerTypeEnum searchType, @Nullable Long startTime, @Nullable Long endTime, @Nullable Integer limit, @Nullable List< Integer > serverTypes, @Nullable String cursor)
构造函数
QChatSearchServerByPageParam(@NonNull String keyword, boolean asc, @NonNull QChatSearchServerTypeEnum searchType)
构造函数
void setSort(QChatServerSearchSortEnum sort)
设置排序条件
void setLimit(@Nullable Integer limit)
设置检索返回的最大记录数
void setEndTime(@Nullable Long endTime)
设置查询时间范围的结束时间
void setCursor(String cursor)
设置查询游标,下次查询的起始位置,第一页设置为null,查询下一页是传入上一页返回的cursor ...
QChatSearchServerByPageParam(@NonNull String keyword, boolean asc, @NonNull QChatSearchServerTypeEnum searchType, @Nullable Long startTime, @Nullable Long endTime, @Nullable Integer limit, @Nullable List< Integer > serverTypes, QChatServerSearchSortEnum sort, @Nullable String cursor)
构造函数
QChatSearchServerByPageParam(@NonNull String keyword, boolean asc, @NonNull QChatSearchServerTypeEnum searchType, @Nullable Long startTime, @Nullable Long endTime, @Nullable Integer limit, @Nullable List< Integer > serverTypes)
构造函数
void setServerTypes(@Nullable List< Integer > serverTypes)
设置服务器类型
void setStartTime(@Nullable Long startTime)
设置查询时间范围的开始时间