@Override JsonPatchOperation toOperation(final DiffOperation op) { return new AddOperation(op.path, op.value); } },
@Override public JsonNode apply(final JsonNode node) throws JsonPatchException { final JsonNode dupData = from.path(node).deepCopy(); if (dupData.isMissingNode()) throw new JsonPatchException(BUNDLE.getMessage( "jsonPatch.noSuchPath")); return new AddOperation(path, dupData).apply(node); } }
@Override public JsonNode apply(final JsonNode node) throws JsonPatchException { if (path.isEmpty()) return value; /* * Check the parent node: it must exist and be a container (ie an array * or an object) for the add operation to work. */ final JsonNode parentNode = path.parent().path(node); if (parentNode.isMissingNode()) throw new JsonPatchException(BUNDLE.getMessage( "jsonPatch.noSuchParent")); if (!parentNode.isContainerNode()) throw new JsonPatchException(BUNDLE.getMessage( "jsonPatch.parentNotContainer")); return parentNode.isArray() ? addToArray(path, node) : addToObject(path, node); }
@Override public JsonNode apply(final JsonNode node) throws JsonPatchException { if (from.equals(path)) return node.deepCopy(); final JsonNode movedNode = from.path(node); if (movedNode.isMissingNode()) throw new JsonPatchException(BUNDLE.getMessage( "jsonPatch.noSuchPath")); final JsonPatchOperation remove = new RemoveOperation(from); final JsonPatchOperation add = new AddOperation(path, movedNode); return add.apply(remove.apply(node)); } }