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

com.gitee.feizns.dynamic.function.ThrowableConsumer Maven / Gradle / Ivy

There is a newer version: 6.1-RELEASE
Show newest version
package com.gitee.feizns.dynamic.function;

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

/**
 * {@link Consumer}
 * @author feizns
 * @since 2024/12/2
 */
@FunctionalInterface
public interface ThrowableConsumer {

    /**
     * Performs this operation on the given argument.
     *
     * @param t the input argument
     */
    void accept(T t) throws Throwable;

    /**
     * Returns a composed {@code Consumer} that performs, in sequence, this
     * operation followed by the {@code after} operation. If performing either
     * operation throws an exception, it is relayed to the caller of the
     * composed operation.  If performing this operation throws an exception,
     * the {@code after} operation will not be performed.
     *
     * @param after the operation to perform after this operation
     * @return a composed {@code Consumer} that performs in sequence this
     * operation followed by the {@code after} operation
     */
    default ThrowableConsumer andThen(ThrowableConsumer after) {
        Objects.requireNonNull(after);
        return (T t) -> { accept(t); after.accept(t); };
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy