Class JsonMergePatchImpl

java.lang.Object
org.glassfish.json.JsonMergePatchImpl
All Implemented Interfaces:
JsonMergePatch

public final class JsonMergePatchImpl extends Object implements JsonMergePatch
This class is an implementation of a JSON Merge Patch as specified in RFC 7396.
Since:
1.1
  • Field Details

  • Constructor Details

    • JsonMergePatchImpl

      public JsonMergePatchImpl(JsonValue patch)
  • Method Details

    • apply

      public JsonValue apply(JsonValue target)
      Description copied from interface: JsonMergePatch
      Applies the JSON Merge Patch to the specified target. The target is not modified by the patch.
      Specified by:
      apply in interface JsonMergePatch
      Parameters:
      target - the target to apply the merge patch
      Returns:
      the transformed target after the patch
    • toJsonValue

      public JsonValue toJsonValue()
      Description copied from interface: JsonMergePatch
      Returns the JsonMergePatch as JsonValue.
      Specified by:
      toJsonValue in interface JsonMergePatch
      Returns:
      this JsonMergePatch as JsonValue
    • mergePatch

      private static JsonValue mergePatch(JsonValue target, JsonValue patch)
      Applies the specified patch to the specified target. The target is not modified by the patch.
      Parameters:
      target - the JsonValue to apply the patch operations
      patch - the patch
      Returns:
      the JsonValue as the result of applying the patch operations on the target.
    • diff

      static JsonValue diff(JsonValue source, JsonValue target)
      Generate a JSON Merge Patch from the source and target JsonValue.
      Parameters:
      source - the source
      target - the target
      Returns:
      a JSON Patch which when applied to the source, yields the target