Interface Converter<T>
- Type Parameters:
T- target type - 目标类型
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Type Converter Interface - Core interface for type conversion
类型转换器接口 - 类型转换的核心接口
Functional interface for converting values between types with optional default value support.
用于在类型之间转换值的函数式接口,支持默认值。
Features | 主要功能:
- Convert with default value - 带默认值转换
- Convert without default (returns null on failure) - 无默认值转换
- Functional interface for lambda usage - 支持 Lambda 表达式
Usage Examples | 使用示例:
// Implement converter - 实现转换器
Converter<Integer> intConverter = (value, def) -> {
try { return Integer.parseInt(value.toString()); }
catch (Exception e) { return def; }
};
// Use converter - 使用转换器
Integer result = intConverter.convert("123", 0);
Security | 安全性:
- Thread-safe: Depends on implementation - 线程安全: 取决于实现
- Null-safe: Yes, null returns default value - 空值安全: 是,null返回默认值
- Since:
- JDK 25, opencode-base-core V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
-
Method Details
-
convert
-
convert
-