
io.github.oliviercailloux.jaris.throwing.TConsumer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jaris Show documentation
Show all versions of jaris Show documentation
Various utilities that complement those found in Guava.
The newest version!
package io.github.oliviercailloux.jaris.throwing;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Generalization of {@link java.util.function.Consumer} that may throw instances of type {@code X},
* not just {@code RuntimeException} instances.
*
* @param the type of the input to the operation
* @param a sort of throwable that this consumer may throw
*/
@FunctionalInterface
public interface TConsumer {
/**
* Performs this operation on the given argument.
*
* @param t the input argument
* @throws X in generally unspecified circumstances
*/
public void accept(T t) throws X;
/**
* Returns a composed {@code Throwing.Consumer} that performs, in sequence, this operation
* followed by the {@code after} operation.
*
* @param after the operation to perform after this operation
* @return a composed {@code Throwing.Consumer} that performs in sequence this operation followed
* by the {@code after} operation
* @see java.util.function.Consumer#andThen(java.util.function.Consumer)
*/
default TConsumer andThen(TConsumer super T, ? extends X> after) {
checkNotNull(after);
return t -> {
accept(t);
after.accept(t);
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy