All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.yandex.bolts.function.Function0V Maven / Gradle / Ivy

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;
    }

} //~




© 2015 - 2024 Weber Informatics LLC | Privacy Policy