mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-31 11:30:39 +00:00
Use record classes
This commit is contained in:
parent
ce70a623c2
commit
ce7aa580b6
66 changed files with 754 additions and 1877 deletions
|
@ -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 {
|
||||
public record JsonContactName(
|
||||
String display, String given, String family, String prefix, String suffix, String middle
|
||||
) {
|
||||
|
||||
@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());
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue