List of usage examples for org.springframework.data.rest.webmvc.json.patch Patch getOperations
@Deprecated
public List<PatchOperation> getOperations()
From source file:org.springframework.data.rest.webmvc.json.patch.JsonPatchPatchConverter.java
/** * Renders a {@link Patch} as a {@link JsonNode}. * /* w ww. j a v a 2 s . c om*/ * @param patch the patch * @return a {@link JsonNode} containing JSON Patch. */ public JsonNode convert(Patch patch) { List<PatchOperation> operations = patch.getOperations(); JsonNodeFactory nodeFactory = JsonNodeFactory.instance; ArrayNode patchNode = nodeFactory.arrayNode(); for (PatchOperation operation : operations) { ObjectNode opNode = nodeFactory.objectNode(); opNode.set("op", nodeFactory.textNode(operation.getOp())); opNode.set("path", nodeFactory.textNode(operation.getPath())); if (operation instanceof FromOperation) { FromOperation fromOp = (FromOperation) operation; opNode.set("from", nodeFactory.textNode(fromOp.getFrom())); } Object value = operation.getValue(); if (value != null) { opNode.set("value", MAPPER.valueToTree(value)); } patchNode.add(opNode); } return patchNode; }