it.auties.whatsapp.model.message.standard.RequestPhoneNumberMessageSpec Maven / Gradle / Ivy
package it.auties.whatsapp.model.message.standard;
import it.auties.whatsapp.model.message.standard.RequestPhoneNumberMessage;
import it.auties.protobuf.stream.ProtobufInputStream;
import it.auties.protobuf.stream.ProtobufOutputStream;
import it.auties.protobuf.model.ProtobufWireType;
public class RequestPhoneNumberMessageSpec {
public static byte[] encode(RequestPhoneNumberMessage protoInputObject) {
if (protoInputObject == null) {
return null;
}
var outputStream = new ProtobufOutputStream(sizeOf(protoInputObject));
var contextInfo = protoInputObject.contextInfo();
if (contextInfo != null) {
var contextInfo0 = it.auties.protobuf.builtin.ProtobufOptionalMixin.toNullableValue(contextInfo);
if (contextInfo0 != null) {
outputStream.writeBytes(1, it.auties.whatsapp.model.info.ContextInfoSpec.encode(contextInfo0));
}
}
return outputStream.toByteArray();
}
public static RequestPhoneNumberMessage decode(byte[] input) {
if (input == null) {
return null;
}
return decode(new ProtobufInputStream(input, 0, input.length));
}
public static RequestPhoneNumberMessage decode(ProtobufInputStream protoInputStream) {
it.auties.whatsapp.model.info.ContextInfo contextInfo = null;
while (protoInputStream.readTag()) {
var protoFieldIndex = protoInputStream.index();
switch (protoFieldIndex) {
case 1 -> contextInfo = it.auties.whatsapp.model.info.ContextInfoSpec.decode(protoInputStream.lengthDelimitedStream());
default -> protoInputStream.readUnknown(false);
}
}
return new it.auties.whatsapp.model.message.standard.RequestPhoneNumberMessage(contextInfo);
}
public static int sizeOf(RequestPhoneNumberMessage object) {
if (object == null) {
return 0;
}
var protoSize = 0;
var contextInfo = object.contextInfo();
if (contextInfo != null) {
var contextInfo0 = it.auties.protobuf.builtin.ProtobufOptionalMixin.toNullableValue(contextInfo);
if (contextInfo0 != null) {
protoSize += ProtobufOutputStream.getFieldSize(1, 2);
var contextInfo0SerializedSize = it.auties.whatsapp.model.info.ContextInfoSpec.sizeOf(contextInfo0);
protoSize += ProtobufOutputStream.getVarIntSize(contextInfo0SerializedSize);
protoSize += contextInfo0SerializedSize;
}
}
return protoSize;
}
}