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