it.auties.whatsapp.model.newsletter.NewsletterNameSpec Maven / Gradle / Ivy
package it.auties.whatsapp.model.newsletter;
import it.auties.whatsapp.model.newsletter.NewsletterName;
import it.auties.protobuf.stream.ProtobufInputStream;
import it.auties.protobuf.stream.ProtobufOutputStream;
import it.auties.protobuf.model.ProtobufWireType;
public class NewsletterNameSpec {
public static byte[] encode(NewsletterName protoInputObject) {
if (protoInputObject == null) {
return null;
}
var outputStream = new ProtobufOutputStream(sizeOf(protoInputObject));
outputStream.writeString(1, protoInputObject.id());
outputStream.writeString(2, protoInputObject.text());
outputStream.writeUInt64(3, protoInputObject.updateTimeSeconds());
return outputStream.toByteArray();
}
public static NewsletterName decode(byte[] input) {
if (input == null) {
return null;
}
return decode(new ProtobufInputStream(input, 0, input.length));
}
public static NewsletterName decode(ProtobufInputStream protoInputStream) {
java.lang.String id = null;
java.lang.String text = null;
long updateTimeSeconds = 0l;
while (protoInputStream.readTag()) {
var protoFieldIndex = protoInputStream.index();
switch (protoFieldIndex) {
case 1 -> id = protoInputStream.readString();
case 2 -> text = protoInputStream.readString();
case 3 -> updateTimeSeconds = protoInputStream.readInt64();
default -> protoInputStream.readUnknown(false);
}
}
return new it.auties.whatsapp.model.newsletter.NewsletterName(id, text, updateTimeSeconds);
}
public static int sizeOf(NewsletterName object) {
if (object == null) {
return 0;
}
var protoSize = 0;
var id = object.id();
if (id != null) {
protoSize += ProtobufOutputStream.getFieldSize(1, 2);
protoSize += ProtobufOutputStream.getStringSize(id);
}
var text = object.text();
if (text != null) {
protoSize += ProtobufOutputStream.getFieldSize(2, 2);
protoSize += ProtobufOutputStream.getStringSize(text);
}
var updateTimeSeconds = object.updateTimeSeconds();
protoSize += ProtobufOutputStream.getFieldSize(3, 0);
protoSize += ProtobufOutputStream.getVarIntSize(updateTimeSeconds);
return protoSize;
}
}