package org.asamk.signal.json;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
+import org.asamk.signal.manager.api.MessageEnvelope;
import org.asamk.signal.util.Util;
-import org.whispersystems.signalservice.api.messages.shared.SharedContact;
-
-public class JsonContactPhone {
-
- @JsonProperty
- private final String value;
-
- @JsonProperty
- private final SharedContact.Phone.Type type;
- @JsonProperty
- private final String label;
+public record JsonContactPhone(String value, String type, String label) {
- public JsonContactPhone(SharedContact.Phone phone) {
- value = phone.getValue();
- type = phone.getType();
- label = Util.getStringIfNotBlank(phone.getLabel());
+ static JsonContactPhone from(MessageEnvelope.Data.SharedContact.Phone phone) {
+ return new JsonContactPhone(phone.value(), phone.type().name(), Util.getStringIfNotBlank(phone.label()));
}
}