Interface Document
-
public interface Document
Provides a set of mutation operations with a Document.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Document
add(java.lang.String path, java.lang.Object value)
Add new property to a document by a given path.java.lang.String
asJson()
Json representation of Document.java.util.Map<java.lang.String,java.lang.Object>
asMap()
Map representation of Document.java.lang.String
asYaml()
YAML representation of Document.Document
delete(java.lang.String path)
Delete property from a document by a given path.com.fasterxml.jackson.databind.JsonNode
getDocument()
Get original document.Document
getMutatedDocument()
Returns a result document after all applied operations.Document
map(java.lang.String path, MapFunction mapFunction)
Map a specificMapFunction
on a given path.Document
put(java.lang.String path, java.lang.String key, java.lang.Object value)
Put a key/value pair to a document by a given json path.java.util.List<java.lang.String>
readPaths(java.lang.String path)
Read a list of strings from a document by a given json path.default java.lang.Object
readValue(java.lang.String path)
<T> T
readValue(java.lang.String path, java.lang.Class<T> clazz)
Read value from a document by a given json path.default java.util.List<java.lang.Object>
readValues(java.lang.String path)
<T> java.util.List<T>
readValues(java.lang.String path, java.lang.Class<T> clazz)
Read a list of values from a document by a given json path.Document
renameKey(java.lang.String path, java.lang.String oldKeyName, java.lang.String newKeyName)
Rename a key at a given json path.Document
set(java.lang.String path, java.lang.Object value)
Set property to a document by a given path.
-
-
-
Method Detail
-
getDocument
com.fasterxml.jackson.databind.JsonNode getDocument()
Get original document.- Returns:
- original document as
JsonNode
-
readValue
<T> T readValue(java.lang.String path, java.lang.Class<T> clazz)
Read value from a document by a given json path.- Type Parameters:
T
- a type of a value- Parameters:
path
- json path to read value from.clazz
- a class of a value type- Returns:
- a value from a specified path
-
readValue
default java.lang.Object readValue(java.lang.String path)
-
readValues
<T> java.util.List<T> readValues(java.lang.String path, java.lang.Class<T> clazz)
Read a list of values from a document by a given json path.- Type Parameters:
T
- a type of a value- Parameters:
path
- json path to read value from.clazz
- a class of a value type- Returns:
- a value from a specified path
-
readValues
default java.util.List<java.lang.Object> readValues(java.lang.String path)
-
readPaths
java.util.List<java.lang.String> readPaths(java.lang.String path)
Read a list of strings from a document by a given json path.- Parameters:
path
- json path to read value from.- Returns:
- a value from a specified path
-
set
Document set(java.lang.String path, java.lang.Object value)
Set property to a document by a given path.- Parameters:
path
- json path of a propertyvalue
- value to set- Returns:
- same document instance
-
map
Document map(java.lang.String path, MapFunction mapFunction)
Map a specificMapFunction
on a given path.- Parameters:
path
- json path where function appliesmapFunction
- value to set- Returns:
- same document instance
-
delete
Document delete(java.lang.String path)
Delete property from a document by a given path.- Parameters:
path
- json path of a property- Returns:
- same document instance
-
add
Document add(java.lang.String path, java.lang.Object value)
Add new property to a document by a given path. Works for array properties.- Parameters:
path
- json path of a propertyvalue
- value to set- Returns:
- same document instance
-
put
Document put(java.lang.String path, java.lang.String key, java.lang.Object value)
Put a key/value pair to a document by a given json path.- Parameters:
path
- a json path of where new key should be addedkey
- a key of a propertyvalue
- a value of a property- Returns:
- same document instance
-
renameKey
Document renameKey(java.lang.String path, java.lang.String oldKeyName, java.lang.String newKeyName)
Rename a key at a given json path.- Parameters:
path
- where the old key is locatedoldKeyName
- old key to renamenewKeyName
- a new key that old key should be changed to- Returns:
- same document instance
-
asMap
java.util.Map<java.lang.String,java.lang.Object> asMap()
Map representation of Document.- Returns:
- a map representation of a document
-
asJson
java.lang.String asJson()
Json representation of Document.- Returns:
- a Json String representation of a Document
-
asYaml
java.lang.String asYaml()
YAML representation of Document.- Returns:
- a Yaml String representation of a Document
-
getMutatedDocument
Document getMutatedDocument()
Returns a result document after all applied operations.- Returns:
- mutated document after all applied operations
-
-