DataTypeUtil { static void stateToBuffer(DocumentNodeState state, WriteBuffer buffer) { pathToBuffer(state.getPath(), buffer); revisionVectorToBuffer(state.getRootRevision(), buffer); RevisionVector lastRevision = state.getLastRevision(); if (lastRevision == null) { lastRevision = RevisionVector.fromString(""); } revisionVectorToBuffer(lastRevision, buffer); buffer.putVarInt(state.getMemory()); booleanToBuffer(state.hasNoChildren(), buffer); Map<String, String> props = state.getAllBundledProperties(); buffer.putVarInt(props.size()); for (Map.Entry<String, String> e : props.entrySet()) { StringDataType.INSTANCE.write(buffer, e.getKey()); StringDataType.INSTANCE.write(buffer, e.getValue()); } }    }
@Test public void stateToBuffer() { DocumentNodeStore ns = builderProvider.newBuilder().build(); Path p = Path.fromString("/foo/bar"); RevisionVector rootRev = ns.getHeadRevision(); DocumentNodeState expected = new DocumentNodeState(ns, p, rootRev, Collections.emptyMap(), true, 0, rootRev, false); DataTypeUtil.stateToBuffer(expected, wb); ByteBuffer rb = readBufferFrom(wb); assertEquals(expected, DataTypeUtil.stateFromBuffer(ns, rb)); }