Class JsonMergePatchImpl

java.lang.Object
org.eclipse.parsson.JsonMergePatchImpl
All Implemented Interfaces:
jakarta.json.JsonMergePatch

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

    Fields
    Modifier and Type
    Field
    Description
    private final JsonContext
     
    private final jakarta.json.JsonValue
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    JsonMergePatchImpl(jakarta.json.JsonValue patch, JsonContext jsonContext)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    jakarta.json.JsonValue
    apply(jakarta.json.JsonValue target)
     
    (package private) static jakarta.json.JsonValue
    diff(jakarta.json.JsonValue source, jakarta.json.JsonValue target, JsonContext jsonContext)
    Generate a JSON Merge Patch from the source and target JsonValue.
    boolean
    Compares this JsonMergePatchImpl with another object.
    int
    Returns the hash code value for this JsonMergePatchImpl.
    private jakarta.json.JsonValue
    mergePatch(jakarta.json.JsonValue target, jakarta.json.JsonValue patch)
    Applies the specified patch to the specified target.
    jakarta.json.JsonValue
     
    Returns the JSON Patch text

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • patch

      private final jakarta.json.JsonValue patch
    • jsonContext

      private final JsonContext jsonContext
  • Constructor Details

    • JsonMergePatchImpl

      public JsonMergePatchImpl(jakarta.json.JsonValue patch, JsonContext jsonContext)
  • Method Details

    • apply

      public jakarta.json.JsonValue apply(jakarta.json.JsonValue target)
      Specified by:
      apply in interface jakarta.json.JsonMergePatch
    • toJsonValue

      public jakarta.json.JsonValue toJsonValue()
      Specified by:
      toJsonValue in interface jakarta.json.JsonMergePatch
    • mergePatch

      private jakarta.json.JsonValue mergePatch(jakarta.json.JsonValue target, jakarta.json.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 jakarta.json.JsonValue diff(jakarta.json.JsonValue source, jakarta.json.JsonValue target, JsonContext jsonContext)
      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
    • equals

      public boolean equals(Object obj)
      Compares this JsonMergePatchImpl with another object.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare this JsonMergePatchImpl against
      Returns:
      true if the given object is a JsonMergePatchImpl with the same reference tokens as this one, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash code value for this JsonMergePatchImpl.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value for this JsonMergePatchImpl object
    • toString

      public String toString()
      Returns the JSON Patch text
      Overrides:
      toString in class Object
      Returns:
      the JSON Patch text