public SenderKeyRecord(byte[] serialized) throws IOException { SenderKeyRecordStructure senderKeyRecordStructure = SenderKeyRecordStructure.parseFrom(serialized); for (StorageProtos.SenderKeyStateStructure structure : senderKeyRecordStructure.getSenderKeyStatesList()) { this.senderKeyStates.add(new SenderKeyState(structure)); } }
public byte[] serialize() { SenderKeyRecordStructure.Builder recordStructure = SenderKeyRecordStructure.newBuilder(); for (SenderKeyState senderKeyState : senderKeyStates) { recordStructure.addSenderKeyStates(senderKeyState.getStructure()); } return recordStructure.build().toByteArray(); }