Package com.pivovarit.function
Interface ThrowingConsumer<T,E extends Exception>
- Type Parameters:
T- the type of the input to the functionE- the type of the thrown checked exception
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents a function that accepts one argument and does not return any value;
Function might throw a checked exception instance.
- Author:
- Grzegorz Piwowarek
-
Method Summary
Modifier and TypeMethodDescriptionvoiddefault ThrowingConsumer<T, E> andThenConsume(ThrowingConsumer<? super T, ? extends E> after) Chains given ThrowingConsumer instancedefault ThrowingFunction<T, Void, E> static <T> Consumer<T> sneaky(ThrowingConsumer<T, ?> consumer) Returns a new BiConsumer instance which rethrows the checked exception using the Sneaky Throws patternuncheck()static <T> Consumer<T> unchecked(ThrowingConsumer<T, ?> consumer)
-
Method Details
-
accept
- Throws:
E
-
unchecked
-
sneaky
Returns a new BiConsumer instance which rethrows the checked exception using the Sneaky Throws pattern- Type Parameters:
T- type of the argument to the consumer- Parameters:
consumer- operation throwing checked exception- Returns:
- BiConsumer instance that rethrows the checked exception using the Sneaky Throws pattern
-
andThenConsume
Chains given ThrowingConsumer instance- Parameters:
after- - consumer that is chained after this instance- Returns:
- chained Consumer instance
-
asFunction
- Returns:
- this consumer instance as a Function instance
-
uncheck
- Returns:
- a Consumer instance which wraps thrown checked exception instance into a RuntimeException
-