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

it.auties.whatsapp.api.WebHistoryLengthSpec Maven / Gradle / Ivy

There is a newer version: 0.0.7
Show newest version
package it.auties.whatsapp.api;

import it.auties.whatsapp.api.WebHistoryLength;
import it.auties.protobuf.stream.ProtobufInputStream;
import it.auties.protobuf.stream.ProtobufOutputStream;
import it.auties.protobuf.model.ProtobufWireType;

public class WebHistoryLengthSpec {
    public static byte[] encode(WebHistoryLength protoInputObject) {
        if (protoInputObject == null) {
            return null;
        }
        var outputStream = new ProtobufOutputStream(sizeOf(protoInputObject));
        outputStream.writeInt32(1, protoInputObject.size());
        return outputStream.toByteArray();
    }

    public static WebHistoryLength decode(byte[] input) {
        if (input == null) {
            return null;
        }
        var protoInputStream = new ProtobufInputStream(input);
        int size = 0;
        while (protoInputStream.readTag()) {
            var protoFieldIndex = protoInputStream.index();
            switch (protoFieldIndex) {
                case 1 -> size = protoInputStream.readInt32();
                default -> protoInputStream.skipBytes();
            }
        }
        return new it.auties.whatsapp.api.WebHistoryLength(size);
    }

    public static int sizeOf(WebHistoryLength object) {
        if (object == null) {
            return 0;
        }
        var protoSize = 0;
        var size = object.size();
        protoSize += ProtobufOutputStream.getFieldSize(1, 0);
        protoSize += ProtobufOutputStream.getVarIntSize(size);
        return protoSize;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy