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