Record Class DiffEntry

java.lang.Object
java.lang.Record
cloud.opencode.base.xml.diff.DiffEntry
Record Components:
path - the XPath-like path to the differing element | 差异元素的类 XPath 路径
type - the type of difference | 差异类型
oldValue - the old value (from first document), null if added | 旧值(来自第一个文档),如果是新增则为 null
newValue - the new value (from second document), null if removed | 新值(来自第二个文档),如果是删除则为 null

public record DiffEntry(String path, DiffType type, String oldValue, String newValue) extends Record
Diff Entry - A single difference between two XML documents 差异条目 - 两个 XML 文档之间的单个差异

Represents one specific difference found during XML comparison, including the XPath-like path, the type of change, and old/new values.

表示在 XML 比较期间发现的一个具体差异,包括类 XPath 路径、变更类型和旧值/新值。

Features | 主要功能:

  • Immutable record with path, type, old/new values - 包含路径、类型、旧值/新值的不可变记录
  • XPath-like path format: /root/child[0]/grandchild[1] - 类 XPath 路径格式

Usage Examples | 使用示例:

DiffEntry entry = new DiffEntry("/root/item[0]", DiffType.ADDED, null, "new value");
System.out.println(entry.path());  // "/root/item[0]"
System.out.println(entry.type());  // ADDED

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
  • Null-safe: Allows null for oldValue/newValue - 空值安全: 允许 oldValue/newValue 为 null
Since:
JDK 25, opencode-base-xml V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • DiffEntry

      public DiffEntry(String path, DiffType type, String oldValue, String newValue)
      Compact constructor validates required fields. 紧凑构造器验证必填字段。
  • Method Details

    • 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.
    • path

      public String path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • type

      public DiffType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • oldValue

      public String oldValue()
      Returns the value of the oldValue record component.
      Returns:
      the value of the oldValue record component
    • newValue

      public String newValue()
      Returns the value of the newValue record component.
      Returns:
      the value of the newValue record component