// Creating a CoreWaveletData because the current protocol lacks the
// meta-data required to construct an ObservableWaveletData directly.
// But this results in unnecessary object creation and copies.
CoreWaveletData coreWavelet =
new CoreWaveletDataImpl(waveletName.waveId, waveletName.waveletId);
Preconditions.checkArgument(snapshot.getParticipantIdCount() > 0);
// Have to add a single participant for the copying to complete without a
// NPE.
coreWavelet.addParticipant(ParticipantId.ofUnsafe(snapshot.getParticipantId(0)));
for (DocumentSnapshot document : snapshot.getDocumentList()) {
DocOp op =
CoreWaveletOperationSerializer.deserialize(document.getDocumentOperation());
coreWavelet.modifyDocument(document.getDocumentId(), op);
}
HashedVersion hashedVersion = CoreWaveletOperationSerializer.deserialize(version);
ObservableWaveletData immutableWaveletData =
DataUtil.fromCoreWaveletData(coreWavelet, hashedVersion, SchemaCollection.empty());