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

it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredDateTimeComponentSpec Maven / Gradle / Ivy

package it.auties.whatsapp.model.button.template.highlyStructured;

import it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredDateTimeComponent;
import it.auties.protobuf.stream.ProtobufInputStream;
import it.auties.protobuf.stream.ProtobufOutputStream;

public class HighlyStructuredDateTimeComponentSpec {
    public static byte[] encode(HighlyStructuredDateTimeComponent protoInputObject) {
      if(protoInputObject == null) {
         return null;
      }
      var outputStream = new ProtobufOutputStream();
outputStream.writeInt32(1, it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredDateTimeComponentDayOfWeekSpec.encode(protoInputObject.dayOfWeek()));
outputStream.writeUInt32(2, protoInputObject.year());
outputStream.writeUInt32(3, protoInputObject.month());
outputStream.writeUInt32(4, protoInputObject.dayOfMonth());
outputStream.writeUInt32(5, protoInputObject.hour());
outputStream.writeUInt32(6, protoInputObject.minute());
outputStream.writeInt32(7, it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredDateTimeComponentCalendarTypeSpec.encode(protoInputObject.calendar()));
      return outputStream.toByteArray();
    }

    public static HighlyStructuredDateTimeComponent decode(byte[] input) {
        if(input == null) {
            return null;
        }
        var inputStream = new ProtobufInputStream(input);
        it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredDateTimeComponent.DayOfWeek dayOfWeek = null;
        int year = 0;
        int month = 0;
        int dayOfMonth = 0;
        int hour = 0;
        int minute = 0;
        it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredDateTimeComponent.CalendarType calendar = null;
        while(inputStream.readTag()) {
            switch(inputStream.index()) {
                case 1 -> dayOfWeek = it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredDateTimeComponentDayOfWeekSpec.decode(inputStream.readInt32()).orElse(null);
                case 2 -> year = inputStream.readInt32();
                case 3 -> month = inputStream.readInt32();
                case 4 -> dayOfMonth = inputStream.readInt32();
                case 5 -> hour = inputStream.readInt32();
                case 6 -> minute = inputStream.readInt32();
                case 7 -> calendar = it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredDateTimeComponentCalendarTypeSpec.decode(inputStream.readInt32()).orElse(null);
                default -> inputStream.skipBytes();
            }
        }
        return new it.auties.whatsapp.model.button.template.highlyStructured.HighlyStructuredDateTimeComponent(dayOfWeek, year, month, dayOfMonth, hour, minute, calendar);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy