DelegatingDocumentNodeState extends AbstractDocumentNodeState { public static NodeState wrapIfPossible(NodeState delegate, NodeStateDiffer differ) { if (hasMetaProps(delegate)) { String revVector = getRequiredProp(delegate, PROP_REVISION); return new DelegatingDocumentNodeState(delegate, Path.ROOT, RevisionVector.fromString(revVector), false, differ); } return delegate; } 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 wrapIfPossible() throws Exception{ assertFalse(DelegatingDocumentNodeState.wrapIfPossible(EMPTY_NODE, NodeStateDiffer.DEFAULT_DIFFER) instanceof AbstractDocumentNodeState); setMetaProps(builder); assertTrue(DelegatingDocumentNodeState.wrapIfPossible(builder.getNodeState(), NodeStateDiffer.DEFAULT_DIFFER) instanceof AbstractDocumentNodeState); }