All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.auties.whatsapp.model.chat.ChatDisappearSpec Maven / Gradle / Ivy

package it.auties.whatsapp.model.chat;

import it.auties.whatsapp.model.chat.ChatDisappear;
import it.auties.protobuf.stream.ProtobufInputStream;
import it.auties.protobuf.stream.ProtobufOutputStream;
import it.auties.protobuf.model.ProtobufWireType;

public class ChatDisappearSpec {
    public static byte[] encode(ChatDisappear protoInputObject) {
        if (protoInputObject == null) {
            return null;
        }
        var outputStream = new ProtobufOutputStream(sizeOf(protoInputObject));
        outputStream.writeInt32(1, it.auties.whatsapp.model.chat.ChatDisappearInitiatorSpec.encode(protoInputObject.initiator()));
        return outputStream.toByteArray();
    }

    public static ChatDisappear decode(byte[] input) {
        if (input == null) {
            return null;
        }
        var protoInputStream = new ProtobufInputStream(input);
        it.auties.whatsapp.model.chat.ChatDisappear.Initiator initiator = null;
        while (protoInputStream.readTag()) {
            var protoFieldIndex = protoInputStream.index();
            switch (protoFieldIndex) {
                case 1 -> initiator = it.auties.whatsapp.model.chat.ChatDisappearInitiatorSpec.decode(protoInputStream.readInt32()).orElse(null);
                default -> protoInputStream.skipBytes();
            }
        }
        return new it.auties.whatsapp.model.chat.ChatDisappear(initiator);
    }

    public static int sizeOf(ChatDisappear object) {
        if (object == null) {
            return 0;
        }
        var protoSize = 0;
        var initiator = object.initiator();
        if (initiator != null) {
            protoSize += ProtobufOutputStream.getFieldSize(1, 2);
            var initiatorSerializedSize = it.auties.whatsapp.model.chat.ChatDisappearInitiatorSpec.sizeOf(initiator);
            protoSize += initiatorSerializedSize;
        }
        return protoSize;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy