Record Class DiffResult<T>
java.lang.Object
java.lang.Record
cloud.opencode.base.core.bean.DiffResult<T>
- Type Parameters:
T- the object type | 对象类型- Record Components:
type- the class of the compared objects | 比较对象的类diffs- the list of property diffs | 属性差异列表
Diff Result Record - Contains the complete comparison result between two objects
差异结果记录 - 包含两个对象之间的完整比较结果
Provides convenience methods to filter diffs by change type.
提供按变更类型过滤差异的便捷方法。
Usage Examples | 使用示例:
DiffResult<User> result = ObjectDiff.compare(oldUser, newUser);
boolean changed = result.hasDiffs();
List<Diff<?>> modified = result.getModified();
List<Diff<?>> added = result.getAdded();
List<Diff<?>> removed = result.getRemoved();
- Since:
- JDK 25, opencode-base-core V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDiffResult(Class<T> type, List<Diff<?>> diffs) Creates a DiffResult with validation and defensive copy 创建 DiffResult(带验证和防御性拷贝) -
Method Summary
Modifier and TypeMethodDescriptiondiffs()Returns the value of thediffsrecord component.final booleanIndicates whether some other object is "equal to" this one.getAdded()Returns only ADDED diffs 返回仅 ADDED 类型的差异Returns only MODIFIED diffs 返回仅 MODIFIED 类型的差异Returns only REMOVED diffs 返回仅 REMOVED 类型的差异booleanhasDiffs()Returns true if there are any non-UNCHANGED diffs 是否存在非 UNCHANGED 的差异final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.
-
Constructor Details
-
DiffResult
-
-
Method Details
-
hasDiffs
public boolean hasDiffs()Returns true if there are any non-UNCHANGED diffs 是否存在非 UNCHANGED 的差异- Returns:
- true if any property changed | 如有属性变更返回 true
-
getModified
-
getAdded
-
getRemoved
-
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). -
type
-
diffs
-