X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/237abe431bb77436ef7a23d32339804fff592cc7..ce7aa580b6f0580cdcf7fd68fcc8efba737d21ed:/src/main/java/org/asamk/signal/json/JsonContactName.java diff --git a/src/main/java/org/asamk/signal/json/JsonContactName.java b/src/main/java/org/asamk/signal/json/JsonContactName.java index 9da27825..9c7af32b 100644 --- a/src/main/java/org/asamk/signal/json/JsonContactName.java +++ b/src/main/java/org/asamk/signal/json/JsonContactName.java @@ -1,36 +1,18 @@ package org.asamk.signal.json; -import com.fasterxml.jackson.annotation.JsonProperty; - import org.asamk.signal.util.Util; import org.whispersystems.signalservice.api.messages.shared.SharedContact; -public class JsonContactName { - - @JsonProperty - private final String display; - - @JsonProperty - private final String given; - - @JsonProperty - private final String family; - - @JsonProperty - private final String prefix; - - @JsonProperty - private final String suffix; - - @JsonProperty - private final String middle; - - public JsonContactName(SharedContact.Name name) { - display = Util.getStringIfNotBlank(name.getDisplay()); - given = Util.getStringIfNotBlank(name.getGiven()); - family = Util.getStringIfNotBlank(name.getFamily()); - prefix = Util.getStringIfNotBlank(name.getPrefix()); - suffix = Util.getStringIfNotBlank(name.getSuffix()); - middle = Util.getStringIfNotBlank(name.getMiddle()); +public record JsonContactName( + String display, String given, String family, String prefix, String suffix, String middle +) { + + static JsonContactName from(SharedContact.Name name) { + return new JsonContactName(Util.getStringIfNotBlank(name.getDisplay()), + Util.getStringIfNotBlank(name.getGiven()), + Util.getStringIfNotBlank(name.getFamily()), + Util.getStringIfNotBlank(name.getPrefix()), + Util.getStringIfNotBlank(name.getSuffix()), + Util.getStringIfNotBlank(name.getMiddle())); } }