public interface Document
Provides a set of mutation operations with a Document.
  • Method Details

    • getDocument

      com.fasterxml.jackson.databind.JsonNode getDocument()
      Get original document.
      Returns:
      original document as JsonNode
    • readValue

      <T> T readValue(String path, 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 Object readValue(String path)
    • readValues

      <T> List<T> readValues(String path, 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 List<Object> readValues(String path)
    • readPaths

      List<String> readPaths(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(String path, Object value)
      Set property to a document by a given path.
      Parameters:
      path - json path of a property
      value - value to set
      Returns:
      same document instance
    • map

      Document map(String path, MapFunction mapFunction)
      Map a specific MapFunction on a given path.
      Parameters:
      path - json path where function applies
      mapFunction - value to set
      Returns:
      same document instance
    • delete

      Document delete(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(String path, Object value)
      Add new property to a document by a given path. Works for array properties.
      Parameters:
      path - json path of a property
      value - value to set
      Returns:
      same document instance
    • put

      Document put(String path, String key, 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 added
      key - a key of a property
      value - a value of a property
      Returns:
      same document instance
    • renameKey

      Document renameKey(String path, String oldKeyName, String newKeyName)
      Rename a key at a given json path.
      Parameters:
      path - where the old key is located
      oldKeyName - old key to rename
      newKeyName - a new key that old key should be changed to
      Returns:
      same document instance
    • asMap

      Map<String,Object> 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