com.github.andyshao.util.function.ThrowableBiConsumer 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.BiConsumer;
/**
*
*
* Title:
* Descript:
* Copyright: Copryright(c) May 30, 2019
* Encoding: UNIX UTF-8
*
* @author Andy.Shao
*
* @param argument type
* @param artument type
* @see ExceptionableBiConsumer
* @see BiConsumer
* @deprecated repeated
*/
@Deprecated(since = "5.0.0.RELEASE")
public interface ThrowableBiConsumer {
/**
* accept operation
* @param t left type
* @param u right type
* @throws Throwable any error
*/
void accept(T t, U u) throws Throwable;
/**
* to {@link ExceptionableBiConsumer}
* @return {@link ExceptionableBiConsumer}
* @param left type
* @param right type
*/
static Convert, ExceptionableBiConsumer> toExceptionableBiConsumer() {
return input -> {
return new ExceptionableBiConsumer() {
@Override
public void accept(T t, U u) throws Exception {
try {
input.accept(t, u);
} catch (Throwable e) {
throw ThrowableException.convertToException(e);
}
}
};
};
}
/**
* and then
* @param after after operation
* @return {@link ThrowableBiConsumer}
*/
default ThrowableBiConsumer andThen(ThrowableBiConsumer super T, ? super U> after) {
Objects.requireNonNull(after);
return (t, u) -> {
this.accept(t, u);
after.accept(t, u);
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy