Record Class DiffResult
java.lang.Object
java.lang.Record
cloud.opencode.base.string.diff.DiffResult
public record DiffResult(List<DiffLine> lines, int additions, int deletions, int modifications)
extends Record
Diff Result - Record holding the result of a string diff operation.
差异结果 - 持有字符串差异操作结果的记录。
Features | 主要功能:
- Unified diff output - 统一差异输出
- HTML diff output - HTML差异输出
- Addition/deletion/modification counts - 增/删/改计数
Usage Examples | 使用示例:
DiffResult result = OpenDiff.diff("hello", "world");
boolean changed = result.hasDiff();
String unified = result.toUnifiedDiff();
String html = result.toHtml();
Security | 安全性:
- Thread-safe: Yes (record is immutable) - 线程安全: 是(记录不可变)
- Since:
- JDK 25, opencode-base-string V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDiffResult(List<DiffLine> lines, int additions, int deletions, int modifications) Creates an instance of aDiffResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of theadditionsrecord component.intReturns the value of thedeletionsrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanhasDiff()final inthashCode()Returns a hash code value for this object.lines()Returns the value of thelinesrecord component.intReturns the value of themodificationsrecord component.toHtml()final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
DiffResult
Creates an instance of aDiffResultrecord class.- Parameters:
lines- the value for thelinesrecord componentadditions- the value for theadditionsrecord componentdeletions- the value for thedeletionsrecord componentmodifications- the value for themodificationsrecord component
-
-
Method Details
-
hasDiff
public boolean hasDiff() -
toUnifiedDiff
-
toHtml
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
lines
-
additions
public int additions()Returns the value of theadditionsrecord component.- Returns:
- the value of the
additionsrecord component
-
deletions
public int deletions()Returns the value of thedeletionsrecord component.- Returns:
- the value of the
deletionsrecord component
-
modifications
public int modifications()Returns the value of themodificationsrecord component.- Returns:
- the value of the
modificationsrecord component
-