Annotation Interface XmlAttribute
@Retention(RUNTIME)
@Target({FIELD,METHOD,RECORD_COMPONENT})
@Documented
public @interface XmlAttribute
XML Attribute Annotation - Maps a field to an XML attribute
XML 属性注解 - 将字段映射到 XML 属性
This annotation specifies how a field should be mapped to an XML attribute.
此注解指定如何将字段映射到 XML 属性。
Features | 主要功能:
- Map fields to XML attributes - 将字段映射到 XML 属性
- Custom attribute name via value() - 通过 value() 自定义属性名
- Required attribute marking - 必需属性标记
Usage Examples | 使用示例:
@XmlRoot("user")
public class User {
@XmlAttribute("id")
private Long id;
@XmlAttribute(required = true)
private String type;
}
Security | 安全性:
- Thread-safe: Yes (annotation is immutable) - 线程安全: 是(注解不可变)
- Null-safe: N/A (annotation type) - 空值安全: 不适用(注解类型)
- Since:
- JDK 25, opencode-base-xml V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
String valueThe attribute name. 属性名称。- Returns:
- the attribute name, defaults to field name | 属性名称,默认为字段名
- Default:
""
-
required
boolean requiredWhether the attribute is required. 属性是否必需。- Returns:
- true if required | 如果必需则返回 true
- Default:
false
-