]> nmode's Git Repositories - signal-cli/blob - lib/src/main/java/org/asamk/signal/manager/api/Recipient.java
Fix TextStyle doc example typo (#1251)
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / api / Recipient.java
1 package org.asamk.signal.manager.api;
2
3 import org.asamk.signal.manager.storage.recipients.Contact;
4 import org.asamk.signal.manager.storage.recipients.Profile;
5 import org.asamk.signal.manager.storage.recipients.RecipientId;
6 import org.signal.libsignal.zkgroup.profiles.ExpiringProfileKeyCredential;
7 import org.signal.libsignal.zkgroup.profiles.ProfileKey;
8
9 import java.util.Objects;
10
11 public class Recipient {
12
13 private final RecipientId recipientId;
14
15 private final RecipientAddress address;
16
17 private final Contact contact;
18
19 private final ProfileKey profileKey;
20
21 private final ExpiringProfileKeyCredential expiringProfileKeyCredential;
22
23 private final Profile profile;
24
25 public Recipient(
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 ) {
33 this.recipientId = recipientId;
34 this.address = address;
35 this.contact = contact;
36 this.profileKey = profileKey;
37 this.expiringProfileKeyCredential = expiringProfileKeyCredential;
38 this.profile = profile;
39 }
40
41 private Recipient(final Builder builder) {
42 recipientId = builder.recipientId;
43 address = builder.address;
44 contact = builder.contact;
45 profileKey = builder.profileKey;
46 expiringProfileKeyCredential = builder.expiringProfileKeyCredential1;
47 profile = builder.profile;
48 }
49
50 public static Builder newBuilder() {
51 return new Builder();
52 }
53
54 public static Builder newBuilder(final Recipient copy) {
55 Builder builder = new Builder();
56 builder.recipientId = copy.getRecipientId();
57 builder.address = copy.getAddress();
58 builder.contact = copy.getContact();
59 builder.profileKey = copy.getProfileKey();
60 builder.expiringProfileKeyCredential1 = copy.getExpiringProfileKeyCredential();
61 builder.profile = copy.getProfile();
62 return builder;
63 }
64
65 public RecipientId getRecipientId() {
66 return recipientId;
67 }
68
69 public RecipientAddress getAddress() {
70 return address;
71 }
72
73 public Contact getContact() {
74 return contact;
75 }
76
77 public ProfileKey getProfileKey() {
78 return profileKey;
79 }
80
81 public ExpiringProfileKeyCredential getExpiringProfileKeyCredential() {
82 return expiringProfileKeyCredential;
83 }
84
85 public Profile getProfile() {
86 return profile;
87 }
88
89 @Override
90 public boolean equals(final Object o) {
91 if (this == o) return true;
92 if (o == null || getClass() != o.getClass()) return false;
93 final Recipient recipient = (Recipient) o;
94 return Objects.equals(recipientId, recipient.recipientId)
95 && Objects.equals(address, recipient.address)
96 && Objects.equals(contact, recipient.contact)
97 && Objects.equals(profileKey, recipient.profileKey)
98 && Objects.equals(expiringProfileKeyCredential, recipient.expiringProfileKeyCredential)
99 && Objects.equals(profile, recipient.profile);
100 }
101
102 @Override
103 public int hashCode() {
104 return Objects.hash(recipientId, address, contact, profileKey, expiringProfileKeyCredential, profile);
105 }
106
107 public static final class Builder {
108
109 private RecipientId recipientId;
110 private RecipientAddress address;
111 private Contact contact;
112 private ProfileKey profileKey;
113 private ExpiringProfileKeyCredential expiringProfileKeyCredential1;
114 private Profile profile;
115
116 private Builder() {
117 }
118
119 public Builder withRecipientId(final RecipientId val) {
120 recipientId = val;
121 return this;
122 }
123
124 public Builder withAddress(final RecipientAddress val) {
125 address = val;
126 return this;
127 }
128
129 public Builder withContact(final Contact val) {
130 contact = val;
131 return this;
132 }
133
134 public Builder withProfileKey(final ProfileKey val) {
135 profileKey = val;
136 return this;
137 }
138
139 public Builder withExpiringProfileKeyCredential(final ExpiringProfileKeyCredential val) {
140 expiringProfileKeyCredential1 = val;
141 return this;
142 }
143
144 public Builder withProfile(final Profile val) {
145 profile = val;
146 return this;
147 }
148
149 public Recipient build() {
150 return new Recipient(this);
151 }
152 }
153 }