Class JsonPatchBuilderImpl
java.lang.Object
org.glassfish.json.JsonPatchBuilderImpl
- All Implemented Interfaces:
JsonPatchBuilder
A builder for constructing a JSON Patch by adding
JSON Patch operations incrementally.
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"}
] - Since:
- 1.1
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates JsonPatchBuilderImpl with empty JSON PatchJsonPatchBuilderImpl(JsonArray patch) Creates a JsonPatchBuilderImpl, starting with the specified JSON Patch -
Method Summary
Modifier and TypeMethodDescriptionAdds an "add" JSON Patch operationAdds an "add" JSON Patch operationAdds an "add" JSON Patch operationAdds an "add" JSON Patch operation.<T extends JsonStructure>
Tapply(T target) A convenience method fornew JsonPatchImpl(build()).apply(target).build()Returns the patch operation in a JsonPatchReturns the patch operations in a JsonArrayAdds a "copy" JSON Patch operation.Adds a "move" JSON Patch operation.Adds a "remove" JSON Patch operation.Adds a "replace" JSON Patch operation.Adds a "replace" JSON Patch operation.Adds a "replace" JSON Patch operation.Adds a "replace" JSON Patch operation.Adds a "test" JSON Patch operation.Adds a "test" JSON Patch operation.Adds a "test" JSON Patch operation.Adds a "test" JSON Patch operation.
-
Field Details
-
builder
-
-
Constructor Details
-
JsonPatchBuilderImpl
Creates a JsonPatchBuilderImpl, starting with the specified JSON Patch- Parameters:
patch- the JSON Patch
-
JsonPatchBuilderImpl
public JsonPatchBuilderImpl()Creates JsonPatchBuilderImpl with empty JSON Patch
-
-
Method Details
-
apply
A convenience method fornew JsonPatchImpl(build()).apply(target). The target is not modified by the patch.- Type Parameters:
T- the target type, must be a subtype ofJsonStructure- Parameters:
target- the target to apply the patch operations- Returns:
- the transformed target after the patch
- Throws:
JsonException- if the supplied JSON Patch is malformed or if it contains references to non-existing members
-
add
Adds an "add" JSON Patch operation.- Specified by:
addin interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationvalue- the "value" member of the operation- Returns:
- this JsonPatchBuilder
-
add
Adds an "add" JSON Patch operation- Specified by:
addin interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationvalue- the "value" member of the operation- Returns:
- this JsonPatchBuilder
-
add
Adds an "add" JSON Patch operation- Specified by:
addin interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationvalue- the "value" member of the operation- Returns:
- this JsonPatchBuilder
-
add
Adds an "add" JSON Patch operation- Specified by:
addin interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationvalue- the "value" member of the operation- Returns:
- this JsonPatchBuilder
-
remove
Adds a "remove" JSON Patch operation.- Specified by:
removein interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operation- Returns:
- this JsonPatchBuilder
-
replace
Adds a "replace" JSON Patch operation.- Specified by:
replacein interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationvalue- the "value" member of the operation- Returns:
- this JsonPatchBuilder
-
replace
Adds a "replace" JSON Patch operation.- Specified by:
replacein interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationvalue- the "value" member of the operation- Returns:
- this JsonPatchBuilder
-
replace
Adds a "replace" JSON Patch operation.- Specified by:
replacein interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationvalue- the "value" member of the operation- Returns:
- this JsonPatchBuilder
-
replace
Adds a "replace" JSON Patch operation.- Specified by:
replacein interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationvalue- the "value" member of the operation- Returns:
- this JsonPatchBuilder
-
move
Adds a "move" JSON Patch operation.- Specified by:
movein interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationfrom- the "from" member of the operation- Returns:
- this JsonPatchBuilder
-
copy
Adds a "copy" JSON Patch operation.- Specified by:
copyin interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationfrom- the "from" member of the operation- Returns:
- this JsonPatchBuilder
-
test
Adds a "test" JSON Patch operation.- Specified by:
testin interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationvalue- the "value" member of the operation- Returns:
- this JsonPatchBuilder
-
test
Adds a "test" JSON Patch operation.- Specified by:
testin interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationvalue- the "value" member of the operation- Returns:
- this JsonPatchBuilder
-
test
Adds a "test" JSON Patch operation.- Specified by:
testin interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationvalue- the "value" member of the operation- Returns:
- this JsonPatchBuilder
-
test
Adds a "test" JSON Patch operation.- Specified by:
testin interfaceJsonPatchBuilder- Parameters:
path- the "path" member of the operationvalue- the "value" member of the operation- Returns:
- this JsonPatchBuilder
-
buildAsJsonArray
Returns the patch operations in a JsonArray- Returns:
- the patch operations in a JsonArray
-
build
Returns the patch operation in a JsonPatch- Specified by:
buildin interfaceJsonPatchBuilder- Returns:
- the patch operation in a JsonPatch
-