Interface AsyncDocumentTree<V>

    • Method Detail

      • root

        DocumentPath root()
        Returns the path to root of the tree.
        Returns:
        path to root of the tree
      • getChildren

        CompletableFuture<Map<String,​Versioned<V>>> getChildren​(DocumentPath path)
        Returns the children of node at specified path in the form of a mapping from child name to child value.
        Parameters:
        path - path to the node
        Returns:
        future for mapping from child name to child value
        Throws:
        NoSuchDocumentPathException - if the path does not point to a valid node
      • get

        CompletableFuture<Versioned<V>> get​(DocumentPath path)
        Returns the value of the tree node at specified path.
        Parameters:
        path - path to the node
        Returns:
        future that will be either be completed with node's versioned value or null if path does not point to a valid node
      • set

        CompletableFuture<Versioned<V>> set​(DocumentPath path,
                                            V value)
        Creates or updates a document tree node.
        Parameters:
        path - path to the node
        value - value to be associated with the node (null is a valid value)
        Returns:
        future that will either be completed with the previous versioned value or null if there was no node previously at that path. Future will be completed with a IllegalDocumentModificationException if the parent node (for the node to create/update) does not exist
      • create

        CompletableFuture<Boolean> create​(DocumentPath path,
                                          V value)
        Creates a document tree node if one does not exist already.
        Parameters:
        path - path to the node
        value - the non-null value to be associated with the node
        Returns:
        future that is completed with true if the new node was successfully created. Future will be completed with false if a node already exists at the specified path. Future will be completed exceptionally with a IllegalDocumentModificationException if the parent node (for the node to create) does not exist
      • createRecursive

        CompletableFuture<Boolean> createRecursive​(DocumentPath path,
                                                   V value)
        Creates a document tree node recursively by creating all missing intermediate nodes in the path.
        Parameters:
        path - path to the node
        value - value to be associated with the node (null is a valid value)
        Returns:
        future that is completed with true if the new node was successfully created. Future will be completed with false if a node already exists at the specified path
      • replace

        CompletableFuture<Boolean> replace​(DocumentPath path,
                                           V newValue,
                                           long version)
        Conditionally updates a tree node if the current version matches a specified version.
        Parameters:
        path - path to the node
        newValue - value to associate with the node (null is a valid value)
        version - current version of the node for update to occur
        Returns:
        future that is either completed with true if the update was made or false if update did not happen
      • replace

        CompletableFuture<Boolean> replace​(DocumentPath path,
                                           V newValue,
                                           V currentValue)
        Conditionally updates a tree node if the current node value matches a specified version.
        Parameters:
        path - path to the node
        newValue - value to associate with the node (null is a valid value)
        currentValue - current value of the node for update to occur
        Returns:
        future that is either completed with true if the update was made or false if update did not happen
      • removeNode

        CompletableFuture<Versioned<V>> removeNode​(DocumentPath path)
        Removes the node with the specified path.
        Parameters:
        path - path to the node
        Returns:
        future for the previous value. Future will be completed with a IllegalDocumentModificationException if the node to be removed is either the root node or has one or more children. Future will be completed with a NoSuchDocumentPathException if the node to be removed does not exist
      • addListener

        CompletableFuture<Void> addListener​(DocumentPath path,
                                            DocumentTreeListener<V> listener)
        Registers a listener to be notified when the subtree rooted at the specified path is modified.
        Parameters:
        path - path to the node
        listener - listener to be notified
        Returns:
        a future that is completed when the operation completes
      • removeListener

        CompletableFuture<Void> removeListener​(DocumentTreeListener<V> listener)
        Unregisters a previously added listener.
        Parameters:
        listener - listener to unregister
        Returns:
        a future that is completed when the operation completes
      • addListener

        default CompletableFuture<Void> addListener​(DocumentTreeListener<V> listener)
        Registers a listener to be notified when the tree is modified.
        Parameters:
        listener - listener to be notified
        Returns:
        a future that is completed when the operation completes
      • asDocumentTree

        default DocumentTree<V> asDocumentTree()
        Returns a new DocumentTree that is backed by this instance.
        Returns:
        new DocumentTree instance
      • asDocumentTree

        default DocumentTree<V> asDocumentTree​(long timeoutMillis)
        Returns a new DocumentTree that is backed by this instance.
        Parameters:
        timeoutMillis - timeout duration for the returned DocumentTree operations
        Returns:
        new DocumentTree instance