com.g2forge.alexandria.java.function.IThrowConsumer2 Maven / Gradle / Ivy
package com.g2forge.alexandria.java.function;
@FunctionalInterface
public interface IThrowConsumer2 extends IConsumer {
public static IThrowConsumer2 create(IThrowConsumer2 function) {
return function;
}
public void accept(I0 input0, I1 input1) throws T;
public default IThrowConsumer2 sync(Object lock) {
if (lock == null) return this;
return (i0, i1) -> {
synchronized (lock) {
accept(i0, i1);
}
};
}
public default IThrowFunction2 toFunction(O retVal) {
return (i0, i1) -> {
accept(i0, i1);
return retVal;
};
}
public default IConsumer2 wrap(IFunction1 super Throwable, ? extends RuntimeException> wrapper) {
return (i0, i1) -> {
try {
accept(i0, i1);
} catch (Throwable throwable) {
throw wrapper.apply(throwable);
}
};
}
public default IThrowConsumer2 wrap(IRunnable pre, IRunnable post) {
return (i0, i1) -> {
pre.run();
try {
accept(i0, i1);
} finally {
post.run();
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy