Class DefaultDocumentTree<V>

    • Constructor Detail

      • DefaultDocumentTree

        public DefaultDocumentTree​(AsyncDocumentTree<V> backingTree,
                                   long operationTimeoutMillis)
    • Method Detail

      • getChildren

        public java.util.Map<java.lang.String,​Versioned<V>> getChildren​(DocumentPath path)
        Description copied from interface: DocumentTree
        Returns the child values for this node.
        Specified by:
        getChildren in interface DocumentTree<V>
        Parameters:
        path - path to the node
        Returns:
        mapping from a child name to its value
      • get

        public Versioned<V> get​(DocumentPath path)
        Description copied from interface: DocumentTree
        Returns a document tree node.
        Specified by:
        get in interface DocumentTree<V>
        Parameters:
        path - path to node
        Returns:
        node value or null if path does not point to a valid node
      • set

        public Versioned<V> set​(DocumentPath path,
                                V value)
        Description copied from interface: DocumentTree
        Creates or updates a document tree node.
        Specified by:
        set in interface DocumentTree<V>
        Parameters:
        path - path for the node to create or update
        value - the non-null value to be associated with the key
        Returns:
        the previous mapping or null if there was no previous mapping
      • create

        public boolean create​(DocumentPath path,
                              V value)
        Description copied from interface: DocumentTree
        Creates a document tree node if one does not exist already.
        Specified by:
        create in interface DocumentTree<V>
        Parameters:
        path - path for the node to create
        value - the non-null value to be associated with the key
        Returns:
        returns true if the mapping could be added successfully, false otherwise
      • createRecursive

        public boolean createRecursive​(DocumentPath path,
                                       V value)
        Description copied from interface: DocumentTree
        Creates a document tree node by first creating any missing intermediate nodes in the path.
        Specified by:
        createRecursive in interface DocumentTree<V>
        Parameters:
        path - path for the node to create
        value - the non-null value to be associated with the key
        Returns:
        returns true if the mapping could be added successfully, false if a node already exists at that path
      • replace

        public boolean replace​(DocumentPath path,
                               V newValue,
                               long version)
        Description copied from interface: DocumentTree
        Conditionally updates a tree node if the current version matches a specified version.
        Specified by:
        replace in interface DocumentTree<V>
        Parameters:
        path - path for the node to create
        newValue - the non-null value to be associated with the key
        version - current version of the value for update to occur
        Returns:
        returns true if the update was made and the tree was modified, false otherwise
      • replace

        public boolean replace​(DocumentPath path,
                               V newValue,
                               V currentValue)
        Description copied from interface: DocumentTree
        Conditionally updates a tree node if the current value matches a specified value.
        Specified by:
        replace in interface DocumentTree<V>
        Parameters:
        path - path for the node to create
        newValue - the non-null value to be associated with the key
        currentValue - current value for update to occur
        Returns:
        returns true if the update was made and the tree was modified, false otherwise. This method returns false if the newValue and currentValue are same.
      • removeNode

        public Versioned<V> removeNode​(DocumentPath path)
        Description copied from interface: DocumentTree
        Removes the node with the specified path.
        Specified by:
        removeNode in interface DocumentTree<V>
        Parameters:
        path - path for the node to remove
        Returns:
        the previous value of the node or null if it did not exist
      • addListener

        public void addListener​(DocumentPath path,
                                DocumentTreeListener<V> listener)
        Description copied from interface: DocumentTree
        Registers a listener to be notified when a subtree rooted at the specified path is modified.
        Specified by:
        addListener in interface DocumentTree<V>
        Parameters:
        path - path to root of subtree to monitor for updates
        listener - listener to be notified
      • addListener

        public void addListener​(DocumentTreeListener<V> listener)
        Description copied from interface: DocumentTree
        Registers a listener to be notified when the tree is modified.
        Specified by:
        addListener in interface DocumentTree<V>
        Parameters:
        listener - listener to be notified