V
- document tree value type@NotThreadSafe public interface DocumentTree<V> extends DistributedPrimitive
DistributedPrimitive.Status, DistributedPrimitive.Type
DEFAULT_OPERATION_TIMEOUT_MILLIS, DEFAULT_OPERTATION_TIMEOUT_MILLIS
Modifier and Type | Method and Description |
---|---|
void |
addListener(DocumentPath path,
DocumentTreeListener<V> listener)
Registers a listener to be notified when a subtree rooted at the specified path
is modified.
|
default void |
addListener(DocumentTreeListener<V> listener)
Registers a listener to be notified when the tree is modified.
|
boolean |
create(DocumentPath path,
V value)
Creates a document tree node if one does not exist already.
|
boolean |
createRecursive(DocumentPath path,
V value)
Creates a document tree node by first creating any missing intermediate nodes in the path.
|
Versioned<V> |
get(DocumentPath path)
Returns a document tree node.
|
java.util.Map<java.lang.String,Versioned<V>> |
getChildren(DocumentPath path)
Returns the child values for this node.
|
default DistributedPrimitive.Type |
primitiveType()
Returns the type of primitive.
|
void |
removeListener(DocumentTreeListener<V> listener)
Unregisters a previously added listener.
|
Versioned<V> |
removeNode(DocumentPath path)
Removes the node with the specified path.
|
boolean |
replace(DocumentPath path,
V newValue,
long version)
Conditionally updates a tree node if the current version matches a specified version.
|
boolean |
replace(DocumentPath path,
V newValue,
V currentValue)
Conditionally updates a tree node if the current value matches a specified value.
|
DocumentPath |
root()
Returns the
path to root of the tree. |
Versioned<V> |
set(DocumentPath path,
V value)
Creates or updates a document tree node.
|
addStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners
default DistributedPrimitive.Type primitiveType()
DistributedPrimitive
primitiveType
in interface DistributedPrimitive
DocumentPath root()
path
to root of the tree.java.util.Map<java.lang.String,Versioned<V>> getChildren(DocumentPath path)
path
- path to the nodeNoSuchDocumentPathException
- if the path does not point to a valid nodeVersioned<V> get(DocumentPath path)
path
- path to nodenull
if path does not point to a valid nodeVersioned<V> set(DocumentPath path, V value)
path
- path for the node to create or updatevalue
- the non-null value to be associated with the keynull
if there was no previous mappingNoSuchDocumentPathException
- if the parent node (for the node to create/update) does not existboolean create(DocumentPath path, V value)
path
- path for the node to createvalue
- the non-null value to be associated with the keytrue
if the mapping could be added successfully, false
otherwiseNoSuchDocumentPathException
- if the parent node (for the node to create) does not existboolean createRecursive(DocumentPath path, V value)
path
- path for the node to createvalue
- the non-null value to be associated with the keytrue
if the mapping could be added successfully, false
if
a node already exists at that pathIllegalDocumentModificationException
- if path
points to rootboolean replace(DocumentPath path, V newValue, long version)
path
- path for the node to createnewValue
- the non-null value to be associated with the keyversion
- current version of the value for update to occurtrue
if the update was made and the tree was modified, false
otherwiseNoSuchDocumentPathException
- if the parent node (for the node to create) does not existboolean replace(DocumentPath path, V newValue, V currentValue)
path
- path for the node to createnewValue
- the non-null value to be associated with the keycurrentValue
- current value for update to occurtrue
if the update was made and the tree was modified, false
otherwise.
This method returns false
if the newValue and currentValue are same.NoSuchDocumentPathException
- if the parent node (for the node to create) does not existVersioned<V> removeNode(DocumentPath path)
path
- path for the node to removenull
if it did not existIllegalDocumentModificationException
- if the remove to be removedvoid addListener(DocumentPath path, DocumentTreeListener<V> listener)
path
- path to root of subtree to monitor for updateslistener
- listener to be notifiedvoid removeListener(DocumentTreeListener<V> listener)
listener
- listener to unregisterdefault void addListener(DocumentTreeListener<V> listener)
listener
- listener to be notified