com.github.fge.jsonpatch
Class TestOperation

java.lang.Object
  extended by com.github.fge.jsonpatch.JsonPatchOperation
      extended by com.github.fge.jsonpatch.PathValueOperation
          extended by com.github.fge.jsonpatch.TestOperation
All Implemented Interfaces:
JsonSerializable

public final class TestOperation
extends PathValueOperation

JSON Patch test operation

The two arguments for this operation are the pointer containing the value to test (path) and the value to test equality against (value).

It is an error if no value exists at the given path.

Also note that equality as defined by JSON Patch is exactly the same as it is defined by JSON Schema itself. As such, this operation reuses JsonNumEquals for testing equality.


Field Summary
 
Fields inherited from class com.github.fge.jsonpatch.PathValueOperation
value
 
Fields inherited from class com.github.fge.jsonpatch.JsonPatchOperation
BUNDLE, op, path
 
Constructor Summary
TestOperation(JsonPointer path, JsonNode value)
           
 
Method Summary
 JsonNode apply(JsonNode node)
          Apply this operation to a JSON value
 
Methods inherited from class com.github.fge.jsonpatch.PathValueOperation
serialize, serializeWithType, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestOperation

public TestOperation(JsonPointer path,
                     JsonNode value)
Method Detail

apply

public JsonNode apply(JsonNode node)
               throws JsonPatchException
Description copied from class: JsonPatchOperation
Apply this operation to a JSON value

Specified by:
apply in class JsonPatchOperation
Parameters:
node - the value to patch
Returns:
the patched value
Throws:
JsonPatchException - operation failed to apply to this value