it.auties.whatsapp.model.sync.PushNameSpec Maven / Gradle / Ivy
package it.auties.whatsapp.model.sync;
import it.auties.whatsapp.model.sync.PushName;
import it.auties.protobuf.stream.ProtobufInputStream;
import it.auties.protobuf.stream.ProtobufOutputStream;
import it.auties.protobuf.model.ProtobufWireType;
public class PushNameSpec {
public static byte[] encode(PushName protoInputObject) {
if (protoInputObject == null) {
return null;
}
var outputStream = new ProtobufOutputStream(sizeOf(protoInputObject));
outputStream.writeString(1, protoInputObject.id());
var name = protoInputObject.name();
if (name != null) {
var name0 = it.auties.protobuf.builtin.ProtobufOptionalMixin.toNullableValue(name);
if (name0 != null) {
outputStream.writeString(2, name0);
}
}
return outputStream.toByteArray();
}
public static PushName decode(byte[] input) {
if (input == null) {
return null;
}
var protoInputStream = new ProtobufInputStream(input);
java.lang.String id = null;
java.util.Optional name = it.auties.protobuf.builtin.ProtobufOptionalMixin.newOptional();
while (protoInputStream.readTag()) {
var protoFieldIndex = protoInputStream.index();
switch (protoFieldIndex) {
case 1 -> id = protoInputStream.readString();
case 2 -> name = it.auties.protobuf.builtin.ProtobufOptionalMixin.ofOptional(protoInputStream.readString());
default -> protoInputStream.skipBytes();
}
}
return new it.auties.whatsapp.model.sync.PushName(id, name);
}
public static int sizeOf(PushName 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 name = object.name();
if (name != null) {
var name0 = it.auties.protobuf.builtin.ProtobufOptionalMixin.toNullableValue(name);
if (name0 != null) {
protoSize += ProtobufOutputStream.getFieldSize(2, 2);
protoSize += ProtobufOutputStream.getStringSize(name0);
}
}
return protoSize;
}
}