javax.json.JsonPatchBuilderpublic final class JsonPatchBuilderImpl extends Object implements javax.json.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(javax.json.JsonArray patch) |
Creates a JsonPatchBuilderImpl, starting with the specified
JSON Patch
|
| Modifier and Type | Method | Description |
|---|---|---|
javax.json.JsonPatchBuilder |
add(String path,
boolean value) |
Adds an "add" JSON Patch operation
|
javax.json.JsonPatchBuilder |
add(String path,
int value) |
Adds an "add" JSON Patch operation
|
javax.json.JsonPatchBuilder |
add(String path,
String value) |
Adds an "add" JSON Patch operation
|
javax.json.JsonPatchBuilder |
add(String path,
javax.json.JsonValue value) |
Adds an "add" JSON Patch operation.
|
<T extends javax.json.JsonStructure> |
apply(T target) |
A convenience method for
new JsonPatchImpl(build()).apply(target). |
javax.json.JsonPatch |
build() |
Returns the patch operation in a JsonPatch
|
javax.json.JsonArray |
buildAsJsonArray() |
Returns the patch operations in a JsonArray
|
javax.json.JsonPatchBuilder |
copy(String path,
String from) |
Adds a "copy" JSON Patch operation.
|
javax.json.JsonPatchBuilder |
move(String path,
String from) |
Adds a "move" JSON Patch operation.
|
javax.json.JsonPatchBuilder |
remove(String path) |
Adds a "remove" JSON Patch operation.
|
javax.json.JsonPatchBuilder |
replace(String path,
boolean value) |
Adds a "replace" JSON Patch operation.
|
javax.json.JsonPatchBuilder |
replace(String path,
int value) |
Adds a "replace" JSON Patch operation.
|
javax.json.JsonPatchBuilder |
replace(String path,
String value) |
Adds a "replace" JSON Patch operation.
|
javax.json.JsonPatchBuilder |
replace(String path,
javax.json.JsonValue value) |
Adds a "replace" JSON Patch operation.
|
javax.json.JsonPatchBuilder |
test(String path,
boolean value) |
Adds a "test" JSON Patch operation.
|
javax.json.JsonPatchBuilder |
test(String path,
int value) |
Adds a "test" JSON Patch operation.
|
javax.json.JsonPatchBuilder |
test(String path,
String value) |
Adds a "test" JSON Patch operation.
|
javax.json.JsonPatchBuilder |
test(String path,
javax.json.JsonValue value) |
Adds a "test" JSON Patch operation.
|
public JsonPatchBuilderImpl(javax.json.JsonArray patch)
patch - the JSON Patchpublic JsonPatchBuilderImpl()
public <T extends javax.json.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 operationsjavax.json.JsonException - if the supplied JSON Patch is malformed or if
it contains references to non-existing memberspublic javax.json.JsonPatchBuilder add(String path, javax.json.JsonValue value)
add in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic javax.json.JsonPatchBuilder add(String path, String value)
add in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic javax.json.JsonPatchBuilder add(String path, int value)
add in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic javax.json.JsonPatchBuilder add(String path, boolean value)
add in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic javax.json.JsonPatchBuilder remove(String path)
remove in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationpublic javax.json.JsonPatchBuilder replace(String path, javax.json.JsonValue value)
replace in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic javax.json.JsonPatchBuilder replace(String path, String value)
replace in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic javax.json.JsonPatchBuilder replace(String path, int value)
replace in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic javax.json.JsonPatchBuilder replace(String path, boolean value)
replace in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic javax.json.JsonPatchBuilder move(String path, String from)
move in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationfrom - the "from" member of the operationpublic javax.json.JsonPatchBuilder copy(String path, String from)
copy in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationfrom - the "from" member of the operationpublic javax.json.JsonPatchBuilder test(String path, javax.json.JsonValue value)
test in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic javax.json.JsonPatchBuilder test(String path, String value)
test in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic javax.json.JsonPatchBuilder test(String path, int value)
test in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic javax.json.JsonPatchBuilder test(String path, boolean value)
test in interface javax.json.JsonPatchBuilderpath - the "path" member of the operationvalue - the "value" member of the operationpublic javax.json.JsonArray buildAsJsonArray()
public javax.json.JsonPatch build()
build in interface javax.json.JsonPatchBuilderCopyright © 2018 Oracle. All rights reserved.