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

pl.grzeslowski.jsupla.protocol.api.encoders.sc.SuplaChannelPackEEncoder Maven / Gradle / Ivy

The newest version!
package pl.grzeslowski.jsupla.protocol.api.encoders.sc;

import lombok.val;
import pl.grzeslowski.jsupla.protocol.api.encoders.PrimitiveEncoder;
import pl.grzeslowski.jsupla.protocol.api.structs.sc.SuplaChannelPackE;
import static pl.grzeslowski.jsupla.protocol.api.JavaConsts.*;
import static pl.grzeslowski.jsupla.protocol.api.consts.ProtoConsts.*;

@javax.annotation.Generated(value="Struct original name: TSC_SuplaChannelPack_E", date = "2024-09-06T08:44:37.896Z[Etc/UTC]")
@lombok.NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
public class SuplaChannelPackEEncoder implements pl.grzeslowski.jsupla.protocol.api.encoders.sc.ServerClientEncoder {
	public static final SuplaChannelPackEEncoder INSTANCE = new SuplaChannelPackEEncoder();

   @Override
	public byte[] encode(SuplaChannelPackE proto) {
final byte[] bytes = new byte[proto.size()];
int offset = 0;

		offset += PrimitiveEncoder.INSTANCE.writeInt(proto.count, bytes, offset);
		offset += PrimitiveEncoder.INSTANCE.writeInt(proto.totalLeft, bytes, offset);
		for (val element : proto.items) {
			byte[] itemsBytes = pl.grzeslowski.jsupla.protocol.api.encoders.sc.SuplaChannelEEncoder.INSTANCE.encode(element);
			offset += itemsBytes.length;
		}				
		
	    return bytes;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy