Record Class JsonDiff.DiffResult

java.lang.Object
java.lang.Record
cloud.opencode.base.json.diff.JsonDiff.DiffResult
Enclosing class:
JsonDiff

public static record JsonDiff.DiffResult(List<JsonDiff.Difference> differences, JsonNode source, JsonNode target) extends Record
Result of comparing two JSON documents. 比较两个 JSON 文档的结果。
Since:
JDK 25, opencode-base-json V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • DiffResult

      public DiffResult(List<JsonDiff.Difference> differences, JsonNode source, JsonNode target)
      Creates an instance of a DiffResult record class.
      Parameters:
      differences - the value for the differences record component
      source - the value for the source record component
      target - the value for the target record component
  • Method Details

    • isIdentical

      public boolean isIdentical()
      Returns whether the documents are identical. 返回文档是否相同。
      Returns:
      true if identical - 如果相同则返回 true
    • hasDifferences

      public boolean hasDifferences()
      Returns whether there are differences. 返回是否有差异。
      Returns:
      true if different - 如果不同则返回 true
    • getDifferenceCount

      public int getDifferenceCount()
      Returns the number of differences. 返回差异数量。
      Returns:
      the difference count - 差异数量
    • getDifferencesByType

      public List<JsonDiff.Difference> getDifferencesByType(JsonDiff.DiffType type)
      Returns differences of a specific type. 返回特定类型的差异。
      Parameters:
      type - the difference type - 差异类型
      Returns:
      matching differences - 匹配的差异
    • toPatch

      public JsonPatch toPatch()
      Converts this diff result to a JSON Patch. 将此差异结果转换为 JSON Patch。
      Returns:
      the JSON Patch - JSON Patch
    • getSummary

      public String getSummary()
      Returns a human-readable summary. 返回人类可读的摘要。
      Returns:
      the summary - 摘要
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • differences

      public List<JsonDiff.Difference> differences()
      Returns the value of the differences record component.
      Returns:
      the value of the differences record component
    • source

      public JsonNode source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component
    • target

      public JsonNode target()
      Returns the value of the target record component.
      Returns:
      the value of the target record component