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
;
30 final long lastUpdateTimestamp
,
31 final String givenName
,
32 final String familyName
,
34 final String aboutEmoji
,
35 final String avatarUrlPath
,
36 final byte[] mobileCoinAddress
,
37 final UnidentifiedAccessMode unidentifiedAccessMode
,
38 final Set
<Capability
> capabilities
40 this.lastUpdateTimestamp
= lastUpdateTimestamp
;
41 this.givenName
= givenName
;
42 this.familyName
= familyName
;
44 this.aboutEmoji
= aboutEmoji
;
45 this.avatarUrlPath
= avatarUrlPath
;
46 this.mobileCoinAddress
= mobileCoinAddress
;
47 this.unidentifiedAccessMode
= unidentifiedAccessMode
;
48 this.capabilities
= capabilities
;
51 private Profile(final Builder builder
) {
52 lastUpdateTimestamp
= builder
.lastUpdateTimestamp
;
53 givenName
= builder
.givenName
;
54 familyName
= builder
.familyName
;
55 about
= builder
.about
;
56 aboutEmoji
= builder
.aboutEmoji
;
57 avatarUrlPath
= builder
.avatarUrlPath
;
58 mobileCoinAddress
= builder
.mobileCoinAddress
;
59 unidentifiedAccessMode
= builder
.unidentifiedAccessMode
;
60 capabilities
= builder
.capabilities
;
63 public static Builder
newBuilder() {
67 public static Builder
newBuilder(final Profile copy
) {
68 Builder builder
= new Builder();
69 builder
.lastUpdateTimestamp
= copy
.getLastUpdateTimestamp();
70 builder
.givenName
= copy
.getGivenName();
71 builder
.familyName
= copy
.getFamilyName();
72 builder
.about
= copy
.getAbout();
73 builder
.aboutEmoji
= copy
.getAboutEmoji();
74 builder
.avatarUrlPath
= copy
.getAvatarUrlPath();
75 builder
.mobileCoinAddress
= copy
.getMobileCoinAddress();
76 builder
.unidentifiedAccessMode
= copy
.getUnidentifiedAccessMode();
77 builder
.capabilities
= copy
.getCapabilities();
81 public long getLastUpdateTimestamp() {
82 return lastUpdateTimestamp
;
85 public String
getGivenName() {
89 public String
getFamilyName() {
93 public String
getInternalServiceName() {
94 if (familyName
== null) {
95 return givenName
== null ?
"" : givenName
;
97 return String
.join("\0", givenName
== null ?
"" : givenName
, familyName
);
100 public String
getDisplayName() {
101 final var noGivenName
= Util
.isEmpty(givenName
);
102 final var noFamilyName
= Util
.isEmpty(familyName
);
104 if (noGivenName
&& noFamilyName
) {
106 } else if (noGivenName
) {
108 } else if (noFamilyName
) {
112 return givenName
+ " " + familyName
;
115 public String
getAbout() {
119 public String
getAboutEmoji() {
123 public String
getAvatarUrlPath() {
124 return avatarUrlPath
;
127 public byte[] getMobileCoinAddress() {
128 return mobileCoinAddress
;
131 public UnidentifiedAccessMode
getUnidentifiedAccessMode() {
132 return unidentifiedAccessMode
;
135 public Set
<Capability
> getCapabilities() {
139 public enum UnidentifiedAccessMode
{
145 public static UnidentifiedAccessMode
valueOfOrUnknown(String value
) {
147 return valueOf(value
);
148 } catch (IllegalArgumentException ignored
) {
154 public enum Capability
{
160 public static Capability
valueOfOrNull(String value
) {
162 return valueOf(value
);
163 } catch (IllegalArgumentException ignored
) {
170 public boolean equals(final Object o
) {
171 if (this == o
) return true;
172 if (o
== null || getClass() != o
.getClass()) return false;
173 final Profile profile
= (Profile
) o
;
174 return lastUpdateTimestamp
== profile
.lastUpdateTimestamp
175 && Objects
.equals(givenName
, profile
.givenName
)
176 && Objects
.equals(familyName
, profile
.familyName
)
177 && Objects
.equals(about
, profile
.about
)
178 && Objects
.equals(aboutEmoji
, profile
.aboutEmoji
)
179 && Objects
.equals(avatarUrlPath
, profile
.avatarUrlPath
)
180 && unidentifiedAccessMode
== profile
.unidentifiedAccessMode
181 && Objects
.equals(capabilities
, profile
.capabilities
);
185 public int hashCode() {
186 return Objects
.hash(lastUpdateTimestamp
,
192 unidentifiedAccessMode
,
196 public static final class Builder
{
198 private String givenName
;
199 private String familyName
;
200 private String about
;
201 private String aboutEmoji
;
202 private String avatarUrlPath
;
203 private byte[] mobileCoinAddress
;
204 private UnidentifiedAccessMode unidentifiedAccessMode
= UnidentifiedAccessMode
.UNKNOWN
;
205 private Set
<Capability
> capabilities
= Collections
.emptySet();
206 private long lastUpdateTimestamp
= 0;
211 public Builder
withGivenName(final String val
) {
216 public Builder
withFamilyName(final String val
) {
221 public Builder
withAbout(final String val
) {
226 public Builder
withAboutEmoji(final String val
) {
231 public Builder
withAvatarUrlPath(final String val
) {
236 public Builder
withUnidentifiedAccessMode(final UnidentifiedAccessMode val
) {
237 unidentifiedAccessMode
= val
;
241 public Builder
withCapabilities(final Set
<Capability
> val
) {
246 public Profile
build() {
247 return new Profile(this);
250 public Builder
withLastUpdateTimestamp(final long val
) {
251 lastUpdateTimestamp
= val
;
255 public Builder
withMobileCoinAddress(final byte[] val
) {
256 mobileCoinAddress
= val
;