Interface CheckedBiFunction<T,U,R>
- Type Parameters:
T- first input type - 第一个输入类型U- second input type - 第二个输入类型R- return type - 返回值类型
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
CheckedBiFunction - BiFunction that can throw checked exceptions
CheckedBiFunction - 可抛出受检异常的双参函数
Extends the concept of JDK BiFunction to allow throwing checked exceptions.
扩展 JDK BiFunction 的概念,支持抛出受检异常。
Features | 主要功能:
- Throw checked exceptions in lambda - 在 lambda 中抛出受检异常
- Convert to standard BiFunction (unchecked) - 转换为标准 BiFunction
- Silent execution with defaults - 静默执行并返回默认值
- Composition support - 支持函数组合
Usage Examples | 使用示例:
CheckedBiFunction<Path, Charset, String> readFile =
(path, charset) -> Files.readString(path, charset);
BiFunction<Path, Charset, String> wrapped = readFile.unchecked();
String content = readFile.applyOrDefault(path, charset, "fallback");
Security | 安全性:
- Thread-safe: Yes (stateless) - 线程安全: 是 (无状态)
- Null-safe: No - 空值安全: 否
- Since:
- JDK 25, opencode-base-functional V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault <V> CheckedBiFunction<T, U, V> andThen(CheckedFunction<? super R, ? extends V> after) Compose with another function (execute this, then after) 与另一个函数组合(先执行本函数,再执行 after)Apply function to arguments, may throw checked exception 应用函数到参数,可能抛出受检异常default RapplyOrDefault(T t, U u, R defaultValue) Apply silently, returning default value on exception 静默应用,异常时返回默认值default RapplyQuietly(T t, U u) Apply silently, returning null on exception 静默应用,异常时返回 nullstatic <T,U, R> CheckedBiFunction <T, U, R> of(BiFunction<T, U, R> function) Wrap a standard BiFunction as CheckedBiFunction 将标准 BiFunction 包装为 CheckedBiFunctiondefault BiFunction<T, U, R> Convert to standard BiFunction, wrapping checked exceptions 转换为标准 BiFunction,包装受检异常
-
Method Details
-
apply
-
unchecked
Convert to standard BiFunction, wrapping checked exceptions 转换为标准 BiFunction,包装受检异常- Returns:
- BiFunction that wraps checked exceptions - 包装受检异常的 BiFunction
-
applyQuietly
-
applyOrDefault
-
andThen
Compose with another function (execute this, then after) 与另一个函数组合(先执行本函数,再执行 after)- Type Parameters:
V- result type of after function - after 函数的结果类型- Parameters:
after- function to apply after this - 在本函数之后应用的函数- Returns:
- composed function - 组合后的函数
-
of
Wrap a standard BiFunction as CheckedBiFunction 将标准 BiFunction 包装为 CheckedBiFunction- Type Parameters:
T- first input type - 第一个输入类型U- second input type - 第二个输入类型R- return type - 返回值类型- Parameters:
function- standard BiFunction - 标准 BiFunction- Returns:
- CheckedBiFunction wrapper - CheckedBiFunction 包装器
-