com.github.andyshao.util.function.ThrowableBiFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Gear Show documentation
Show all versions of Gear Show documentation
Enhance and formating the coding of JDK
The newest version!
package com.github.andyshao.util.function;
import com.github.andyshao.lang.Convert;
import com.github.andyshao.util.stream.ThrowableException;
import java.util.Objects;
import java.util.function.BiFunction;
/**
*
*
* Title:
* Descript:
* Copyright: Copryright(c) May 30, 2019
* Encoding: UNIX UTF-8
*
* @author Andy.Shao
*
* @param argument type
* @param argument type
* @param return type
* @see ExceptionableBiFunction
* @see BiFunction
* @deprecated repeated
*/
@Deprecated(since = "5.0.0.RELEASE")
public interface ThrowableBiFunction {
/**
* apply operation
* @param t left type
* @param u right type
* @return ret
* @throws Throwable any error
*/
R apply(T t, U u) throws Throwable;
/**
* to {@link ExceptionableBiFunction}
* @return {@link ExceptionableBiFunction}
* @param left type
* @param right type
* @param return type
*/
static Convert, ExceptionableBiFunction> toExceptionableBiFunction() {
return input -> {
return new ExceptionableBiFunction() {
@Override
public R apply(T t, U u) throws Throwable {
try {
return input.apply(t, u);
} catch (Throwable e) {
throw ThrowableException.convertToException(e);
}
}
};
};
}
/**
* and then
* @param after after {@link ThrowableFunction}
* @return {@link ThrowableFunction}
* @param data type
*/
default ThrowableBiFunction andThen(ThrowableFunction super R, ? extends V> after) {
Objects.requireNonNull(after);
return (T t, U u) -> after.apply(apply(t, u));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy