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

com.quorum.tessera.io.IOCallback Maven / Gradle / Ivy

There is a newer version: 0.11.0.30092019161842
Show newest version
package com.quorum.tessera.io;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.UncheckedIOException;

/**
 * Callback and template function to uncheck IO exceptions
 *
 * @param  the function to execute that throws an {@link IOException}
 */
@FunctionalInterface
public interface IOCallback {

    Logger LOGGER = LoggerFactory.getLogger(IOCallback.class);

    T doExecute() throws IOException;

    static  T execute(IOCallback callback) {
        try {
            return callback.doExecute();
        } catch (final IOException ex) {
            LOGGER.debug(null, ex);
            throw new UncheckedIOException(ex);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy