Package javax.json
Interface JsonPatchBuilder
-
public interface JsonPatchBuilderTODO this is a final class in the spec, but that makes no sense. This class can be used to easily createJsonPatches. To get an instance useJson.createPatchBuilder()orJson.createPatchBuilder(JsonArray)The order of the operations corresponds to the order they are builded.NOTICE: A JsonPatchBuilder contains state and therefore is NOT threadsafe and should not be used concurrently.
The following
JsonPatch"[ { "op": "add", "path": "/add/object", "value": { "foo": "bar" } }, { "op": "remove", "path": "/remove/it" }, { "op": "move", "path": "move/to", "from": "move/from" } ]"can be build with the JsonPatchBuilderJsonPatch patch = Json.createJsonPatchBuilder() .add("/add/object", Json.createObjectBuilder() .add("foo", "bar") .build()) .remove("/remove/it") .move("/move/to", "move/from") .build();An instance of a JsonPatchBuilder can be reused for another
JsonPatchafter thebuild()-Method was called.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description JsonPatchBuilderadd(java.lang.String path, boolean value)JsonPatchBuilderadd(java.lang.String path, int value)JsonPatchBuilderadd(java.lang.String path, java.lang.String value)JsonPatchBuilderadd(java.lang.String path, JsonValue value)Adds an 'add'-operation to theJsonPatchJsonPatchbuild()JsonPatchBuildercopy(java.lang.String path, java.lang.String from)Adds a 'copy'-operation to theJsonPatchJsonPatchBuildermove(java.lang.String path, java.lang.String from)Adds a 'move'-operation to theJsonPatchJsonPatchBuilderremove(java.lang.String path)Adds a 'remove'-operation to theJsonPatchJsonPatchBuilderreplace(java.lang.String path, boolean value)JsonPatchBuilderreplace(java.lang.String path, int value)JsonPatchBuilderreplace(java.lang.String path, java.lang.String value)JsonPatchBuilderreplace(java.lang.String path, JsonValue value)Adds a 'replace'-operation to theJsonPatchJsonPatchBuildertest(java.lang.String path, boolean value)JsonPatchBuildertest(java.lang.String path, int value)JsonPatchBuildertest(java.lang.String path, java.lang.String value)JsonPatchBuildertest(java.lang.String path, JsonValue value)Adds a 'test'-operation to theJsonPointer
-
-
-
Method Detail
-
add
JsonPatchBuilder add(java.lang.String path, JsonValue value)
Adds an 'add'-operation to theJsonPatch- Parameters:
path- asJsonPointerwhere the value should be addedvalue- the value to add- Returns:
- the builder instance for chained method calls
- Throws:
java.lang.NullPointerException- if the givenpathisnull
-
add
JsonPatchBuilder add(java.lang.String path, java.lang.String value)
- See Also:
add(String, JsonValue)
-
add
JsonPatchBuilder add(java.lang.String path, int value)
- See Also:
add(String, JsonValue)
-
add
JsonPatchBuilder add(java.lang.String path, boolean value)
- See Also:
add(String, JsonValue)
-
remove
JsonPatchBuilder remove(java.lang.String path)
Adds a 'remove'-operation to theJsonPatch- Parameters:
path- asJsonPointerof the value which should get removed- Returns:
- the builder instance for chained method calls
- Throws:
java.lang.NullPointerException- if the givenpathisnull
-
replace
JsonPatchBuilder replace(java.lang.String path, JsonValue value)
Adds a 'replace'-operation to theJsonPatch- Parameters:
path- asJsonPointerto the value which should get replacedvalue- the new value- Returns:
- the builder instance for chained method calls
- Throws:
java.lang.NullPointerException- if the givenpathisnull
-
replace
JsonPatchBuilder replace(java.lang.String path, java.lang.String value)
- See Also:
replace(String, JsonValue)
-
replace
JsonPatchBuilder replace(java.lang.String path, int value)
- See Also:
replace(String, JsonValue)
-
replace
JsonPatchBuilder replace(java.lang.String path, boolean value)
- See Also:
replace(String, JsonValue)
-
move
JsonPatchBuilder move(java.lang.String path, java.lang.String from)
Adds a 'move'-operation to theJsonPatch- Parameters:
path- where the value should get inserted asJsonPointerfrom- where the value should be taken from asJsonPointer- Returns:
- the builder instance for chained method calls
- Throws:
java.lang.NullPointerException- if the givenpathisnullif the givenfromisnull
-
copy
JsonPatchBuilder copy(java.lang.String path, java.lang.String from)
Adds a 'copy'-operation to theJsonPatch- Parameters:
path- where the copied value should get inserted asJsonPointerfrom- value to copy asJsonPointer- Returns:
- the builder instance for chained method calls
- Throws:
java.lang.NullPointerException- if the givenpathisnullif the givenfromisnull
-
test
JsonPatchBuilder test(java.lang.String path, JsonValue value)
Adds a 'test'-operation to theJsonPointer- Parameters:
path- asJsonPointerto the value to testvalue- value to test- Returns:
- the builder instance for chained method calls
- Throws:
java.lang.NullPointerException- if the givenpathisnull
-
test
JsonPatchBuilder test(java.lang.String path, java.lang.String value)
- See Also:
test(String, JsonValue)
-
test
JsonPatchBuilder test(java.lang.String path, int value)
- See Also:
test(String, JsonValue)
-
test
JsonPatchBuilder test(java.lang.String path, boolean value)
- See Also:
test(String, JsonValue)
-
build
JsonPatch build()
-
-