DocumentNodeState extends AbstractDocumentNodeState implements CacheValue { @NotNull DocumentNodeState asBranchRootState(@NotNull DocumentNodeStoreBranch branch) { checkState(path.isRoot()); checkState(getRootRevision().isBranch()); return new DocumentBranchRootNodeState(store, branch, path, rootRevision, lastRevision, bundlingContext, memory); } DocumentNodeState(@NotNull DocumentNodeStore store,
                      @NotNull Path path,
                      @NotNull RevisionVector rootRevision);   DocumentNodeState(@NotNull DocumentNodeStore store, @NotNull Path path,
                      @NotNull RevisionVector rootRevision,
                      Iterable<? extends PropertyState> properties,
                      boolean hasChildren,
                      @Nullable RevisionVector lastRevision);  DocumentNodeState(@NotNull DocumentNodeStore store,
                             @NotNull Path path,
                             @NotNull RevisionVector rootRevision,
                             @NotNull Map<String, PropertyState> properties,
                             boolean hasChildren,
                             int memory,
                             @Nullable RevisionVector lastRevision,
                             boolean fromExternalChange); protected  DocumentNodeState(@NotNull DocumentNodeStore store,
                                @NotNull Path path,
                                @Nullable RevisionVector lastRevision,
                                @NotNull RevisionVector rootRevision,
                                boolean fromExternalChange,
                                BundlingContext bundlingContext,
                                int memory); @Override DocumentNodeState withRootRevision(@NotNull RevisionVector root,
                                               boolean externalChange); @NotNull DocumentNodeState fromExternalChange(); @Override boolean isFromExternalChange(); @NotNull RevisionVector getRootRevision(); @Override Path getPath(); @Override RevisionVector getLastRevision(); @Override boolean exists(); @Override PropertyState getProperty(@NotNull String name); @Override boolean hasProperty(@NotNull String name); @NotNull @Override Iterable<? extends PropertyState> getProperties(); @Override boolean hasChildNode(@NotNull String name); @NotNull @Override NodeState getChildNode(@NotNull String name); @Override long getChildNodeCount(long max); @Override long getPropertyCount(); @NotNull @Override Iterable<? extends ChildNodeEntry> getChildNodeEntries(); @NotNull @Override NodeBuilder builder(); Set<String> getBundledChildNodeNames(); boolean hasOnlyBundledChildren(); @Override boolean hasNoChildren(); @Override String toString(); @Override int getMemory(); Iterable<DocumentNodeState> getAllBundledNodesStates(); Map<String, String> getAllBundledProperties(); static final Children NO_CHILDREN; }
@Test public void asBranchRootState() { DocumentNodeStore store = builderProvider.newBuilder().getNodeStore(); DocumentNodeStoreBranch branch = store.createBranch(store.getRoot()); NodeBuilder builder = branch.getBase().builder(); builder.child("a"); branch.setRoot(builder.getNodeState()); branch.persist(); asDocumentState(branch.getHead()).asBranchRootState(branch); }
@Test(expected = IllegalStateException.class) public void asBranchRootStateNonBranch() { DocumentNodeStore store = builderProvider.newBuilder().getNodeStore(); DocumentNodeStoreBranch branch = store.createBranch(store.getRoot()); store.getRoot().asBranchRootState(branch); }