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

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

package it.auties.whatsapp.model.action;

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

public class ArchiveChatActionSpec {
    public static byte[] encode(ArchiveChatAction protoInputObject) {
      if(protoInputObject == null) {
         return null;
      }
      var outputStream = new ProtobufOutputStream();
outputStream.writeBool(1, protoInputObject.archived());
var messageRange = protoInputObject.messageRange();
var messageRange0 = messageRange.orElse(null);
if(messageRange0 != null) {
outputStream.writeBytes(2, it.auties.whatsapp.model.sync.ActionMessageRangeSyncSpec.encode(messageRange0));
}
      return outputStream.toByteArray();
    }

    public static ArchiveChatAction decode(byte[] input) {
        if(input == null) {
            return null;
        }
        var inputStream = new ProtobufInputStream(input);
        boolean archived = false;
        java.util.Optional messageRange = java.util.Optional.empty();
        while(inputStream.readTag()) {
            switch(inputStream.index()) {
                case 1 -> archived = inputStream.readBool();
                case 2 -> messageRange = java.util.Optional.ofNullable(it.auties.whatsapp.model.sync.ActionMessageRangeSyncSpec.decode(inputStream.readBytes()));
                default -> inputStream.skipBytes();
            }
        }
        return new it.auties.whatsapp.model.action.ArchiveChatAction(archived, messageRange);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy