NIMSDK-AOS  10.10.13
V2NIMClearLocalMessageParams.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.v2.message.params;
2 
3 import java.util.Objects;
4 
5 /**
6  * V2NIM 清空本地消息参数类
7  * 用于配置清空本地消息的相关参数,包括时间范围和是否删除会话入口
8  */
10 
11 
12  /**
13  * 清理指定时间之前的所有消息
14  * 默认值为0 , 表示当前时间,表示清理当前时间之前的所有消息
15  * 单位:毫秒
16  */
17  private long anchorTime = 0;
18 
19  /**
20  * 是否同步删除会话入口,主要删除本地会话
21  * true:表示会同步删除时间段内相关的会话入口
22  * false:会话入口会保留
23  * 默认值:false
24  */
25  private boolean deleteConversation = false;
26 
27  /**
28  * 默认构造函数
29  */
31  }
32 
33  /**
34  * 带参数的构造函数
35  *
36  * @param anchorTime 清空的时间范围的结束时间(毫秒)
37  * @param deleteConversation 是否删除会话入口
38  */
39  public V2NIMClearLocalMessageParams(long anchorTime, boolean deleteConversation) {
40  this.anchorTime = anchorTime;
41  this.deleteConversation = deleteConversation;
42  }
43 
44  /**
45  * 获取清空的时间范围的结束时间
46  * @return 结束时间(毫秒)
47  */
48  public long getAnchorTime() {
49  return anchorTime;
50  }
51 
52  /**
53  * 设置清空的时间范围的结束时间
54  * @param anchorTime 结束时间(毫秒)
55  */
56  public void setAnchorTime(long anchorTime) {
57  this.anchorTime = anchorTime;
58  if(this.anchorTime < 0){
59  this.anchorTime = 0;
60  }
61  }
62 
63  /**
64  * 获取是否同步删除会话入口的标志
65  *
66  * @return true表示会同步删除时间段内相关的会话入口,false表示会话入口会保留
67  */
68  public boolean isDeleteConversation() {
69  return deleteConversation;
70  }
71 
72  /**
73  * 设置是否同步删除会话入口
74  *
75  * @param deleteConversation true表示会同步删除时间段内相关的会话入口,false表示会话入口会保留
76  */
77  public void setDeleteConversation(boolean deleteConversation) {
78  this.deleteConversation = deleteConversation;
79  }
80 
81  /**
82  * 参数校验方法
83  *
84  * @return true表示参数有效,false表示参数无效
85  */
86  public boolean isValid() {
87  return anchorTime >= 0;
88  }
89 
90  /**
91  * 重写toString方法,便于调试和日志输出
92  *
93  * @return 对象的字符串表示
94  */
95  @Override
96  public String toString() {
97  return "V2NIMClearLocalMessageParams{" +
98  "anchorTime=" + anchorTime +
99  ", deleteConversation=" + deleteConversation +
100  '}';
101  }
102 
103  /**
104  * 重写equals方法
105  *
106  * @param obj 比较对象
107  * @return 是否相等
108  */
109  @Override
110  public boolean equals(Object obj) {
111  if (this == obj) {
112  return true;
113  }
114  if (obj == null || getClass() != obj.getClass()) {
115  return false;
116  }
117 
119 
120  return anchorTime == that.anchorTime &&
121  deleteConversation == that.deleteConversation;
122  }
123 
124  /**
125  * 重写hashCode方法
126  *
127  * @return 哈希码
128  */
129  @Override
130  public int hashCode() {
131  return Objects.hash(anchorTime, deleteConversation);
132  }
133 }
V2NIMClearLocalMessageParams(long anchorTime, boolean deleteConversation)
带参数的构造函数
void setAnchorTime(long anchorTime)
设置清空的时间范围的结束时间
void setDeleteConversation(boolean deleteConversation)
设置是否同步删除会话入口
V2NIM 清空本地消息参数类 用于配置清空本地消息的相关参数,包括时间范围和是否删除会话入口 ...
String toString()
重写toString方法,便于调试和日志输出
boolean isDeleteConversation()
获取是否同步删除会话入口的标志