Record Class DiffEntry
java.lang.Object
java.lang.Record
cloud.opencode.base.yml.diff.DiffEntry
- Record Components:
type- the type of change | 变更类型path- the dot-notation path where change occurred | 变更发生位置的点号路径oldValue- the previous value (null for ADDED) | 先前的值(ADDED 时为 null)newValue- the new value (null for REMOVED) | 新值(REMOVED 时为 null)
public record DiffEntry(DiffType type, String path, Object oldValue, Object newValue)
extends Record
Diff Entry - Represents a single difference between two YAML documents
差异条目 - 表示两个 YAML 文档之间的单个差异
An immutable record that captures the type of change, the path where it occurred, and the old/new values involved.
一个不可变记录,捕获变更类型、发生位置的路径以及涉及的旧/新值。
Features | 主要功能:
- Immutable record with type, path, old value, new value - 不可变记录:类型、路径、旧值、新值
- Factory methods for creating entries - 创建条目的工厂方法
- Dot-notation paths with array index support - 点号路径表示法,支持数组索引
Usage Examples | 使用示例:
DiffEntry added = DiffEntry.added("server.port", 8080);
DiffEntry removed = DiffEntry.removed("logging.level", "DEBUG");
DiffEntry modified = DiffEntry.modified("app.name", "old", "new");
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Since:
- JDK 25, opencode-base-yml V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DiffEntryCreates an ADDED entry.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static DiffEntryCreates a MODIFIED entry.newValue()Returns the value of thenewValuerecord component.oldValue()Returns the value of theoldValuerecord component.path()Returns the value of thepathrecord component.static DiffEntryCreates a REMOVED entry.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.
-
Constructor Details
-
DiffEntry
Canonical constructor with validation. 带校验的规范构造器。- Parameters:
type- the type of change | 变更类型path- the path | 路径oldValue- the old value | 旧值newValue- the new value | 新值- Throws:
NullPointerException- if type or path is null | 当 type 或 path 为 null 时
-
-
Method Details
-
added
-
removed
-
modified
-
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
-
path
-
oldValue
-
newValue
-