mirror of
https://github.com/aljazceru/signal-cli.git
synced 2026-01-21 06:34:21 +01:00
Use record classes
This commit is contained in:
@@ -1,37 +1,19 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
||||
public class JsonMention {
|
||||
public record JsonMention(@Deprecated String name, String number, String uuid, int start, int length) {
|
||||
|
||||
@JsonProperty
|
||||
@Deprecated
|
||||
final String name;
|
||||
|
||||
@JsonProperty
|
||||
final String number;
|
||||
|
||||
@JsonProperty
|
||||
final String uuid;
|
||||
|
||||
@JsonProperty
|
||||
final int start;
|
||||
|
||||
@JsonProperty
|
||||
final int length;
|
||||
|
||||
JsonMention(SignalServiceDataMessage.Mention mention, Manager m) {
|
||||
static JsonMention from(SignalServiceDataMessage.Mention mention, Manager m) {
|
||||
final var address = m.resolveSignalServiceAddress(new SignalServiceAddress(mention.getUuid()));
|
||||
this.name = getLegacyIdentifier(address);
|
||||
this.number = address.getNumber().orNull();
|
||||
this.uuid = address.getUuid().toString();
|
||||
this.start = mention.getStart();
|
||||
this.length = mention.getLength();
|
||||
return new JsonMention(getLegacyIdentifier(address),
|
||||
address.getNumber().orNull(),
|
||||
address.getUuid().toString(),
|
||||
mention.getStart(),
|
||||
mention.getLength());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user