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

it.auties.whatsapp.model.message.standard.LiveLocationMessageSpec Maven / Gradle / Ivy

package it.auties.whatsapp.model.message.standard;

import it.auties.whatsapp.model.message.standard.LiveLocationMessage;
import it.auties.protobuf.stream.ProtobufInputStream;
import it.auties.protobuf.stream.ProtobufOutputStream;

public class LiveLocationMessageSpec {
    public static byte[] encode(LiveLocationMessage protoInputObject) {
      if(protoInputObject == null) {
         return null;
      }
      var outputStream = new ProtobufOutputStream();
outputStream.writeDouble(1, protoInputObject.latitude());
outputStream.writeDouble(2, protoInputObject.longitude());
outputStream.writeUInt32(3, protoInputObject.accuracy());
outputStream.writeFloat(4, protoInputObject.speed());
outputStream.writeUInt32(5, protoInputObject.magneticNorthOffset());
var caption = protoInputObject.caption();
if(caption != null) {
var caption0 = caption.orElse(null);
if(caption0 != null) {
outputStream.writeString(6, caption0);
}
}
outputStream.writeUInt64(7, protoInputObject.sequenceNumber());
outputStream.writeUInt32(8, protoInputObject.timeOffset());
var thumbnail = protoInputObject.thumbnail();
if(thumbnail != null) {
var thumbnail0 = thumbnail.orElse(null);
if(thumbnail0 != null) {
outputStream.writeBytes(16, thumbnail0);
}
}
var contextInfo = protoInputObject.contextInfo();
if(contextInfo != null) {
var contextInfo0 = contextInfo.orElse(null);
if(contextInfo0 != null) {
outputStream.writeBytes(17, it.auties.whatsapp.model.info.ContextInfoSpec.encode(contextInfo0));
}
}
      return outputStream.toByteArray();
    }

    public static LiveLocationMessage decode(byte[] input) {
        if(input == null) {
            return null;
        }
        var inputStream = new ProtobufInputStream(input);
        double latitude = 0d;
        double longitude = 0d;
        int accuracy = 0;
        float speed = 0f;
        int magneticNorthOffset = 0;
        java.lang.String caption = null;
        long sequenceNumber = 0l;
        int timeOffset = 0;
        byte[] thumbnail = null;
        it.auties.whatsapp.model.info.ContextInfo contextInfo = null;
        while(inputStream.readTag()) {
            switch(inputStream.index()) {
                case 1 -> latitude = inputStream.readDouble();
                case 2 -> longitude = inputStream.readDouble();
                case 3 -> accuracy = inputStream.readInt32();
                case 4 -> speed = inputStream.readFloat();
                case 5 -> magneticNorthOffset = inputStream.readInt32();
                case 6 -> caption = inputStream.readString();
                case 7 -> sequenceNumber = inputStream.readInt64();
                case 8 -> timeOffset = inputStream.readInt32();
                case 16 -> thumbnail = inputStream.readBytes();
                case 17 -> contextInfo = it.auties.whatsapp.model.info.ContextInfoSpec.decode(inputStream.readBytes());
                default -> inputStream.skipBytes();
            }
        }
        return new it.auties.whatsapp.model.message.standard.LiveLocationMessage(latitude, longitude, accuracy, speed, magneticNorthOffset, caption, sequenceNumber, timeOffset, thumbnail, contextInfo);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy