NIMSDK-AOS  10.9.90
V2NIMMessagePushConfig.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.v2.message.config;
2 
3 import com.netease.nimlib.log.NimLog;
4 import com.netease.nimlib.util.EncryptUtil;
5 import java.io.Serializable;
6 import java.util.List;
7 
8 public class V2NIMMessagePushConfig implements Serializable {
9  // 是否需要推送消息。
10  private final boolean pushEnabled;
11 
12  // 是否需要推送消息发送者昵称。
13  private final boolean pushNickEnabled;
14 
15  // 推送文案
16  private final String pushContent;
17 
18  // 推送数据
19  private final String pushPayload;
20 
21  // 强制推送,忽略用户消息提醒相关设置,只消息类型有效
22  private final boolean forcePush;
23 
24  // 强制推送文案,只消息类型有效
25  private final String forcePushContent;
26 
27  // 强制推送目标账号列表,只消息类型有效
28  private final List<String> forcePushAccountIds;
29 
30  private V2NIMMessagePushConfig() {
31  this(DEFAULT_PUSH_ENABLE, DEFAULT_PUSH_NICK_ENABLE, null, null, false, null, null);
32  }
33 
34  private V2NIMMessagePushConfig(boolean pushEnabled, boolean pushNickEnabled, String pushContent, String pushPayload, boolean forcePush, String forcePushContent, List<String> forcePushAccountIds) {
35  this.pushEnabled = pushEnabled;
36  this.pushNickEnabled = pushNickEnabled;
37  this.pushContent = pushContent;
38  this.pushPayload = pushPayload;
39  this.forcePush = forcePush;
40  this.forcePushContent = forcePushContent;
41  this.forcePushAccountIds = forcePushAccountIds;
42  }
43 
44  public boolean isPushEnabled() {
45  return pushEnabled;
46  }
47 
48  public boolean isPushNickEnabled() {
49  return pushNickEnabled;
50  }
51 
52  public String getPushContent() {
53  return pushContent;
54  }
55 
56  public String getPushPayload() {
57  return pushPayload;
58  }
59 
60  public boolean isForcePush() {
61  return forcePush;
62  }
63 
64  public String getForcePushContent() {
65  return forcePushContent;
66  }
67 
68  public List<String> getForcePushAccountIds() {
69  return forcePushAccountIds;
70  }
71 
72  @Override
73  public String toString() {
74  if (NimLog.isDebugLog()) {
75  return "V2NIMMessagePushConfig{" +
76  "pushEnabled=" + pushEnabled +
77  ", pushNickEnabled=" + pushNickEnabled +
78  ", content='" + pushContent + '\'' +
79  ", payload='" + pushPayload + '\'' +
80  ", forcePush=" + forcePush +
81  ", forcePushContent='" + forcePushContent + '\'' +
82  ", forcePushAccountIds=" + forcePushAccountIds +
83  '}';
84  }else {
85  return "V2NIMMessagePushConfig{" +
86  "pushEnabled=" + pushEnabled +
87  ", pushNickEnabled=" + pushNickEnabled +
88  ", content='" + EncryptUtil.encryptBase64(pushContent) + '\'' +
89  ", payload='" + EncryptUtil.encryptBase64(pushPayload) + '\'' +
90  ", forcePush=" + forcePush +
91  ", forcePushContent='" + "*******" + '\'' +
92  ", forcePushAccountIds=" + forcePushAccountIds +
93  '}';
94  }
95 
96  }
97 
98  public static final boolean DEFAULT_PUSH_ENABLE = true;
99  public static final boolean DEFAULT_PUSH_NICK_ENABLE = true;
100 
101  public static final class V2NIMMessagePushConfigBuilder {
102  private boolean pushEnabled = DEFAULT_PUSH_ENABLE;
103  private boolean pushNickEnabled = DEFAULT_PUSH_NICK_ENABLE;
104  private String content;
105  private String payload;
106  private boolean forcePush;
107  private String forcePushContent;
108  private List<String> forcePushAccountIds;
109 
110  private V2NIMMessagePushConfigBuilder() {
111  }
112 
113  public static V2NIMMessagePushConfigBuilder builder() {
114  return new V2NIMMessagePushConfigBuilder();
115  }
116 
117  public V2NIMMessagePushConfigBuilder withPushEnabled(boolean pushEnabled) {
118  this.pushEnabled = pushEnabled;
119  return this;
120  }
121 
122  public V2NIMMessagePushConfigBuilder withPushNickEnabled(boolean pushNickEnabled) {
123  this.pushNickEnabled = pushNickEnabled;
124  return this;
125  }
126 
127  public V2NIMMessagePushConfigBuilder withContent(String content) {
128  this.content = content;
129  return this;
130  }
131 
132  public V2NIMMessagePushConfigBuilder withPayload(String payload) {
133  this.payload = payload;
134  return this;
135  }
136 
137  public V2NIMMessagePushConfigBuilder withForcePush(boolean forcePush) {
138  this.forcePush = forcePush;
139  return this;
140  }
141 
142  public V2NIMMessagePushConfigBuilder withForcePushContent(String forcePushContent) {
143  this.forcePushContent = forcePushContent;
144  return this;
145  }
146 
147  public V2NIMMessagePushConfigBuilder withForcePushAccountIds(List<String> forcePushAccountIds) {
148  this.forcePushAccountIds = forcePushAccountIds;
149  return this;
150  }
151 
152  public V2NIMMessagePushConfig build() {
153  return new V2NIMMessagePushConfig(pushEnabled, pushNickEnabled, content, payload, forcePush, forcePushContent, forcePushAccountIds);
154  }
155  }
156 }