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

it.auties.whatsapp.model.action.ContactActionSpec Maven / Gradle / Ivy

package it.auties.whatsapp.model.action;

import it.auties.whatsapp.model.action.ContactAction;
import it.auties.protobuf.stream.ProtobufInputStream;
import it.auties.protobuf.stream.ProtobufOutputStream;

public class ContactActionSpec {
    public static byte[] encode(ContactAction protoInputObject) {
      if(protoInputObject == null) {
         return null;
      }
      var outputStream = new ProtobufOutputStream();
var fullName = protoInputObject.fullName();
var fullName0 = fullName.orElse(null);
if(fullName0 != null) {
outputStream.writeString(1, fullName0);
}
var firstName = protoInputObject.firstName();
var firstName0 = firstName.orElse(null);
if(firstName0 != null) {
outputStream.writeString(2, firstName0);
}
var lidJid = protoInputObject.lidJid();
var lidJid0 = lidJid.orElse(null);
if(lidJid0 != null) {
outputStream.writeString(3, lidJid0);
}
      return outputStream.toByteArray();
    }

    public static ContactAction decode(byte[] input) {
        if(input == null) {
            return null;
        }
        var inputStream = new ProtobufInputStream(input);
        java.util.Optional fullName = java.util.Optional.empty();
        java.util.Optional firstName = java.util.Optional.empty();
        java.util.Optional lidJid = java.util.Optional.empty();
        while(inputStream.readTag()) {
            switch(inputStream.index()) {
                case 1 -> fullName = java.util.Optional.ofNullable(inputStream.readString());
                case 2 -> firstName = java.util.Optional.ofNullable(inputStream.readString());
                case 3 -> lidJid = java.util.Optional.ofNullable(inputStream.readString());
                default -> inputStream.skipBytes();
            }
        }
        return new it.auties.whatsapp.model.action.ContactAction(fullName, firstName, lidJid);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy