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

net.yudichev.jiotty.common.lang.Runnables Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version
package net.yudichev.jiotty.common.lang;

import org.slf4j.Logger;

import static com.google.common.base.Preconditions.checkNotNull;

public final class Runnables {
    private Runnables() {
    }

    public static Runnable guarded(Logger logger, String taskDescription, Runnable delegate) {
        checkNotNull(logger);
        checkNotNull(delegate);
        return () -> {
            try {
                delegate.run();
            } catch (Throwable e) {
                logger.error("Failed while {}", taskDescription, e);
            }
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy