Record Class DiffLine

java.lang.Object
java.lang.Record
cloud.opencode.base.string.diff.DiffLine

public record DiffLine(DiffLine.Type type, int originalLine, int revisedLine, String content) extends Record
Diff Line - Record representing a single line in a diff result. 差异行 - 表示差异结果中单行的记录。

Features | 主要功能:

  • Diff type (EQUAL, INSERT, DELETE, MODIFY) - 差异类型
  • Line number tracking for original and revised - 原始和修改行号跟踪

Usage Examples | 使用示例:

DiffLine line = new DiffLine(DiffLine.Type.INSERT, -1, 5, "new content");
DiffLine.Type type = line.type(); // INSERT

Security | 安全性:

  • Thread-safe: Yes (record is immutable) - 线程安全: 是(记录不可变)
Since:
JDK 25, opencode-base-string V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DiffLine(DiffLine.Type type, int originalLine, int revisedLine, String content)
    Creates an instance of a DiffLine record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the content record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the originalLine record component.
    int
    Returns the value of the revisedLine record component.
    final String
    Returns a string representation of this record class.
    Returns the value of the type record component.

    Methods inherited from class Object

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

    • DiffLine

      public DiffLine(DiffLine.Type type, int originalLine, int revisedLine, String content)
      Creates an instance of a DiffLine record class.
      Parameters:
      type - the value for the type record component
      originalLine - the value for the originalLine record component
      revisedLine - the value for the revisedLine record component
      content - the value for the content 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 DiffLine.Type type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • originalLine

      public int originalLine()
      Returns the value of the originalLine record component.
      Returns:
      the value of the originalLine record component
    • revisedLine

      public int revisedLine()
      Returns the value of the revisedLine record component.
      Returns:
      the value of the revisedLine record component
    • content

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