@ComponentProfile(summary="Generate a JSON patch diff between two documents", tag="service,json,jsonpatch", since="3.9.0") public class GeneratePatchDiffService extends JsonPatchService
JSON Patch defines a JSON document structure for expressing a sequence of operations to apply to a JavaScript Object Notation (JSON) document. This service generates the JSON that expresses the differences between 2 JSON documents as a sequence of operations.
For a given diff-source
of {"a": 0,"b": [1,2]}
and a diff-target
of
{"b": [1,2,0]}
then the patch transformation generated and stored against output
should be [{"op":"move","from":"/a","path":"/b/2"}]
.
Note that zjsonpatch operates on JsonNode objects; this means keeping the both node trees in memory, so behaviour will be size/memory dependent.
In the adapter configuration file this class is aliased as json-patch-generate-diff which is the preferred alternative to the fully qualified classname when building your configuration.
mapper
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
GeneratePatchDiffService() |
Modifier and Type | Method and Description |
---|---|
void |
doService(AdaptrisMessage msg) |
MessageWrapper<java.io.InputStream> |
getDiffSource() |
MessageWrapper<java.io.InputStream> |
getDiffTarget() |
java.util.List<PatchDiffFlag> |
getFlags() |
void |
prepare() |
void |
setDiffSource(MessageWrapper<java.io.InputStream> diffSource)
Specify the JSON document that will be transformed.
|
void |
setDiffTarget(MessageWrapper<java.io.InputStream> diffTarget)
Specify the target JSON document you want the patch to transform to.
|
void |
setFlags(java.util.List<PatchDiffFlag> flags)
Specify any additional flags for the diff operation.
|
GeneratePatchDiffService |
withDiffSource(MessageWrapper<java.io.InputStream> diffSource) |
GeneratePatchDiffService |
withDiffTarget(MessageWrapper<java.io.InputStream> diffTarget) |
GeneratePatchDiffService |
withFlags(java.util.List<PatchDiffFlag> flags) |
GeneratePatchDiffService |
withFlags(PatchDiffFlag... flags) |
closeService, getOutput, initService, output, readAndClose, setOutput, withOutput, writeAndClose
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getLookupName, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setLookupName, setUniqueId, start, stop
public void doService(AdaptrisMessage msg) throws ServiceException
ServiceException
public void prepare() throws CoreException
CoreException
public MessageWrapper<java.io.InputStream> getDiffSource()
public void setDiffSource(MessageWrapper<java.io.InputStream> diffSource)
diffSource
- the sourcepublic GeneratePatchDiffService withDiffSource(MessageWrapper<java.io.InputStream> diffSource)
public MessageWrapper<java.io.InputStream> getDiffTarget()
public void setDiffTarget(MessageWrapper<java.io.InputStream> diffTarget)
diffTarget
- the target JSON documentpublic GeneratePatchDiffService withDiffTarget(MessageWrapper<java.io.InputStream> diffTarget)
public java.util.List<PatchDiffFlag> getFlags()
public void setFlags(java.util.List<PatchDiffFlag> flags)
flags
- the flags.public GeneratePatchDiffService withFlags(java.util.List<PatchDiffFlag> flags)
public GeneratePatchDiffService withFlags(PatchDiffFlag... flags)