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