1 package org
.asamk
.signal
.manager
.storage
.recipients
;
3 import org
.asamk
.signal
.manager
.api
.Contact
;
4 import org
.asamk
.signal
.manager
.api
.Profile
;
5 import org
.signal
.libsignal
.zkgroup
.profiles
.ExpiringProfileKeyCredential
;
6 import org
.signal
.libsignal
.zkgroup
.profiles
.ProfileKey
;
8 import java
.util
.Objects
;
10 public class Recipient
{
12 private final RecipientId recipientId
;
14 private final RecipientAddress address
;
16 private final Contact contact
;
18 private final ProfileKey profileKey
;
20 private final ExpiringProfileKeyCredential expiringProfileKeyCredential
;
22 private final Profile profile
;
24 private final byte[] storageRecord
;
27 final RecipientId recipientId
,
28 final RecipientAddress address
,
29 final Contact contact
,
30 final ProfileKey profileKey
,
31 final ExpiringProfileKeyCredential expiringProfileKeyCredential
,
32 final Profile profile
,
33 final byte[] storageRecord
35 this.recipientId
= recipientId
;
36 this.address
= address
;
37 this.contact
= contact
;
38 this.profileKey
= profileKey
;
39 this.expiringProfileKeyCredential
= expiringProfileKeyCredential
;
40 this.profile
= profile
;
41 this.storageRecord
= storageRecord
;
44 private Recipient(final Builder builder
) {
45 recipientId
= builder
.recipientId
;
46 address
= builder
.address
;
47 contact
= builder
.contact
;
48 profileKey
= builder
.profileKey
;
49 expiringProfileKeyCredential
= builder
.expiringProfileKeyCredential
;
50 profile
= builder
.profile
;
51 storageRecord
= builder
.storageRecord
;
54 public static Builder
newBuilder() {
58 public static Builder
newBuilder(final Recipient copy
) {
59 Builder builder
= new Builder();
60 builder
.recipientId
= copy
.getRecipientId();
61 builder
.address
= copy
.getAddress();
62 builder
.contact
= copy
.getContact();
63 builder
.profileKey
= copy
.getProfileKey();
64 builder
.expiringProfileKeyCredential
= copy
.getExpiringProfileKeyCredential();
65 builder
.profile
= copy
.getProfile();
66 builder
.storageRecord
= copy
.getStorageRecord();
70 public RecipientId
getRecipientId() {
74 public RecipientAddress
getAddress() {
78 public Contact
getContact() {
82 public ProfileKey
getProfileKey() {
86 public ExpiringProfileKeyCredential
getExpiringProfileKeyCredential() {
87 return expiringProfileKeyCredential
;
90 public Profile
getProfile() {
94 public byte[] getStorageRecord() {
99 public boolean equals(final Object o
) {
100 if (this == o
) return true;
101 if (o
== null || getClass() != o
.getClass()) return false;
102 final Recipient recipient
= (Recipient
) o
;
103 return Objects
.equals(recipientId
, recipient
.recipientId
)
104 && Objects
.equals(address
, recipient
.address
)
105 && Objects
.equals(contact
, recipient
.contact
)
106 && Objects
.equals(profileKey
, recipient
.profileKey
)
107 && Objects
.equals(expiringProfileKeyCredential
, recipient
.expiringProfileKeyCredential
)
108 && Objects
.equals(profile
, recipient
.profile
);
112 public int hashCode() {
113 return Objects
.hash(recipientId
, address
, contact
, profileKey
, expiringProfileKeyCredential
, profile
);
116 public static final class Builder
{
118 private RecipientId recipientId
;
119 private RecipientAddress address
;
120 private Contact contact
;
121 private ProfileKey profileKey
;
122 private ExpiringProfileKeyCredential expiringProfileKeyCredential
;
123 private Profile profile
;
124 private byte[] storageRecord
;
129 public Builder
withRecipientId(final RecipientId val
) {
134 public Builder
withAddress(final RecipientAddress val
) {
139 public Builder
withContact(final Contact val
) {
144 public Builder
withProfileKey(final ProfileKey val
) {
149 public Builder
withExpiringProfileKeyCredential(final ExpiringProfileKeyCredential val
) {
150 expiringProfileKeyCredential
= val
;
154 public Builder
withProfile(final Profile val
) {
159 public Builder
withStorageRecord(final byte[] val
) {
164 public Recipient
build() {
165 return new Recipient(this);