NIMSDK-AOS  10.9.90
V2NIMAddCollectionParams.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.v2.message.params;
2 
3 /**
4  * 添加收藏参数
5  */
7 
8  /**
9  * 收藏类型
10  * 必须大于 0, 可以按该字段分类
11  */
12  private final int collectionType;
13  /**
14  * 收藏数据
15  * 最大 20480 字节
16  */
17  private final String collectionData;
18  /**
19  * 扩展字段
20  * 最大1024 字节
21  */
22  private final String serverExtension;
23  /**
24  * 去重唯一ID, 如果ID相同, 则不会新增收藏,只更新之前的收藏内容
25  */
26  private final String uniqueId;
27 
28  private V2NIMAddCollectionParams() {
29  this(0, "", null,null);
30  }
31 
32  private V2NIMAddCollectionParams(int collectionType, String collectionData, String serverExtension,String uniqueId) {
33  this.collectionType = collectionType;
34  this.collectionData = collectionData;
35  this.serverExtension = serverExtension;
36  this.uniqueId = uniqueId;
37  }
38 
39  /**
40  * 获取收藏类型
41  * @return 收藏类型
42  */
43  public int getCollectionType() {
44  return collectionType;
45  }
46 
47  /**
48  * 获取收藏数据
49  * @return 收藏数据
50  */
51  public String getCollectionData() {
52  return collectionData;
53  }
54 
55  /**
56  * 获取扩展字段
57  * @return 扩展字段
58  */
59  public String getServerExtension() {
60  return serverExtension;
61  }
62 
63  /**
64  * 获取去重唯一ID
65  * @return 去重唯一ID,如果ID相同, 则不会新增收藏,只更新之前的收藏内容
66  */
67  public String getUniqueId() {
68  return uniqueId;
69  }
70 
71  @Override
72  public String toString() {
73  return "V2NIMAddCollectionParams{" +
74  "collectionType=" + collectionType +
75  ", collectionData='" + collectionData + '\'' +
76  ", serverExtension='" + serverExtension + '\'' +
77  ", uniqueId='" + uniqueId + '\'' +
78  '}';
79  }
80 
81  /**
82  * 添加收藏参数构造器
83  */
84  public static final class V2NIMAddCollectionParamsBuilder {
85  private final int collectionType;
86  private final String collectionData;
87  private String serverExtension;
88  private String uniqueId;
89 
90  private V2NIMAddCollectionParamsBuilder(int collectionType, String collectionData) {
91  this.collectionType = collectionType;
92  this.collectionData = collectionData;
93  }
94 
95  /**
96  * 创建添加收藏参数构造器
97  * @param collectionType 收藏类型
98  * @param collectionData 收藏数据
99  * @return V2NIMAddCollectionParamsBuilder
100  */
101  public static V2NIMAddCollectionParamsBuilder builder(int collectionType, String collectionData) {
102  return new V2NIMAddCollectionParamsBuilder(collectionType, collectionData);
103  }
104 
105  /**
106  * 设置扩展字段
107  * @param serverExtension 扩展字段
108  * @return V2NIMAddCollectionParamsBuilder
109  */
110  public V2NIMAddCollectionParamsBuilder withServerExtension(String serverExtension) {
111  this.serverExtension = serverExtension;
112  return this;
113  }
114 
115  /**
116  * 设置去重唯一ID
117  * @param uniqueId 去重唯一ID
118  * @return V2NIMAddCollectionParamsBuilder
119  */
120  public V2NIMAddCollectionParamsBuilder withUniqueId(String uniqueId) {
121  this.uniqueId = uniqueId;
122  return this;
123  }
124 
125  /**
126  * 构建添加收藏参数
127  * @return V2NIMAddCollectionParams
128  */
129  public V2NIMAddCollectionParams build() {
130  return new V2NIMAddCollectionParams(collectionType, collectionData, serverExtension,uniqueId);
131  }
132  }
133 }