Annotation Interface YmlProperty
YML Property - Binds a field to a YAML property
YML 属性 - 将字段绑定到 YAML 属性
This annotation maps a Java field to a YAML property path.
此注解将 Java 字段映射到 YAML 属性路径。
Features | 主要功能:
- Map fields to specific YAML property paths - 将字段映射到特定 YAML 属性路径
- Default value support for missing properties - 缺失属性的默认值支持
- Required property validation - 必需属性验证
Usage Examples | 使用示例:
public class ServerConfig {
@YmlProperty("server.port")
private int port;
@YmlProperty(value = "server.host", defaultValue = "localhost")
private String host;
}
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:
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionDefault value if property is not found.booleanWhether the property is required.
-
Element Details
-
value
String valueThe property path (e.g., "server.port"). 属性路径(如 "server.port")。- Returns:
- the property path | 属性路径
-
defaultValue
String defaultValueDefault value if property is not found. 如果未找到属性时的默认值。- Returns:
- the default value | 默认值
- Default:
""
-
required
boolean requiredWhether the property is required. 属性是否必需。- Returns:
- true if required | 如果必需则返回 true
- Default:
false
-