V
- document tree value type@NotThreadSafe public interface AsyncDocumentTree<V> extends DistributedPrimitive, Transactional<NodeUpdate<V>>
DistributedPrimitive.Status, DistributedPrimitive.Type
DEFAULT_OPERATION_TIMEOUT_MILLIS, DEFAULT_OPERTATION_TIMEOUT_MILLIS
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Void> |
addListener(DocumentPath path,
DocumentTreeListener<V> listener)
Registers a listener to be notified when the subtree rooted at the specified path
is modified.
|
default CompletableFuture<Void> |
addListener(DocumentTreeListener<V> listener)
Registers a listener to be notified when the tree is modified.
|
default DocumentTree<V> |
asDocumentTree()
Returns a new
DocumentTree that is backed by this instance. |
default DocumentTree<V> |
asDocumentTree(long timeoutMillis)
Returns a new
DocumentTree that is backed by this instance. |
CompletableFuture<Boolean> |
create(DocumentPath path,
V value)
Creates a document tree node if one does not exist already.
|
CompletableFuture<Boolean> |
createRecursive(DocumentPath path,
V value)
Creates a document tree node recursively by creating all missing intermediate nodes in the path.
|
CompletableFuture<Versioned<V>> |
get(DocumentPath path)
Returns the value of the tree node at specified path.
|
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.
|
default DistributedPrimitive.Type |
primitiveType()
Returns the type of primitive.
|
CompletableFuture<Void> |
removeListener(DocumentTreeListener<V> listener)
Unregisters a previously added listener.
|
CompletableFuture<Versioned<V>> |
removeNode(DocumentPath path)
Removes the node with the specified path.
|
CompletableFuture<Boolean> |
replace(DocumentPath path,
V newValue,
long version)
Conditionally updates a tree node if the current version matches a specified version.
|
CompletableFuture<Boolean> |
replace(DocumentPath path,
V newValue,
V currentValue)
Conditionally updates a tree node if the current node value matches a specified version.
|
DocumentPath |
root()
Returns the
path to root of the tree. |
CompletableFuture<Versioned<V>> |
set(DocumentPath path,
V value)
Creates or updates a document tree node.
|
addStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners
begin, commit, prepare, prepareAndCommit, rollback
default DistributedPrimitive.Type primitiveType()
DistributedPrimitive
primitiveType
in interface DistributedPrimitive
DocumentPath root()
path
to root of the tree.CompletableFuture<Map<String,Versioned<V>>> getChildren(DocumentPath path)
path
- path to the nodeNoSuchDocumentPathException
- if the path does not point to a valid nodeCompletableFuture<Versioned<V>> get(DocumentPath path)
path
- path to the nodeversioned
value
or null
if path does not point to a valid nodeCompletableFuture<Versioned<V>> set(DocumentPath path, V value)
path
- path to the nodevalue
- value to be associated with the node (null
is a valid value)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 existCompletableFuture<Boolean> create(DocumentPath path, V value)
path
- path to the nodevalue
- the non-null value to be associated with the nodetrue
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 existCompletableFuture<Boolean> createRecursive(DocumentPath path, V value)
path
- path to the nodevalue
- value to be associated with the node (null
is a valid value)true
if the new node was successfully
created. Future will be completed with false
if a node already exists at the specified pathCompletableFuture<Boolean> replace(DocumentPath path, V newValue, long version)
path
- path to the nodenewValue
- value to associate with the node (null
is a valid value)version
- current version of the node for update to occurtrue
if the update was made
or false
if update did not happenCompletableFuture<Boolean> replace(DocumentPath path, V newValue, V currentValue)
path
- path to the nodenewValue
- value to associate with the node (null
is a valid value)currentValue
- current value of the node for update to occurtrue
if the update was made
or false
if update did not happenCompletableFuture<Versioned<V>> removeNode(DocumentPath path)
path
- path to the nodeIllegalDocumentModificationException
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 existCompletableFuture<Void> addListener(DocumentPath path, DocumentTreeListener<V> listener)
path
- path to the nodelistener
- listener to be notifiedCompletableFuture<Void> removeListener(DocumentTreeListener<V> listener)
listener
- listener to unregisterdefault CompletableFuture<Void> addListener(DocumentTreeListener<V> listener)
listener
- listener to be notifieddefault DocumentTree<V> asDocumentTree()
DocumentTree
that is backed by this instance.DocumentTree
instancedefault DocumentTree<V> asDocumentTree(long timeoutMillis)
DocumentTree
that is backed by this instance.timeoutMillis
- timeout duration for the returned DocumentTree operationsDocumentTree
instance