1 package org
.asamk
.signal
.manager
.storage
.contacts
;
3 import com
.fasterxml
.jackson
.annotation
.JsonProperty
;
5 import org
.whispersystems
.signalservice
.api
.push
.SignalServiceAddress
;
7 import java
.util
.ArrayList
;
10 public class JsonContactsStore
{
12 @JsonProperty("contacts")
13 private List
<ContactInfo
> contacts
= new ArrayList
<>();
15 public void updateContact(ContactInfo contact
) {
16 final SignalServiceAddress contactAddress
= contact
.getAddress();
17 for (int i
= 0; i
< contacts
.size(); i
++) {
18 if (contacts
.get(i
).getAddress().matches(contactAddress
)) {
19 contacts
.set(i
, contact
);
24 contacts
.add(contact
);
27 public ContactInfo
getContact(SignalServiceAddress address
) {
28 for (ContactInfo contact
: contacts
) {
29 if (contact
.getAddress().matches(address
)) {
30 if (contact
.uuid
== null) {
31 contact
.uuid
= address
.getUuid().orNull();
32 } else if (contact
.number
== null) {
33 contact
.number
= address
.getNumber().orNull();
42 public List
<ContactInfo
> getContacts() {
43 return new ArrayList
<>(contacts
);
47 * Remove all contacts from the store