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 Summary
ConstructorsConstructorDescriptionDiffResult(List<JsonDiff.Difference> differences, JsonNode source, JsonNode target) Creates an instance of aDiffResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thedifferencesrecord component.final booleanIndicates whether some other object is "equal to" this one.intReturns the number of differences.Returns differences of a specific type.Returns a human-readable summary.booleanReturns whether there are differences.final inthashCode()Returns a hash code value for this object.booleanReturns whether the documents are identical.source()Returns the value of thesourcerecord component.target()Returns the value of thetargetrecord component.toPatch()Converts this diff result to a JSON Patch.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
DiffResult
Creates an instance of aDiffResultrecord class.- Parameters:
differences- the value for thedifferencesrecord componentsource- the value for thesourcerecord componenttarget- the value for thetargetrecord 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
Returns differences of a specific type. 返回特定类型的差异。- Parameters:
type- the difference type - 差异类型- Returns:
- matching differences - 匹配的差异
-
toPatch
Converts this diff result to a JSON Patch. 将此差异结果转换为 JSON Patch。- Returns:
- the JSON Patch - JSON Patch
-
getSummary
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
differences
Returns the value of thedifferencesrecord component.- Returns:
- the value of the
differencesrecord component
-
source
Returns the value of thesourcerecord component.- Returns:
- the value of the
sourcerecord component
-
target
Returns the value of thetargetrecord component.- Returns:
- the value of the
targetrecord component
-