Interface PropertyConverter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Property Converter Interface - Custom property conversion strategy
属性转换器接口 - 自定义属性转换策略
Functional interface for custom property conversion during bean copy operations.
函数式接口,用于 Bean 复制操作中的自定义属性转换。
Features | 主要功能:
- Custom conversion logic - 自定义转换逻辑
- Access to source/target types - 访问源/目标类型
- Property name aware - 属性名感知
- Chainable converters (andThen) - 可链式转换器
Usage Examples | 使用示例:
// Custom converter - 自定义转换器
PropertyConverter converter = (value, srcType, tgtType, name) -> {
if ("date".equals(name)) return formatDate(value);
return Convert.convert(value, tgtType);
};
OpenBean.copyProperties(source, target, converter);
// Chain converters - 链式转换器
PropertyConverter chained = converter.andThen(anotherConverter);
Security | 安全性:
- Thread-safe: Depends on implementation - 线程安全: 取决于实现
- Null-safe: Implementation dependent - 空值安全: 取决于实现
- Since:
- JDK 25, opencode-base-core V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault PropertyConverterandThen(PropertyConverter after) Chained converter 链式转换器Converts property value 转换属性值static PropertyConverterDefault converter (uses Convert utility) 默认转换器(使用 Convert 工具)static PropertyConverteridentity()Identity converter that returns the original value 直接返回原值的转换器
-
Method Details
-
convert
Converts property value 转换属性值- Parameters:
sourceValue- source value - 源值sourceType- source type - 源类型targetType- target type - 目标类型propertyName- property name - 属性名- Returns:
- the converted value - 转换后的值
-
defaultConverter
Default converter (uses Convert utility) 默认转换器(使用 Convert 工具) -
identity
Identity converter that returns the original value 直接返回原值的转换器 -
andThen
Chained converter 链式转换器
-