Package com.rpl.agentorama.store
Interface DocumentStore<K>
- Type Parameters:
K- the type of keys
- All Superinterfaces:
KeyValueStore<K,,Map> PStateStore,Store
DocumentStore is like a key-value store where each value is a document (map) that can contain
nested fields. Stores are distributed, durable, and replicated.
Document stores are created using
AgentTopology.declareDocumentStore(String, Class, Object...).-
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsDocumentField(K key, Object docKey) Checks if a document contains a specific field.getDocumentField(K key, Object docKey) Gets a field value from a document.getDocumentFieldOrDefault(K key, Object docKey, Object defaultValue) Gets a field value from a document, or returns a default value if not found.voidputDocumentField(K key, Object docKey, Object value) Sets a field value in a document.<T,R> void updateDocumentField(K key, Object docKey, com.rpl.rama.ops.RamaFunction1<T, R> updateFunction) Updates a field value in a document using the provided function.Methods inherited from interface com.rpl.agentorama.store.KeyValueStore
containsKey, get, getOrDefault, put, update
-
Method Details
-
getDocumentField
Gets a field value from a document.- Parameters:
key- the document keydocKey- the field key within the document- Returns:
- the field value, or null if not found
-
getDocumentFieldOrDefault
Gets a field value from a document, or returns a default value if not found.- Parameters:
key- the document keydocKey- the field key within the documentdefaultValue- the default value to return if field is not found- Returns:
- the field value, or the default value if not found
-
containsDocumentField
Checks if a document contains a specific field.- Parameters:
key- the document keydocKey- the field key to check- Returns:
- true if the document contains the field, false otherwise
-
putDocumentField
Sets a field value in a document.- Parameters:
key- the document keydocKey- the field key within the documentvalue- the value to set
-
updateDocumentField
<T,R> void updateDocumentField(K key, Object docKey, com.rpl.rama.ops.RamaFunction1<T, R> updateFunction) Updates a field value in a document using the provided function.- Parameters:
key- the document keydocKey- the field key within the documentupdateFunction- function to apply to the current field value
-