ru.yandex.bolts.function.Function0V Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bolts Show documentation
Show all versions of bolts Show documentation
Collections utilities used in various Yandex projects
The newest version!
package ru.yandex.bolts.function;
@FunctionalInterface
public interface Function0V extends Runnable {
void apply();
@Override
default void run() {
apply();
}
static Function1V applyF() {
return Function0V::apply;
}
static Function0V nop() {
return () -> {};
}
default Function0 asFunction0ReturnNull() {
return () -> {
apply();
return null;
};
}
default Function asFunctionReturnParam() {
return r -> {
apply();
return r;
};
}
@SuppressWarnings({"unchecked"})
static void throw0(Throwable e) throws E {
throw (E) e;
}
static void throwException(Throwable e) {
Function0V.throw0(e);
}
static Function0V throwC(final Function0 th) {
return () -> throwException(th.apply());
}
static Function0V throwC(Throwable th) {
return () -> throwException(th);
}
static Function0V wrap(final Runnable runnable) {
if (runnable instanceof Function0V) return (Function0V) runnable;
else return runnable::run;
}
} //~