Package org.eclipse.ditto.json
Interface JsonPatch
-
public interface JsonPatch
Defines a JSON Patch which can be used to specify modifications on JSON Objects. For example, the following patch defines an insertion operation on path "address/city" with value "Berlin".{ "op": "add", "path": "address/city", "value": "Berlin" }
Implementations of this interface are required to be immutable!
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
JsonPatch.JsonFields
An enumeration of the knownJsonField
s of a Thing.static class
JsonPatch.Operation
Enumeration defining the supported JSON Patch operation types.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description JsonPatch.Operation
getOperation()
Returns the JSON Patch operation type.JsonPointer
getPath()
Returns the path within the JSON Object on which the operation is defined.java.util.Optional<JsonValue>
getValue()
Returns the value to be used for the specified operation on the given path, if applicable, or an emptyOptional
otherwise.static JsonPatch
newInstance(JsonPatch.Operation operation, JsonPointer path, JsonValue value)
Returns a new JSON Patch which can be used to specify modifications on JSON Objects.JsonObject
toJson()
Returns the JSON object representation of this JSON Patch.java.lang.String
toString()
Returns the JSON string for this JSON Patch in its minimal form, without any additional whitespace.
-
-
-
Method Detail
-
newInstance
static JsonPatch newInstance(JsonPatch.Operation operation, JsonPointer path, JsonValue value)
Returns a new JSON Patch which can be used to specify modifications on JSON Objects.- Parameters:
operation
- the patch operation typepath
- a JSON Pointer specifying the path within the JSON Object on which the operation is definedvalue
- the value to be used for the specified operation on the given path- Returns:
- the new JSON Patch.
- Throws:
java.lang.NullPointerException
- ifoperation
orpath
isnull
.
-
getOperation
JsonPatch.Operation getOperation()
Returns the JSON Patch operation type.- Returns:
Operation
-
getPath
JsonPointer getPath()
Returns the path within the JSON Object on which the operation is defined.- Returns:
- the path.
-
getValue
java.util.Optional<JsonValue> getValue()
Returns the value to be used for the specified operation on the given path, if applicable, or an emptyOptional
otherwise.- Returns:
- the value.
-
toJson
JsonObject toJson()
Returns the JSON object representation of this JSON Patch.- Returns:
- the JSON object representation of this patch.
-
toString
java.lang.String toString()
Returns the JSON string for this JSON Patch in its minimal form, without any additional whitespace.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a JSON string that represents this JSON Patch.
-
-