Annotation Interface CsvColumn
CSV Column - Maps a Java field to a CSV column
CSV列 - 将Java字段映射到CSV列
Annotate record components or class fields to specify which CSV column
they correspond to. If neither value() nor index() is set,
the Java field name is used as the header name.
标注记录组件或类字段以指定它们对应的CSV列。如果既未设置 value()
也未设置 index(),则使用Java字段名作为标题名。
Usage Examples | 使用示例:
public record Employee(
@CsvColumn("Name") String name,
@CsvColumn(index = 1) int age,
@CsvColumn(value = "Role", required = true) String role
) {}
- Since:
- JDK 25, opencode-base-csv V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionintThe 0-based column index (-1 = use name matching) 0起始列索引(-1 = 使用名称匹配)booleanWhether this column is required (binding fails if missing) 此列是否为必需(缺少时绑定失败)The CSV header name to bind to (empty = use field name) 要绑定的CSV标题名(空 = 使用字段名)
-
Element Details
-
value
String valueThe CSV header name to bind to (empty = use field name) 要绑定的CSV标题名(空 = 使用字段名)- Returns:
- the header name | 标题名
- Default:
""
-
index
int indexThe 0-based column index (-1 = use name matching) 0起始列索引(-1 = 使用名称匹配)- Returns:
- the column index | 列索引
- Default:
-1
-
required
boolean requiredWhether this column is required (binding fails if missing) 此列是否为必需(缺少时绑定失败)- Returns:
- true if required | 如果必需返回true
- Default:
false
-