aQute.lib.exceptions.BiConsumerWithException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.bndtools.templating.gitrepo Show documentation
Show all versions of org.bndtools.templating.gitrepo Show documentation
org.bndtools.templating.gitrepo
package aQute.lib.exceptions;
import java.util.function.BiConsumer;
/**
* BiConsumer interface that allows exceptions.
*
* @param the type of the first argument
* @param the type of the second argument
*/
@FunctionalInterface
public interface BiConsumerWithException {
void accept(T t, U u) throws Exception;
default BiConsumer orElseThrow() {
return (t, u) -> {
try {
accept(t, u);
} catch (Exception e) {
throw Exceptions.duck(e);
}
};
}
default BiConsumer ignoreException() {
return (t, u) -> {
try {
accept(t, u);
} catch (Exception e) {}
};
}
static BiConsumer asBiConsumer(BiConsumerWithException unchecked) {
return unchecked.orElseThrow();
}
static BiConsumer asBiConsumerIgnoreException(BiConsumerWithException unchecked) {
return unchecked.ignoreException();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy