it.auties.whatsapp.model.button.template.hsm.HighlyStructuredFourRowTemplateSpec Maven / Gradle / Ivy
package it.auties.whatsapp.model.button.template.hsm;
import it.auties.whatsapp.model.button.template.hsm.HighlyStructuredFourRowTemplate;
import it.auties.protobuf.stream.ProtobufInputStream;
import it.auties.protobuf.stream.ProtobufOutputStream;
public class HighlyStructuredFourRowTemplateSpec {
public static byte[] encode(HighlyStructuredFourRowTemplate protoInputObject) {
if(protoInputObject == null) {
return null;
}
var outputStream = new ProtobufOutputStream();
var titleDocument = protoInputObject.titleDocument();
var titleDocument0 = titleDocument.orElse(null);
if(titleDocument0 != null) {
outputStream.writeBytes(1, it.auties.whatsapp.model.message.standard.DocumentMessageSpec.encode(titleDocument0));
}
var titleHighlyStructured = protoInputObject.titleHighlyStructured();
var titleHighlyStructured0 = titleHighlyStructured.orElse(null);
if(titleHighlyStructured0 != null) {
outputStream.writeBytes(2, it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredMessageSpec.encode(titleHighlyStructured0));
}
var titleImage = protoInputObject.titleImage();
var titleImage0 = titleImage.orElse(null);
if(titleImage0 != null) {
outputStream.writeBytes(3, it.auties.whatsapp.model.message.standard.ImageMessageSpec.encode(titleImage0));
}
var titleVideo = protoInputObject.titleVideo();
var titleVideo0 = titleVideo.orElse(null);
if(titleVideo0 != null) {
outputStream.writeBytes(4, it.auties.whatsapp.model.message.standard.VideoOrGifMessageSpec.encode(titleVideo0));
}
var titleLocation = protoInputObject.titleLocation();
var titleLocation0 = titleLocation.orElse(null);
if(titleLocation0 != null) {
outputStream.writeBytes(5, it.auties.whatsapp.model.message.standard.LocationMessageSpec.encode(titleLocation0));
}
outputStream.writeBytes(6, it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredMessageSpec.encode(protoInputObject.content()));
var footer = protoInputObject.footer();
var footer0 = footer.orElse(null);
if(footer0 != null) {
outputStream.writeBytes(7, it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredMessageSpec.encode(footer0));
}
if(protoInputObject.buttons() != null) {
for(var buttonsEntry : protoInputObject.buttons()) {
outputStream.writeBytes(8, it.auties.whatsapp.model.button.template.hsm.HighlyStructuredButtonTemplateSpec.encode(buttonsEntry));
}
}
return outputStream.toByteArray();
}
public static HighlyStructuredFourRowTemplate decode(byte[] input) {
if(input == null) {
return null;
}
var inputStream = new ProtobufInputStream(input);
java.util.Optional titleDocument = java.util.Optional.empty();
java.util.Optional titleHighlyStructured = java.util.Optional.empty();
java.util.Optional titleImage = java.util.Optional.empty();
java.util.Optional titleVideo = java.util.Optional.empty();
java.util.Optional titleLocation = java.util.Optional.empty();
it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredMessage content = null;
java.util.Optional footer = java.util.Optional.empty();
java.util.List buttons = new java.util.ArrayList();
while(inputStream.readTag()) {
switch(inputStream.index()) {
case 1 -> titleDocument = java.util.Optional.ofNullable(it.auties.whatsapp.model.message.standard.DocumentMessageSpec.decode(inputStream.readBytes()));
case 2 -> titleHighlyStructured = java.util.Optional.ofNullable(it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredMessageSpec.decode(inputStream.readBytes()));
case 3 -> titleImage = java.util.Optional.ofNullable(it.auties.whatsapp.model.message.standard.ImageMessageSpec.decode(inputStream.readBytes()));
case 4 -> titleVideo = java.util.Optional.ofNullable(it.auties.whatsapp.model.message.standard.VideoOrGifMessageSpec.decode(inputStream.readBytes()));
case 5 -> titleLocation = java.util.Optional.ofNullable(it.auties.whatsapp.model.message.standard.LocationMessageSpec.decode(inputStream.readBytes()));
case 6 -> content = it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredMessageSpec.decode(inputStream.readBytes());
case 7 -> footer = java.util.Optional.ofNullable(it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredMessageSpec.decode(inputStream.readBytes()));
case 8 -> buttons.add(it.auties.whatsapp.model.button.template.hsm.HighlyStructuredButtonTemplateSpec.decode(inputStream.readBytes()));
default -> inputStream.skipBytes();
}
}
return new it.auties.whatsapp.model.button.template.hsm.HighlyStructuredFourRowTemplate(titleDocument, titleHighlyStructured, titleImage, titleVideo, titleLocation, content, footer, buttons);
}
}