Interface Document
public interface Document
Provides a set of mutation operations with a Document.
-
Method Summary
Modifier and TypeMethodDescriptionAdd new property to a document by a given path.asJson()Json representation of Document.asMap()Map representation of Document.asYaml()YAML representation of Document.Delete property from a document by a given path.com.fasterxml.jackson.databind.JsonNodeGet original document.Returns a result document after all applied operations.map(String path, MapFunction mapFunction) Map a specificMapFunctionon a given path.Put a key/value pair to a document by a given json path.Read a list of strings from a document by a given json path.default Object<T> TRead value from a document by a given json path.readValues(String path) <T> List<T>readValues(String path, Class<T> clazz) Read a list of values from a document by a given json path.Rename a key at a given json path.Set property to a document by a given path.
-
Method Details
-
getDocument
com.fasterxml.jackson.databind.JsonNode getDocument()Get original document.- Returns:
- original document as
JsonNode
-
readValue
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
-
readValues
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
-
readPaths
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
Set property to a document by a given path.- Parameters:
path- json path of a propertyvalue- value to set- Returns:
- same document instance
-
map
Map a specificMapFunctionon a given path.- Parameters:
path- json path where function appliesmapFunction- value to set- Returns:
- same document instance
-
delete
Delete property from a document by a given path.- Parameters:
path- json path of a property- Returns:
- same document instance
-
add
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
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
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
Map representation of Document.- Returns:
- a map representation of a document
-
asJson
String asJson()Json representation of Document.- Returns:
- a Json String representation of a Document
-
asYaml
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
-