1 package org
.asamk
.signal
.manager
.api
;
3 import org
.whispersystems
.signalservice
.internal
.util
.Util
;
5 import java
.util
.Collections
;
6 import java
.util
.Objects
;
11 private final long lastUpdateTimestamp
;
13 private final String givenName
;
15 private final String familyName
;
17 private final String about
;
19 private final String aboutEmoji
;
21 private final String avatarUrlPath
;
23 private final byte[] mobileCoinAddress
;
25 private final UnidentifiedAccessMode unidentifiedAccessMode
;
27 private final Set
<Capability
> capabilities
;
29 private final PhoneNumberSharingMode phoneNumberSharingMode
;
32 final long lastUpdateTimestamp
,
33 final String givenName
,
34 final String familyName
,
36 final String aboutEmoji
,
37 final String avatarUrlPath
,
38 final byte[] mobileCoinAddress
,
39 final UnidentifiedAccessMode unidentifiedAccessMode
,
40 final Set
<Capability
> capabilities
,
41 final PhoneNumberSharingMode phoneNumberSharingMode
43 this.lastUpdateTimestamp
= lastUpdateTimestamp
;
44 this.givenName
= givenName
;
45 this.familyName
= familyName
;
47 this.aboutEmoji
= aboutEmoji
;
48 this.avatarUrlPath
= avatarUrlPath
;
49 this.mobileCoinAddress
= mobileCoinAddress
;
50 this.unidentifiedAccessMode
= unidentifiedAccessMode
;
51 this.capabilities
= capabilities
;
52 this.phoneNumberSharingMode
= phoneNumberSharingMode
;
55 private Profile(final Builder builder
) {
56 lastUpdateTimestamp
= builder
.lastUpdateTimestamp
;
57 givenName
= builder
.givenName
;
58 familyName
= builder
.familyName
;
59 about
= builder
.about
;
60 aboutEmoji
= builder
.aboutEmoji
;
61 avatarUrlPath
= builder
.avatarUrlPath
;
62 mobileCoinAddress
= builder
.mobileCoinAddress
;
63 unidentifiedAccessMode
= builder
.unidentifiedAccessMode
;
64 capabilities
= builder
.capabilities
;
65 phoneNumberSharingMode
= builder
.phoneNumberSharingMode
;
68 public static Builder
newBuilder() {
72 public static Builder
newBuilder(final Profile copy
) {
73 Builder builder
= new Builder();
74 builder
.lastUpdateTimestamp
= copy
.getLastUpdateTimestamp();
75 builder
.givenName
= copy
.getGivenName();
76 builder
.familyName
= copy
.getFamilyName();
77 builder
.about
= copy
.getAbout();
78 builder
.aboutEmoji
= copy
.getAboutEmoji();
79 builder
.avatarUrlPath
= copy
.getAvatarUrlPath();
80 builder
.mobileCoinAddress
= copy
.getMobileCoinAddress();
81 builder
.unidentifiedAccessMode
= copy
.getUnidentifiedAccessMode();
82 builder
.capabilities
= copy
.getCapabilities();
86 public long getLastUpdateTimestamp() {
87 return lastUpdateTimestamp
;
90 public String
getGivenName() {
94 public String
getFamilyName() {
98 public String
getInternalServiceName() {
99 if (familyName
== null) {
100 return givenName
== null ?
"" : givenName
;
102 return String
.join("\0", givenName
== null ?
"" : givenName
, familyName
);
105 public String
getDisplayName() {
106 final var noGivenName
= Util
.isEmpty(givenName
);
107 final var noFamilyName
= Util
.isEmpty(familyName
);
109 if (noGivenName
&& noFamilyName
) {
111 } else if (noGivenName
) {
113 } else if (noFamilyName
) {
117 return givenName
+ " " + familyName
;
120 public String
getAbout() {
124 public String
getAboutEmoji() {
128 public String
getAvatarUrlPath() {
129 return avatarUrlPath
;
132 public byte[] getMobileCoinAddress() {
133 return mobileCoinAddress
;
136 public UnidentifiedAccessMode
getUnidentifiedAccessMode() {
137 return unidentifiedAccessMode
;
140 public Set
<Capability
> getCapabilities() {
144 public PhoneNumberSharingMode
getPhoneNumberSharingMode() {
145 return phoneNumberSharingMode
;
148 public enum UnidentifiedAccessMode
{
154 public static UnidentifiedAccessMode
valueOfOrUnknown(String value
) {
156 return valueOf(value
);
157 } catch (IllegalArgumentException ignored
) {
163 public enum Capability
{
166 public static Capability
valueOfOrNull(String value
) {
168 return valueOf(value
);
169 } catch (IllegalArgumentException ignored
) {
176 public boolean equals(final Object o
) {
177 if (this == o
) return true;
178 if (o
== null || getClass() != o
.getClass()) return false;
179 final Profile profile
= (Profile
) o
;
180 return lastUpdateTimestamp
== profile
.lastUpdateTimestamp
181 && Objects
.equals(givenName
, profile
.givenName
)
182 && Objects
.equals(familyName
, profile
.familyName
)
183 && Objects
.equals(about
, profile
.about
)
184 && Objects
.equals(aboutEmoji
, profile
.aboutEmoji
)
185 && Objects
.equals(avatarUrlPath
, profile
.avatarUrlPath
)
186 && unidentifiedAccessMode
== profile
.unidentifiedAccessMode
187 && Objects
.equals(capabilities
, profile
.capabilities
);
191 public int hashCode() {
192 return Objects
.hash(lastUpdateTimestamp
,
198 unidentifiedAccessMode
,
202 public static final class Builder
{
204 private String givenName
;
205 private String familyName
;
206 private String about
;
207 private String aboutEmoji
;
208 private String avatarUrlPath
;
209 private byte[] mobileCoinAddress
;
210 private UnidentifiedAccessMode unidentifiedAccessMode
= UnidentifiedAccessMode
.UNKNOWN
;
211 private Set
<Capability
> capabilities
= Collections
.emptySet();
212 private PhoneNumberSharingMode phoneNumberSharingMode
;
213 private long lastUpdateTimestamp
= 0;
218 public Builder
withGivenName(final String val
) {
223 public Builder
withFamilyName(final String val
) {
228 public Builder
withAbout(final String val
) {
233 public Builder
withAboutEmoji(final String val
) {
238 public Builder
withAvatarUrlPath(final String val
) {
243 public Builder
withUnidentifiedAccessMode(final UnidentifiedAccessMode val
) {
244 unidentifiedAccessMode
= val
;
248 public Builder
withCapabilities(final Set
<Capability
> val
) {
253 public Builder
withPhoneNumberSharingMode(final PhoneNumberSharingMode val
) {
254 phoneNumberSharingMode
= val
;
258 public Profile
build() {
259 return new Profile(this);
262 public Builder
withLastUpdateTimestamp(final long val
) {
263 lastUpdateTimestamp
= val
;
267 public Builder
withMobileCoinAddress(final byte[] val
) {
268 mobileCoinAddress
= val
;