it.auties.whatsapp.model.chat.GroupPastParticipantsSpec Maven / Gradle / Ivy
package it.auties.whatsapp.model.chat;
import it.auties.whatsapp.model.chat.GroupPastParticipants;
import it.auties.protobuf.stream.ProtobufInputStream;
import it.auties.protobuf.stream.ProtobufOutputStream;
public class GroupPastParticipantsSpec {
public static byte[] encode(GroupPastParticipants protoInputObject) {
if(protoInputObject == null) {
return null;
}
var outputStream = new ProtobufOutputStream();
var groupJid = protoInputObject.groupJid();
if(groupJid != null) {
var groupJid0 = groupJid.toProtobufValue();
if(groupJid0 != null) {
outputStream.writeString(1, groupJid0);
}
}
if(protoInputObject.pastParticipants() != null) {
for(var pastParticipantsEntry : protoInputObject.pastParticipants()) {
outputStream.writeBytes(2, it.auties.whatsapp.model.chat.GroupPastParticipantSpec.encode(pastParticipantsEntry));
}
}
return outputStream.toByteArray();
}
public static GroupPastParticipants decode(byte[] input) {
if(input == null) {
return null;
}
var inputStream = new ProtobufInputStream(input);
it.auties.whatsapp.model.jid.Jid groupJid = null;
java.util.List pastParticipants = new java.util.ArrayList();
while(inputStream.readTag()) {
switch(inputStream.index()) {
case 1 -> groupJid = it.auties.whatsapp.model.jid.Jid.ofProtobuf(inputStream.readString());
case 2 -> pastParticipants.add(it.auties.whatsapp.model.chat.GroupPastParticipantSpec.decode(inputStream.readBytes()));
default -> inputStream.skipBytes();
}
}
return new it.auties.whatsapp.model.chat.GroupPastParticipants(groupJid, pastParticipants);
}
}