JsonPatchBuilderpublic final class JsonPatchBuilderImpl extends Object implements JsonPatchBuilder
The following illustrates the approach.
JsonPatchBuilder builder = Json.createPatchBuilder();
JsonPatch patch = builder.add("/John/phones/office", "1234-567")
.remove("/Amy/age")
.build();
The result is equivalent to the following JSON Patch.
[
{"op" = "add", "path" = "/John/phones/office", "value" = "1234-567"},
{"op" = "remove", "path" = "/Amy/age"}
] | Constructor | Description |
|---|---|
JsonPatchBuilderImpl() |
Creates JsonPatchBuilderImpl with empty JSON Patch
|
JsonPatchBuilderImpl(JsonArray patch) |
Creates a JsonPatchBuilderImpl, starting with the specified
JSON Patch
|
| Modifier and Type | Method | Description |
|---|---|---|
JsonPatchBuilder |
add(String path,
boolean value) |
Adds an "add" JSON Patch operation
|
JsonPatchBuilder |
add(String path,
int value) |
Adds an "add" JSON Patch operation
|
JsonPatchBuilder |
add(String path,
String value) |
Adds an "add" JSON Patch operation
|
JsonPatchBuilder |
add(String path,
JsonValue value) |
Adds an "add" JSON Patch operation.
|
<T extends JsonStructure> |
apply(T target) |
A convenience method for
new JsonPatchImpl(build()).apply(target). |
JsonPatch |
build() |
Returns the patch operation in a JsonPatch
|
JsonArray |
buildAsJsonArray() |
Returns the patch operations in a JsonArray
|
JsonPatchBuilder |
copy(String path,
String from) |
Adds a "copy" JSON Patch operation.
|
JsonPatchBuilder |
move(String path,
String from) |
Adds a "move" JSON Patch operation.
|
JsonPatchBuilder |
remove(String path) |
Adds a "remove" JSON Patch operation.
|
JsonPatchBuilder |
replace(String path,
boolean value) |
Adds a "replace" JSON Patch operation.
|
JsonPatchBuilder |
replace(String path,
int value) |
Adds a "replace" JSON Patch operation.
|
JsonPatchBuilder |
replace(String path,
String value) |
Adds a "replace" JSON Patch operation.
|
JsonPatchBuilder |
replace(String path,
JsonValue value) |
Adds a "replace" JSON Patch operation.
|
JsonPatchBuilder |
test(String path,
boolean value) |
Adds a "test" JSON Patch operation.
|
JsonPatchBuilder |
test(String path,
int value) |
Adds a "test" JSON Patch operation.
|
JsonPatchBuilder |
test(String path,
String value) |
Adds a "test" JSON Patch operation.
|
JsonPatchBuilder |
test(String path,
JsonValue value) |
Adds a "test" JSON Patch operation.
|
public JsonPatchBuilderImpl(JsonArray patch)
patch - the JSON Patchpublic JsonPatchBuilderImpl()
public <T extends JsonStructure> T apply(T target)
new JsonPatchImpl(build()).apply(target).
The target is not modified by the patch.T - the target type, must be a subtype of JsonStructuretarget - the target to apply the patch operationsJsonException - if the supplied JSON Patch is malformed or if
it contains references to non-existing memberspublic JsonPatchBuilder add(String path, JsonValue value)
add in interface JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder add(String path, String value)
add in interface JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder add(String path, int value)
add in interface JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder add(String path, boolean value)
add in interface JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder remove(String path)
remove in interface JsonPatchBuilderpath - the "path" member of the operationpublic JsonPatchBuilder replace(String path, JsonValue value)
replace in interface JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder replace(String path, String value)
replace in interface JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder replace(String path, int value)
replace in interface JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder replace(String path, boolean value)
replace in interface JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder move(String path, String from)
move in interface JsonPatchBuilderpath - the "path" member of the operationfrom - the "from" member of the operationpublic JsonPatchBuilder copy(String path, String from)
copy in interface JsonPatchBuilderpath - the "path" member of the operationfrom - the "from" member of the operationpublic JsonPatchBuilder test(String path, JsonValue value)
test in interface JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder test(String path, String value)
test in interface JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder test(String path, int value)
test in interface JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder test(String path, boolean value)
test in interface JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic JsonArray buildAsJsonArray()
public JsonPatch build()
build in interface JsonPatchBuilderCopyright © 2018 Oracle. All rights reserved.