NIMSDK-AOS  10.5.0
QChatRoleResource.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.qchat.enums;
2 
3 import androidx.annotation.NonNull;
4 import com.netease.nimlib.util.StringUtil;
5 import java.io.Serializable;
6 import java.util.LinkedHashMap;
7 import java.util.Map;
8 import java.util.Objects;
9 
13 public class QChatRoleResource implements Serializable, Comparable<QChatRoleResource> {
17  public static final QChatRoleResource MANAGE_SERVER = new QChatRoleResource(1,1, "MANAGE_SERVER", 0);
21  public static final QChatRoleResource MANAGE_CHANNEL = new QChatRoleResource(2,0, "MANAGE_CHANNEL", 1);
25  public static final QChatRoleResource MANAGE_ROLE = new QChatRoleResource(3,0, "MANAGE_ROLE", 2);
29  public static final QChatRoleResource SEND_MSG = new QChatRoleResource(4,0, "SEND_MSG", 3);
33  public static final QChatRoleResource ACCOUNT_INFO_SELF = new QChatRoleResource(5,1, "ACCOUNT_INFO_SELF", 4);
37  public static final QChatRoleResource INVITE_SERVER = new QChatRoleResource(6,1, "INVITE_SERVER", 5);
41  public static final QChatRoleResource KICK_SERVER = new QChatRoleResource(7,1, "KICK_SERVER", 6);
45  public static final QChatRoleResource ACCOUNT_INFO_OTHER = new QChatRoleResource(8,1, "ACCOUNT_INFO_OTHER", 7);
49  public static final QChatRoleResource RECALL_MSG = new QChatRoleResource(9,0, "RECALL_MSG", 8);
53  public static final QChatRoleResource DELETE_MSG = new QChatRoleResource(10,0, "DELETE_MSG", 9);
57  public static final QChatRoleResource REMIND_OTHER = new QChatRoleResource(11,0, "REMIND_OTHER", 10);
61  public static final QChatRoleResource REMIND_EVERYONE = new QChatRoleResource(12,0, "REMIND_EVERYONE", 11);
65  public static final QChatRoleResource MANAGE_BLACK_WHITE_LIST = new QChatRoleResource(13,0, "MANAGE_BLACK_WHITE_LIST", 12);
69  public static final QChatRoleResource BAN_SERVER_MEMBER = new QChatRoleResource(14,1, "BAN_SERVER_MEMBER", 13);
73  public static final QChatRoleResource RTC_CHANNEL_CONNECT = new QChatRoleResource(15, 0, "RTC_CHANNEL_CONNECT", 14);
77  public static final QChatRoleResource RTC_CHANNEL_DISCONNECT_OTHER = new QChatRoleResource(16, 0, "RTC_CHANNEL_DISCONNECT_OTHER", 15);
81  public static final QChatRoleResource RTC_CHANNEL_OPEN_MICROPHONE = new QChatRoleResource(17, 0, "RTC_CHANNEL_OPEN_MICROPHONE", 16);
85  public static final QChatRoleResource RTC_CHANNEL_OPEN_CAMERA = new QChatRoleResource(18, 0, "RTC_CHANNEL_OPEN_CAMERA", 17);
89  public static final QChatRoleResource RTC_CHANNEL_OPEN_CLOSE_OTHER_MICROPHONE = new QChatRoleResource(19, 0, "RTC_CHANNEL_OPEN_CLOSE_OTHER_MICROPHONE", 18);
93  public static final QChatRoleResource RTC_CHANNEL_OPEN_CLOSE_OTHER_CAMERA = new QChatRoleResource(20, 0, "RTC_CHANNEL_OPEN_CLOSE_OTHER_CAMERA", 19);
97  public static final QChatRoleResource RTC_CHANNEL_OPEN_CLOSE_EVERYONE_MICROPHONE = new QChatRoleResource(21, 0, "RTC_CHANNEL_OPEN_CLOSE_EVERYONE_MICROPHONE", 20);
101  public static final QChatRoleResource RTC_CHANNEL_OPEN_CLOSE_EVERYONE_CAMERA = new QChatRoleResource(22, 0, "RTC_CHANNEL_OPEN_CLOSE_EVERYONE_CAMERA", 21);
105  public static final QChatRoleResource RTC_CHANNEL_OPEN_SCREEN_SHARE = new QChatRoleResource(23, 0, "RTC_CHANNEL_OPEN_SCREEN_SHARE", 22);
109  public static final QChatRoleResource RTC_CHANNEL_CLOSE_OTHER_SCREEN_SHARE = new QChatRoleResource(24, 0, "RTC_CHANNEL_CLOSE_OTHER_SCREEN_SHARE", 23);
113  public static final QChatRoleResource SERVER_APPLY_HANDLE = new QChatRoleResource(25, 1, "SERVER_APPLY_HANDLE", 24);
117  public static final QChatRoleResource INVITE_APPLY_HISTORY_QUERY = new QChatRoleResource(26, 1, "INVITE_APPLY_HISTORY_QUERY", 25);
118 
122  public static final QChatRoleResource MENTIONED_ROLE = new QChatRoleResource(27, 0, "MENTIONED_ROLE", 26);
126  public static final QChatRoleResource MUTE = new QChatRoleResource(28, 0, "MUTE", 27);
127 
129  ;
130 
131  private final int resource;
137  private final int type;
138 
143  public final String name;
148  public final int ordinal;
149  @SuppressWarnings("java:S3599")
150  private static final Map<String, QChatRoleResource> ROLE_MAP = new LinkedHashMap<String, QChatRoleResource>() {
151  {
152  put("MANAGE_SERVER", MANAGE_SERVER);
153  put("MANAGE_CHANNEL", MANAGE_CHANNEL);
154  put("MANAGE_ROLE", MANAGE_ROLE);
155  put("SEND_MSG", SEND_MSG);
156  put("ACCOUNT_INFO_SELF", ACCOUNT_INFO_SELF);
157  put("INVITE_SERVER", INVITE_SERVER);
158  put("KICK_SERVER", KICK_SERVER);
159  put("ACCOUNT_INFO_OTHER", ACCOUNT_INFO_OTHER);
160  put("RECALL_MSG", RECALL_MSG);
161  put("DELETE_MSG", DELETE_MSG);
162  put("REMIND_OTHER", REMIND_OTHER);
163  put("REMIND_EVERYONE", REMIND_EVERYONE);
164  put("MANAGE_BLACK_WHITE_LIST", MANAGE_BLACK_WHITE_LIST);
165  put("BAN_SERVER_MEMBER", BAN_SERVER_MEMBER);
166  put("RTC_CHANNEL_CONNECT", RTC_CHANNEL_CONNECT);
167  put("RTC_CHANNEL_DISCONNECT_OTHER", RTC_CHANNEL_DISCONNECT_OTHER);
168  put("RTC_CHANNEL_OPEN_MICROPHONE", RTC_CHANNEL_OPEN_MICROPHONE);
169  put("RTC_CHANNEL_OPEN_CAMERA", RTC_CHANNEL_OPEN_CAMERA);
170  put("RTC_CHANNEL_OPEN_CLOSE_OTHER_MICROPHONE", RTC_CHANNEL_OPEN_CLOSE_OTHER_MICROPHONE);
171  put("RTC_CHANNEL_OPEN_CLOSE_OTHER_CAMERA", RTC_CHANNEL_OPEN_CLOSE_OTHER_CAMERA);
172  put("RTC_CHANNEL_OPEN_CLOSE_EVERYONE_MICROPHONE", RTC_CHANNEL_OPEN_CLOSE_EVERYONE_MICROPHONE);
173  put("RTC_CHANNEL_OPEN_CLOSE_EVERYONE_CAMERA", RTC_CHANNEL_OPEN_CLOSE_EVERYONE_CAMERA);
174  put("RTC_CHANNEL_OPEN_SCREEN_SHARE", RTC_CHANNEL_OPEN_SCREEN_SHARE);
175  put("RTC_CHANNEL_CLOSE_OTHER_SCREEN_SHARE", RTC_CHANNEL_CLOSE_OTHER_SCREEN_SHARE);
176  put("SERVER_APPLY_HANDLE", SERVER_APPLY_HANDLE);
177  put("INVITE_APPLY_HISTORY_QUERY", INVITE_APPLY_HISTORY_QUERY);
178  put("MENTIONED_ROLE", MENTIONED_ROLE);
179  put("MUTE", MUTE);
180  }
181  };
182 
183 
184  public QChatRoleResource(int resource, int type) {
185  this(resource, type, "", -1);
186  }
187 
188  private QChatRoleResource(int resource, int type, @NonNull String name, int ordinal) {
189  this.resource = resource;
190  this.type = type;
191  this.name = name;
192  this.ordinal = ordinal;
193  }
194 
195  public int value() {
196  return resource;
197  }
198 
203  public boolean isOnlyServerPermission()
204  {
205  return type == 1;
206  }
207 
212  public boolean isOnlyChannelPermission()
213  {
214  return type == 2;
215  }
216 
221  public boolean isAllPermission()
222  {
223  return type == 0;
224  }
225 
230  @NonNull
231  public String name() {
232  return name;
233  }
234 
239  public int ordinal() {
240  return ordinal;
241  }
242 
249  @Override
250  public int compareTo(QChatRoleResource o) {
251  return this.ordinal - o.ordinal;
252  }
253 
259  public final Class<QChatRoleResource> getDeclaringClass() {
260  return QChatRoleResource.class;
261  }
262 
263  @Override
264  @NonNull
265  public String toString() {
266  return StringUtil.isEmpty(name) ? String.valueOf(resource) : name;
267  }
268 
269  @Override
270  public boolean equals(Object o) {
271  if (this == o) {
272  return true;
273  }
274  if (o == null || getClass() != o.getClass()) {
275  return false;
276  }
277  QChatRoleResource resource1 = (QChatRoleResource) o;
278  return resource == resource1.resource && type == resource1.type;
279  }
280 
281  @Override
282  public int hashCode() {
283  return Objects.hash(resource, type);
284  }
285 
286  public static QChatRoleResource getByValue(int value) {
287  for (QChatRoleResource pt : ROLE_MAP.values()) {
288  if (value == pt.value()) {
289  return pt;
290  }
291  }
292  return new QChatRoleResource(value, 0);
293  }
294 
295  public static QChatRoleResource getByName(String name) {
296  return ROLE_MAP.get(name);
297  }
298 
299  public static QChatRoleResource[] values() {
300  QChatRoleResource[] result = new QChatRoleResource[ROLE_MAP.size()];
301  int index = 0;
302  for (QChatRoleResource pt : ROLE_MAP.values()) {
303  result[index++] = pt;
304  }
305  return result;
306  }
307 
308  public static QChatRoleResource valueOf(String name) {
309  return getByName(name);
310  }
311 }
static final QChatRoleResource REMIND_OTHER
@ 他人的权限,server和channel都有
static final QChatRoleResource RTC_CHANNEL_OPEN_CLOSE_OTHER_MICROPHONE
RTC频道:开启/关闭他人麦克风的权限
static final QChatRoleResource RTC_CHANNEL_CONNECT
RTC频道:连接的权限
static final QChatRoleResource RTC_CHANNEL_OPEN_CLOSE_OTHER_CAMERA
RTC频道:开启/关闭他人摄像头的权限
int compareTo(QChatRoleResource o)
模拟枚举类型的对比方法
static final QChatRoleResource BAN_SERVER_MEMBER
封禁他人的权限,仅server有,允许成员永久封禁其他成员访问此服务器
static final QChatRoleResource DELETE_MSG
删除他人消息的权限,server和channel都有
static final QChatRoleResource RTC_CHANNEL_DISCONNECT_OTHER
RTC频道:断开他人连接的权限
static final QChatRoleResource SERVER_APPLY_HANDLE
服务器申请处理权限
static final QChatRoleResource RTC_CHANNEL_OPEN_CAMERA
RTC频道:开启摄像头的权限
static final QChatRoleResource RTC_CHANNEL_CLOSE_OTHER_SCREEN_SHARE
RTC频道:关闭他人屏幕共享的权限
static final QChatRoleResource INVITE_SERVER
邀请他人进入server的,仅server有
static final QChatRoleResource RTC_CHANNEL_OPEN_CLOSE_EVERYONE_CAMERA
RTC频道:开启/关闭全员摄像头的权限
static final QChatRoleResource MENTIONED_ROLE
@身份组的权限,server和channel都有
static final QChatRoleResource MANAGE_CHANNEL
管理频道,server和channel都有
static final QChatRoleResource ACCOUNT_INFO_SELF
修改自己在该server的服务器成员信息,仅server有
static final QChatRoleResource INVITE_APPLY_HISTORY_QUERY
申请邀请历史查看权限,有这个权限才可以查询server级别的申请/邀请记录
static final QChatRoleResource MANAGE_SERVER
管理服务器:修改服务器,仅server有
boolean isOnlyChannelPermission()
是否是仅Channel才拥有的权限
boolean isOnlyServerPermission()
是否是仅Server才拥有的权限
static final QChatRoleResource SEND_MSG
发送消息,server和channel都有
final Class< QChatRoleResource > getDeclaringClass()
模拟枚举类型的对应方法
static final QChatRoleResource RTC_CHANNEL_OPEN_CLOSE_EVERYONE_MICROPHONE
RTC频道:开启/关闭全员麦克风的权限
static final QChatRoleResource RTC_CHANNEL_OPEN_MICROPHONE
RTC频道:开启麦克风的权限
static final QChatRoleResource RECALL_MSG
撤回他人消息的权限,server和channel都有
static final QChatRoleResource MANAGE_BLACK_WHITE_LIST
管理黑白名单的权限,server和channel都有
static final QChatRoleResource MANAGE_ROLE
管理身份组的权限,server和channel都有
static final QChatRoleResource REMIND_EVERYONE
@ everyone,server和channel都有
boolean isAllPermission()
是否是Server和Channel都拥有的权限
static QChatRoleResource getByName(String name)
static final QChatRoleResource RTC_CHANNEL_OPEN_SCREEN_SHARE
RTC频道:打开自己屏幕共享的权限
static final QChatRoleResource MUTE
禁言权限
static final QChatRoleResource ACCOUNT_INFO_OTHER
修改他人在该server的服务器成员信息,仅server有
final String name
模拟枚举类型的变量名
static final QChatRoleResource KICK_SERVER
踢除他人的权限,仅server有