@Override public int getMaxSerializedSize() { int size = 4 * values.size(); // max 4 bytes for storing each value's size for (Value v : values) { size += ValueUtility.toGbp(v).getSerializedSize(); } return size; }
/** Encode using regular protobuf delimited field writes */ @Override public void writeTo(ByteBuffer bb) { VarIntUtil.writeVarInt32(bb, values.size()); for (Value v : values) { byte[] b = ValueUtility.toGbp(v).toByteArray(); VarIntUtil.writeVarInt32(bb, b.length); bb.put(b); } }
@Override public void updatedCommand(CommandId cmdId, long changeDate, String key, Value value) { CommandHistoryAttribute cha = CommandHistoryAttribute.newBuilder() .setName(key) .setValue(ValueUtility.toGbp(value)) .build(); CommandHistoryEntry entry = CommandHistoryEntry.newBuilder().setCommandId(cmdId).addAttr(cha).build(); doSend(entry); }