@FunctionalInterface public interface ThrowingConsumer<T> extends Consumer<T>
| Modifier and Type | Method and Description |
|---|---|
default void |
accept(T argument)
Performs this operation on the given argument.
|
void |
acceptThrowing(T argument)
Performs this operation on the given argument.
|
default Consumer<T> |
fallbackTo(Consumer<T> fallback)
Returns a
Consumer performing the given operation on the argument if this operation throws an exception. |
default Consumer<T> |
fallbackTo(Consumer<T> fallback,
Consumer<Exception> exceptionConsumer)
Returns a
Consumer performing the given operation on the argument if this operation throws an exception. |
default ThrowingConsumer<T> |
orThrow(Class<? extends RuntimeException> exceptionClass)
Returns a
ThrowingConsumer throwing an exception of the given type if this operation throws an exception. |
default ThrowingConsumer<T> |
orThrow(Class<? extends RuntimeException> exceptionClass,
String message)
Returns a
ThrowingConsumer throwing an exception of the given type if this operation throws an exception. |
default ThrowingConsumer<T> |
orTryWith(ThrowingConsumer<? super T> other)
Returns a
ThrowingConsumer performing the given operation on the argument if this operation throws an exception. |
default ThrowingConsumer<T> |
orTryWith(ThrowingConsumer<? super T> other,
Consumer<Exception> exceptionConsumer)
Returns a
ThrowingConsumer performing the given operation on the argument if this operation throws an exception. |
default void accept(T argument)
UncheckedException.void acceptThrowing(T argument) throws Exception
Exceptiondefault Consumer<T> fallbackTo(Consumer<T> fallback)
Consumer performing the given operation on the argument if this operation throws an exception.IllegalArgumentException - if fallback is nulldefault Consumer<T> fallbackTo(Consumer<T> fallback, Consumer<Exception> exceptionConsumer)
Consumer performing the given operation on the argument if this operation throws an exception.IllegalArgumentException - if fallback is nulldefault ThrowingConsumer<T> orThrow(Class<? extends RuntimeException> exceptionClass)
ThrowingConsumer throwing an exception of the given type if this operation throws an exception.
The original exception thrown by this operation is the cause of the thrown exception.
The exception class must have a constructor accepting a single Throwable as an argument.
IllegalArgumentException - if exceptionClass is nulldefault ThrowingConsumer<T> orThrow(Class<? extends RuntimeException> exceptionClass, String message)
ThrowingConsumer throwing an exception of the given type if this operation throws an exception.
The original exception thrown by this operation is the cause of the thrown exception.
The exception class must have a constructor accepting String and Throwable as arguments.
IllegalArgumentException - if exceptionClass is nulldefault ThrowingConsumer<T> orTryWith(ThrowingConsumer<? super T> other)
ThrowingConsumer performing the given operation on the argument if this operation throws an exception.IllegalArgumentException - if other is nulldefault ThrowingConsumer<T> orTryWith(ThrowingConsumer<? super T> other, Consumer<Exception> exceptionConsumer)
ThrowingConsumer performing the given operation on the argument if this operation throws an exception.IllegalArgumentException - if other is null