Class YmlBinder
java.lang.Object
cloud.opencode.base.yml.bind.YmlBinder
YML Binder - Binds YAML data to Java objects
YML 绑定器 - 将 YAML 数据绑定到 Java 对象
This class provides data binding between YAML documents and Java objects.
此类提供 YAML 文档和 Java 对象之间的数据绑定。
Features | 主要功能:
- Bind YAML documents to Java beans and records - 将 YAML 文档绑定到 Java Bean 和 Record
- Path-based binding with prefix support - 基于路径的前缀绑定
- Annotation-driven field mapping (@YmlProperty, @YmlAlias, @YmlIgnore) - 注解驱动的字段映射
- Bidirectional: object to Map and back - 双向转换:对象到 Map 及反向
Usage Examples | 使用示例:
// Bind to class
ServerConfig config = YmlBinder.bind(document, ServerConfig.class);
// Bind with prefix
ServerConfig config = YmlBinder.bind(document, "server", ServerConfig.class);
// Convert object to map
Map<String, Object> map = YmlBinder.toMap(config);
Security | 安全性:
- Thread-safe: Yes (stateless utility class) - 线程安全: 是(无状态工具类)
- Null-safe: Yes (returns null for null input) - 空值安全: 是(空输入返回 null)
- Since:
- JDK 25, opencode-base-yml V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Tbind(YmlDocument document, Class<T> type) Binds YAML data to a Java object.static <T> Tbind(YmlDocument document, String path, Class<T> type) Binds YAML data at a path to a Java object.static <T> TBinds Map data to a Java object.Converts an object to a Map.
-
Method Details
-
bind
Binds YAML data to a Java object. 将 YAML 数据绑定到 Java 对象。- Type Parameters:
T- the type parameter | 类型参数- Parameters:
document- the YAML document | YAML 文档type- the target type | 目标类型- Returns:
- the bound object | 绑定的对象
-
bind
Binds YAML data at a path to a Java object. 将指定路径的 YAML 数据绑定到 Java 对象。- Type Parameters:
T- the type parameter | 类型参数- Parameters:
document- the YAML document | YAML 文档path- the path prefix | 路径前缀type- the target type | 目标类型- Returns:
- the bound object | 绑定的对象
-
bind
-
toMap
-