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

co.pragmati.function.throwing.ThrowingConsumer Maven / Gradle / Ivy

The newest version!
package co.pragmati.function.throwing;

import java.util.Objects;
import java.util.function.Consumer;

/**
 * Consumer that throws exceptions
 * @param 
 * @param 
 *
 * @author jmbataller
 */
@FunctionalInterface
interface ThrowingConsumer {

    /**
     * Performs operation on the given argument
     *
     * @param t
     * @throws E
     */
    void accept(T t) throws E;

    default ThrowingConsumer andThen(ThrowingConsumer after) {
        Objects.requireNonNull(after);
        return (T t) -> {
            accept(t);
            after.accept(t);
        };
    }

    default ThrowingConsumer andThen(Consumer after) throws E {
        Objects.requireNonNull(after);
        return (T t) -> {
            accept(t);
            after.accept(t);
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy