Record Class CsvChange

java.lang.Object
java.lang.Record
cloud.opencode.base.csv.diff.CsvChange
Record Components:
type - the type of change | 变更类型
rowIndex - the row index in the original (for REMOVED/MODIFIED) or target (for ADDED) | 原始中的行索引(REMOVED/MODIFIED)或目标中的行索引(ADDED)
oldRow - the old row (null for ADDED) | 旧行(ADDED时为null)
newRow - the new row (null for REMOVED) | 新行(REMOVED时为null)

public record CsvChange(CsvChange.ChangeType type, int rowIndex, CsvRow oldRow, CsvRow newRow) extends Record
CSV Change - Represents a single change between two CSV documents CSV变更 - 表示两个CSV文档之间的单个变更

An immutable record capturing a row-level difference. Used by CSV diff operations to report additions, removals, and modifications.

一个不可变记录,捕获行级差异。被CSV差异操作用于报告添加、删除和修改。

Usage Examples | 使用示例:

CsvChange added = new CsvChange(ChangeType.ADDED, 3, null, newRow);
CsvChange removed = new CsvChange(ChangeType.REMOVED, 1, oldRow, null);
CsvChange modified = new CsvChange(ChangeType.MODIFIED, 2, oldRow, newRow);

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
Since:
JDK 25, opencode-base-csv V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • CsvChange

      public CsvChange(CsvChange.ChangeType type, int rowIndex, CsvRow oldRow, CsvRow newRow)
      Creates an instance of a CsvChange record class.
      Parameters:
      type - the value for the type record component
      rowIndex - the value for the rowIndex record component
      oldRow - the value for the oldRow record component
      newRow - the value for the newRow record component
  • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • type

      public CsvChange.ChangeType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • rowIndex

      public int rowIndex()
      Returns the value of the rowIndex record component.
      Returns:
      the value of the rowIndex record component
    • oldRow

      public CsvRow oldRow()
      Returns the value of the oldRow record component.
      Returns:
      the value of the oldRow record component
    • newRow

      public CsvRow newRow()
      Returns the value of the newRow record component.
      Returns:
      the value of the newRow record component