Class RecordMapper.Builder<S,T>
java.lang.Object
cloud.opencode.base.reflect.record.RecordMapper.Builder<S,T>
- Type Parameters:
S- the source type | 源类型T- the target type | 目标类型
- Enclosing class:
RecordMapper<S,T>
Builder for RecordMapper
RecordMapper构建器
Configures field mappings, exclusions, converters, and null handling.
配置字段映射、排除、转换器和空值处理。
- Since:
- JDK 25, opencode-base-reflect V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the RecordMapper 构建RecordMapperAdds a custom converter for a target field 为目标字段添加自定义转换器Excludes a field from mapping 从映射中排除字段ignoreNulls(boolean ignoreNulls) Sets whether to ignore null values during mapping 设置映射时是否忽略空值Maps a source field name to a target field name 将源字段名映射到目标字段名
-
Method Details
-
map
Maps a source field name to a target field name 将源字段名映射到目标字段名- Parameters:
sourceField- the source field name | 源字段名targetField- the target field name | 目标字段名- Returns:
- this builder | 此构建器
- Throws:
NullPointerException- if sourceField or targetField is null | 如果字段名为null
-
exclude
Excludes a field from mapping 从映射中排除字段- Parameters:
fieldName- the field name to exclude | 要排除的字段名- Returns:
- this builder | 此构建器
- Throws:
NullPointerException- if fieldName is null | 如果字段名为null
-
convert
Adds a custom converter for a target field 为目标字段添加自定义转换器- Parameters:
targetField- the target field name | 目标字段名converter- the converter function | 转换器函数- Returns:
- this builder | 此构建器
- Throws:
NullPointerException- if targetField or converter is null | 如果参数为null
-
ignoreNulls
Sets whether to ignore null values during mapping 设置映射时是否忽略空值When true, source fields with null values will not be mapped to the target. For Record targets, unmapped fields will receive their type's default value.
当为true时,源字段中的null值不会映射到目标。 对于Record目标,未映射的字段将使用其类型的默认值。
- Parameters:
ignoreNulls- whether to ignore nulls | 是否忽略空值- Returns:
- this builder | 此构建器
-
build
Builds the RecordMapper 构建RecordMapper- Returns:
- the RecordMapper | RecordMapper
-