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

com.github.andyshao.util.function.ThrowableConsumer Maven / Gradle / Ivy

The newest version!
package com.github.andyshao.util.function;

import com.github.andyshao.lang.Convert;
import com.github.andyshao.util.stream.ThrowableException;

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

/**
 * 
 * 
 * Title:
* Descript:
* Copyright: Copryright(c) May 27, 2019
* Encoding: UNIX UTF-8 * * @author Andy.Shao * * @param argument type * @see ExceptionableConsumer * @see Consumer * @deprecated repeated */ @Deprecated(since = "5.0.0.RELEASE") @FunctionalInterface public interface ThrowableConsumer { /** * accept operation * @param t input * @throws Throwable any error */ void accept(T t) throws Throwable; /** * to {@link ExceptionableConsumer} * @return {@link ExceptionableConsumer} * @param data type */ static Convert, ExceptionableConsumer> toExceptionableConsumer() { return input -> { return new ExceptionableConsumer() { @Override public void accept(T t) throws Exception { try { input.accept(t); } catch (Throwable e) { throw ThrowableException.convertToException(e); } } }; }; } /** * and then * @param after after {@link ThrowableConsumer} * @return {@link ThrowableConsumer} */ default ThrowableConsumer andThen(ThrowableConsumer after) { Objects.requireNonNull(after); return it -> { this.accept(it); after.accept(it); }; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy