1 package org
.asamk
.signal
.manager
.api
;
3 import org
.asamk
.signal
.manager
.storage
.recipients
.RecipientId
;
4 import org
.signal
.libsignal
.zkgroup
.profiles
.ExpiringProfileKeyCredential
;
5 import org
.signal
.libsignal
.zkgroup
.profiles
.ProfileKey
;
7 import java
.util
.Objects
;
9 public class Recipient
{
11 private final RecipientId recipientId
;
13 private final RecipientAddress address
;
15 private final Contact contact
;
17 private final ProfileKey profileKey
;
19 private final ExpiringProfileKeyCredential expiringProfileKeyCredential
;
21 private final Profile profile
;
23 private final Boolean discoverable
;
26 final RecipientId recipientId
,
27 final RecipientAddress address
,
28 final Contact contact
,
29 final ProfileKey profileKey
,
30 final ExpiringProfileKeyCredential expiringProfileKeyCredential
,
31 final Profile profile
,
32 final Boolean discoverable
34 this.recipientId
= recipientId
;
35 this.address
= address
;
36 this.contact
= contact
;
37 this.profileKey
= profileKey
;
38 this.expiringProfileKeyCredential
= expiringProfileKeyCredential
;
39 this.profile
= profile
;
40 this.discoverable
= discoverable
;
43 private Recipient(final Builder builder
) {
44 recipientId
= builder
.recipientId
;
45 address
= builder
.address
;
46 contact
= builder
.contact
;
47 profileKey
= builder
.profileKey
;
48 expiringProfileKeyCredential
= builder
.expiringProfileKeyCredential
;
49 profile
= builder
.profile
;
50 discoverable
= builder
.discoverable
;
53 public static Builder
newBuilder() {
57 public static Builder
newBuilder(final Recipient copy
) {
58 Builder builder
= new Builder();
59 builder
.recipientId
= copy
.getRecipientId();
60 builder
.address
= copy
.getAddress();
61 builder
.contact
= copy
.getContact();
62 builder
.profileKey
= copy
.getProfileKey();
63 builder
.expiringProfileKeyCredential
= copy
.getExpiringProfileKeyCredential();
64 builder
.profile
= copy
.getProfile();
68 public RecipientId
getRecipientId() {
72 public RecipientAddress
getAddress() {
76 public Contact
getContact() {
80 public ProfileKey
getProfileKey() {
84 public ExpiringProfileKeyCredential
getExpiringProfileKeyCredential() {
85 return expiringProfileKeyCredential
;
88 public Profile
getProfile() {
92 public Boolean
getDiscoverable() {
97 public boolean equals(final Object o
) {
98 if (this == o
) return true;
99 if (o
== null || getClass() != o
.getClass()) return false;
100 final Recipient recipient
= (Recipient
) o
;
101 return Objects
.equals(recipientId
, recipient
.recipientId
)
102 && Objects
.equals(address
, recipient
.address
)
103 && Objects
.equals(contact
, recipient
.contact
)
104 && Objects
.equals(profileKey
, recipient
.profileKey
)
105 && Objects
.equals(expiringProfileKeyCredential
, recipient
.expiringProfileKeyCredential
)
106 && Objects
.equals(profile
, recipient
.profile
);
110 public int hashCode() {
111 return Objects
.hash(recipientId
, address
, contact
, profileKey
, expiringProfileKeyCredential
, profile
);
114 public static final class Builder
{
116 private RecipientId recipientId
;
117 private RecipientAddress address
;
118 private Contact contact
;
119 private ProfileKey profileKey
;
120 private ExpiringProfileKeyCredential expiringProfileKeyCredential
;
121 private Profile profile
;
122 private Boolean discoverable
;
127 public Builder
withRecipientId(final RecipientId val
) {
132 public Builder
withAddress(final RecipientAddress val
) {
137 public Builder
withContact(final Contact val
) {
142 public Builder
withProfileKey(final ProfileKey val
) {
147 public Builder
withExpiringProfileKeyCredential(final ExpiringProfileKeyCredential val
) {
148 expiringProfileKeyCredential
= val
;
152 public Builder
withProfile(final Profile val
) {
157 public Builder
withDiscoverable(final Boolean val
) {
162 public Recipient
build() {
163 return new Recipient(this);