DelegatingDocumentNodeState extends AbstractDocumentNodeState { @Override public AbstractDocumentNodeState withRootRevision(@NotNull RevisionVector root, boolean externalChange) { if (rootRevision.equals(root) && fromExternalChange == externalChange) { return this; } else { return new DelegatingDocumentNodeState(this, root, externalChange); } } private  DelegatingDocumentNodeState(NodeState delegate, Path path, RevisionVector rootRevision,
                                       boolean fromExternalChange, NodeStateDiffer differ); private  DelegatingDocumentNodeState(DelegatingDocumentNodeState original,
                                        RevisionVector rootRevision, boolean fromExternalChange); static NodeState wrapIfPossible(NodeState delegate, NodeStateDiffer differ); static boolean hasMetaProps(NodeState delegate); static AbstractDocumentNodeState wrap(NodeState delegate, NodeStateDiffer differ); @Override Path getPath(); @Override RevisionVector getLastRevision(); @Override RevisionVector getRootRevision(); @Override boolean isFromExternalChange(); @Override AbstractDocumentNodeState withRootRevision(@NotNull RevisionVector root, boolean externalChange); @Override boolean hasNoChildren(); @Override boolean exists(); @NotNull @Override Iterable<? extends PropertyState> getProperties(); @Override boolean hasChildNode(@NotNull String name); @NotNull @Override NodeState getChildNode(@NotNull String name); @NotNull @Override Iterable<? extends ChildNodeEntry> getChildNodeEntries(); @NotNull @Override NodeBuilder builder(); @Override PropertyState getProperty(@NotNull String name); @Override long getPropertyCount(); @Override boolean hasProperty(@NotNull String name); @Override boolean getBoolean(@NotNull String name); @Override long getLong(String name); @Override String getString(String name); @NotNull @Override Iterable<String> getStrings(@NotNull String name); @Override String getName(@NotNull String name); @NotNull @Override Iterable<String> getNames(@NotNull String name); @Override long getChildNodeCount(long max); @Override Iterable<String> getChildNodeNames(); static final String PROP_REVISION; static final String PROP_LAST_REV; }
@Test public void withRootRevision() throws Exception{ RevisionVector rv1 = new RevisionVector(new Revision(1,0,1)); RevisionVector rv2 = new RevisionVector(new Revision(1,0,3)); builder.setProperty(asPropertyState(PROP_REVISION, rv1)); builder.setProperty(asPropertyState(PROP_LAST_REV, rv2)); AbstractDocumentNodeState state = DelegatingDocumentNodeState.wrap(builder.getNodeState(), NodeStateDiffer.DEFAULT_DIFFER); AbstractDocumentNodeState state2 = state.withRootRevision(rv1, false); assertSame(state, state2); RevisionVector rv4 = new RevisionVector(new Revision(1,0,4)); AbstractDocumentNodeState state3 = state.withRootRevision(rv4, true); assertEquals(rv4, state3.getRootRevision()); assertTrue(state3.isFromExternalChange()); }