Created
March 7, 2013 23:20
-
-
Save fge/5112786 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Copyright (c) 2013, Francis Galiegue <fgaliegue@gmail.com> | |
| * | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the Lesser GNU General Public License as | |
| * published by the Free Software Foundation, either version 3 of the | |
| * License, or (at your option) any later version. | |
| * | |
| * This program is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| * Lesser GNU General Public License for more details. | |
| * | |
| * You should have received a copy of the GNU General Public License | |
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| */ | |
| package com.github.fge.jsonschema.jsonpatch; | |
| import com.fasterxml.jackson.annotation.JsonCreator; | |
| import com.fasterxml.jackson.annotation.JsonProperty; | |
| import com.fasterxml.jackson.annotation.JsonSubTypes; | |
| import com.fasterxml.jackson.annotation.JsonTypeInfo; | |
| import com.fasterxml.jackson.databind.JsonNode; | |
| import com.github.fge.jsonschema.exceptions.JsonPatchException; | |
| import com.github.fge.jsonschema.jsonpointer.JsonPointer; | |
| import static com.fasterxml.jackson.annotation.JsonSubTypes.*; | |
| import static com.fasterxml.jackson.annotation.JsonTypeInfo.*; | |
| @JsonTypeInfo(use = Id.NAME, include = As.PROPERTY, property = "op") | |
| @JsonSubTypes({ | |
| @Type(name = "test", value = TestOperation.class), | |
| @Type(name = "add", value = AddOperation.class) | |
| }) | |
| public abstract class JsonPatchOperation | |
| { | |
| /* | |
| * Note: no need for a custom deserializer, Jackson will try and find a | |
| * constructor with a single string argument and use it | |
| */ | |
| protected final JsonPointer path; | |
| protected final JsonNode value; | |
| @JsonCreator | |
| protected JsonPatchOperation(@JsonProperty("path") final JsonPointer path, | |
| @JsonProperty("value") final JsonNode value) | |
| { | |
| this.path = path; | |
| this.value = value; | |
| } | |
| public abstract JsonNode apply(final JsonNode source) | |
| throws JsonPatchException; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment