Annotation Interface YmlNestedProperty
YAML Nested Property Annotation - Binds Nested Object from YAML
YAML 嵌套属性注解 - 从 YAML 绑定嵌套对象
Marks a field as a nested configuration object that should be bound from a sub-tree of the YAML document.
标记字段为嵌套配置对象,应从 YAML 文档的子树绑定。
Features | 主要功能:
- Bind nested YAML sub-trees to object fields - 将嵌套 YAML 子树绑定到对象字段
- Custom prefix path with dot notation support - 支持点号表示法的自定义前缀路径
Usage Example | 使用示例:
public class AppConfig {
@YmlNestedProperty(prefix = "database")
private DatabaseConfig database;
@YmlNestedProperty(prefix = "cache")
private CacheConfig cache;
}
public class DatabaseConfig {
@YmlProperty("host")
private String host;
@YmlProperty("port")
private int port;
@YmlProperty("name")
private String name;
}
// YAML content:
// database:
// host: localhost
// port: 5432
// name: mydb
// cache:
// enabled: true
// ttl: 3600
AppConfig config = YmlBinder.bind(yaml, AppConfig.class);
Security | 安全性:
- Thread-safe: Yes (annotation is inherently immutable) - 线程安全: 是(注解本身不可变)
- Null-safe: N/A - 空值安全: 不适用
- Since:
- JDK 25, opencode-base-yml V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Optional Element Summary
Optional Elements
-
Element Details
-
prefix
String prefixThe prefix path for nested properties 嵌套属性的前缀路径If empty, uses the field name as the prefix. Supports dot notation for deeply nested structures.
如果为空,使用字段名作为前缀。 支持点表示法用于深层嵌套结构。
- Returns:
- prefix path | 前缀路径
- Default:
""
-