]>
nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/json/JsonSharedContact.java
1 package org
.asamk
.signal
.json
;
3 import com
.fasterxml
.jackson
.annotation
.JsonInclude
;
4 import com
.fasterxml
.jackson
.annotation
.JsonProperty
;
6 import org
.whispersystems
.signalservice
.api
.messages
.shared
.SharedContact
;
9 import java
.util
.stream
.Collectors
;
11 public class JsonSharedContact
{
14 final JsonContactName name
;
17 final JsonContactAvatar avatar
;
20 @JsonInclude(JsonInclude
.Include
.NON_NULL
)
21 final List
<JsonContactPhone
> phone
;
24 @JsonInclude(JsonInclude
.Include
.NON_NULL
)
25 final List
<JsonContactEmail
> email
;
28 @JsonInclude(JsonInclude
.Include
.NON_NULL
)
29 final List
<JsonContactAddress
> address
;
32 final String organization
;
35 public JsonSharedContact(SharedContact contact
) {
36 name
= new JsonContactName(contact
.getName());
37 if (contact
.getAvatar().isPresent()) {
38 avatar
= new JsonContactAvatar(contact
.getAvatar().get());
43 if (contact
.getPhone().isPresent()) {
44 phone
= contact
.getPhone()
47 .map(JsonContactPhone
::new)
48 .collect(Collectors
.toList());
53 if (contact
.getEmail().isPresent()) {
54 email
= contact
.getEmail()
57 .map(JsonContactEmail
::new)
58 .collect(Collectors
.toList());
63 if (contact
.getAddress().isPresent()) {
64 address
= contact
.getAddress()
67 .map(JsonContactAddress
::new)
68 .collect(Collectors
.toList());
73 organization
= contact
.getOrganization().orNull();