Record Class Diff<T>
java.lang.Object
java.lang.Record
cloud.opencode.base.core.bean.Diff<T>
- Type Parameters:
T- the value type | 值类型- Record Components:
fieldName- the property name | 属性名称oldValue- the old value (nullable) | 旧值(可为 null)newValue- the new value (nullable) | 新值(可为 null)changeType- the type of change | 变更类型
public record Diff<T>(String fieldName, T oldValue, T newValue, ChangeType changeType)
extends Record
Diff Record - Represents a single property difference between two objects
差异记录 - 表示两个对象之间单个属性的差异
Captures the field name, old value, new value, and the type of change.
记录字段名称、旧值、新值以及变更类型。
Usage Examples | 使用示例:
Diff<String> diff = new Diff<>("name", "Alice", "Bob", ChangeType.MODIFIED);
String field = diff.fieldName(); // "name"
String oldVal = diff.oldValue(); // "Alice"
String newVal = diff.newValue(); // "Bob"
ChangeType type = diff.changeType(); // MODIFIED
- Since:
- JDK 25, opencode-base-core V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDiff(String fieldName, T oldValue, T newValue, ChangeType changeType) Creates a Diff instance with validation 创建 Diff 实例(带验证) -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thechangeTyperecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefieldNamerecord component.final inthashCode()Returns a hash code value for this object.newValue()Returns the value of thenewValuerecord component.oldValue()Returns the value of theoldValuerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Diff
Creates a Diff instance with validation 创建 Diff 实例(带验证)- Parameters:
fieldName- the property name | 属性名称oldValue- the old value (nullable) | 旧值newValue- the new value (nullable) | 新值changeType- the type of change | 变更类型
-
-
Method Details
-
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). -
fieldName
-
oldValue
-
newValue
-
changeType
Returns the value of thechangeTyperecord component.- Returns:
- the value of the
changeTyperecord component
-