
com.github.fge.jsonpatch.JsonPatchOperationFactoryBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json-patch Show documentation
Show all versions of json-patch Show documentation
JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7386) implementation in Java
package com.github.fge.jsonpatch;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JacksonUtils;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
import java.io.IOException;
/**
* The JsonPatchOperationFactoryBase implements a few common operations
* for all JsonPatchOperationFactorys.
*/
public abstract class JsonPatchOperationFactoryBase implements JsonPatchOperationFactory
{
private static final MessageBundle BUNDLE
= MessageBundles.getBundle(JsonPatchMessages.class);
public JsonPatchOperation create(JsonNode node)
throws JsonPatchException
{
try {
return JacksonUtils.getReader().withType(getOperationClass()).readValue(node);
} catch (IOException e) {
throw new JsonPatchException(BUNDLE.getMessage("jsonPatch.deserFailed"), e);
}
}
}