pl.grzeslowski.jsupla.protocol.api.encoders.sc.SuplaChannelRelationPackEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protocol Show documentation
Show all versions of protocol Show documentation
Uploads all artifacts belonging to configuration ':protocol:archives'
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.SuplaChannelRelationPack;
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_SuplaChannelRelationPack", date = "2024-09-06T08:44:37.897Z[Etc/UTC]")
@lombok.NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
public class SuplaChannelRelationPackEncoder implements pl.grzeslowski.jsupla.protocol.api.encoders.sc.ServerClientEncoder {
public static final SuplaChannelRelationPackEncoder INSTANCE = new SuplaChannelRelationPackEncoder();
@Override
public byte[] encode(SuplaChannelRelationPack 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.SuplaChannelRelationEncoder.INSTANCE.encode(element);
offset += itemsBytes.length;
}
return bytes;
}
}