Record Class TreeDiffResult<T>
java.lang.Object
java.lang.Record
cloud.opencode.base.tree.diff.TreeDiffResult<T>
- Type Parameters:
T- the node type | 节点类型- Record Components:
added- the added nodes | 新增的节点removed- the removed nodes | 删除的节点modified- the modified nodes | 修改的节点unchanged- the unchanged nodes | 未变化的节点
public record TreeDiffResult<T>(List<T> added, List<T> removed, List<TreeDiffResult.ModifiedNode<T>> modified, List<T> unchanged)
extends Record
Tree Diff Result
树差异结果
Result of comparing two trees.
比较两棵树的结果。
Features | 主要功能:
- Immutable diff result record - 不可变差异结果记录
- Change count statistics - 变化数量统计
- Summary string generation - 摘要字符串生成
Usage Examples | 使用示例:
TreeDiffResult<MyNode> result = TreeDiff.diff(oldRoots, newRoots);
boolean equal = result.isEqual();
int totalChanges = result.getTotalChanges();
String summary = result.getSummary();
Security | 安全性:
- Thread-safe: Yes (immutable record) - 是(不可变记录)
- Null-safe: Yes (null lists default to empty) - 是(null列表默认为空)
- Since:
- JDK 25, opencode-base-tree V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordModified Node 修改的节点 -
Constructor Summary
ConstructorsConstructorDescriptionTreeDiffResult(List<T> added, List<T> removed, List<TreeDiffResult.ModifiedNode<T>> modified, List<T> unchanged) Compact constructor 紧凑构造函数 -
Method Summary
Modifier and TypeMethodDescriptionadded()Returns the value of theaddedrecord component.static <T> TreeDiffResult<T> empty()Create empty result 创建空结果final booleanIndicates whether some other object is "equal to" this one.intGet added count 获取新增数量intGet modified count 获取修改数量intGet removed count 获取删除数量Get summary string 获取摘要字符串intGet total change count 获取总变化数量booleanCheck if has changes 检查是否有变化final inthashCode()Returns a hash code value for this object.booleanisEqual()Check if trees are equal 检查两棵树是否相等modified()Returns the value of themodifiedrecord component.removed()Returns the value of theremovedrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of theunchangedrecord component.
-
Constructor Details
-
TreeDiffResult
-
-
Method Details
-
empty
Create empty result 创建空结果- Type Parameters:
T- the node type | 节点类型- Returns:
- the empty result | 空结果
-
isEqual
public boolean isEqual()Check if trees are equal 检查两棵树是否相等- Returns:
- true if equal | 如果相等返回true
-
hasChanges
public boolean hasChanges()Check if has changes 检查是否有变化- Returns:
- true if has changes | 如果有变化返回true
-
getTotalChanges
public int getTotalChanges()Get total change count 获取总变化数量- Returns:
- the total changes | 总变化数量
-
getAddedCount
public int getAddedCount()Get added count 获取新增数量- Returns:
- the added count | 新增数量
-
getRemovedCount
public int getRemovedCount()Get removed count 获取删除数量- Returns:
- the removed count | 删除数量
-
getModifiedCount
public int getModifiedCount()Get modified count 获取修改数量- Returns:
- the modified count | 修改数量
-
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). -
added
-
removed
-
modified
-
unchanged
-