pl.grzeslowski.jsupla.protocol.api.encoders.SuplaChannelExtendedValueEncoder Maven / Gradle / Ivy
package pl.grzeslowski.jsupla.protocol.api.encoders;
import lombok.val;
import pl.grzeslowski.jsupla.protocol.api.encoders.PrimitiveEncoder;
import pl.grzeslowski.jsupla.protocol.api.structs.SuplaChannelExtendedValue;
import static pl.grzeslowski.jsupla.protocol.api.JavaConsts.*;
import static pl.grzeslowski.jsupla.protocol.api.consts.ProtoConsts.*;
@javax.annotation.Generated(value="Struct original name: TSuplaChannelExtendedValue", date = "2024-08-03T11:49:42.118Z[Etc/UTC]")
@lombok.NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
public class SuplaChannelExtendedValueEncoder implements pl.grzeslowski.jsupla.protocol.api.encoders.ProtoWithSizeEncoder {
public static final SuplaChannelExtendedValueEncoder INSTANCE = new SuplaChannelExtendedValueEncoder();
@Override
public byte[] encode(SuplaChannelExtendedValue proto) {
final byte[] bytes = new byte[proto.size()];
int offset = 0;
offset += PrimitiveEncoder.INSTANCE.writeByte(proto.type, bytes, offset);
offset += PrimitiveEncoder.INSTANCE.writeUnsignedInt(proto.size, bytes, offset);
offset += PrimitiveEncoder.INSTANCE.writeByteArray(proto.value, bytes, offset);
return bytes;
}
}