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

io.swagger.swaggerhub.interfaces.ExceptionThrowingConsumer Maven / Gradle / Ivy

Go to download

A maven plugin for downloading and uploading Swagger/OAS definitions from/to SwaggerHub as part of a build process.

There is a newer version: 1.0.4
Show newest version
package io.swagger.swaggerhub.interfaces;

import java.util.function.Consumer;

/**
 * Consumer used throw an exception from the given function
 * @see https://www.baeldung.com/java-lambda-exceptions
 * @param 
 * @param 
 */
@FunctionalInterface
public interface ExceptionThrowingConsumer {

    void accept(T t) throws E;

    /**
     * Consumer wrapper that catches a thrown exception and wraps that in a Runtime Exception.
     * @param exceptionThrowingConsumer
     * @param 
     * @return
     */
    static  Consumer RuntimeThrowingConsumerWrapper(
            ExceptionThrowingConsumer exceptionThrowingConsumer) {

        return i -> {
            try {
                exceptionThrowingConsumer.accept(i);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy