Package com.pivovarit.function
Interface ThrowingConsumer<T,E extends java.lang.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.
@FunctionalInterface public interface ThrowingConsumer<T,E extends java.lang.Exception>
Represents a function that accepts one argument and does not return any value; Function might throw a checked exception instance.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
accept(T t)
default ThrowingConsumer<T,E>
andThenConsume(ThrowingConsumer<? super T,? extends E> after)
Chains given ThrowingConsumer instancedefault ThrowingFunction<T,java.lang.Void,E>
asFunction()
static <T> java.util.function.Consumer<T>
sneaky(ThrowingConsumer<T,?> consumer)
Returns a new BiConsumer instance which rethrows the checked exception using the Sneaky Throws patterndefault java.util.function.Consumer<T>
uncheck()
static <T> java.util.function.Consumer<T>
unchecked(ThrowingConsumer<T,?> consumer)
-
-
-
Method Detail
-
unchecked
static <T> java.util.function.Consumer<T> unchecked(ThrowingConsumer<T,?> consumer)
-
sneaky
static <T> java.util.function.Consumer<T> sneaky(ThrowingConsumer<T,?> consumer)
Returns a new BiConsumer instance which rethrows the checked exception using the Sneaky Throws pattern- Returns:
- BiConsumer instance that rethrows the checked exception using the Sneaky Throws pattern
-
andThenConsume
default ThrowingConsumer<T,E> andThenConsume(ThrowingConsumer<? super T,? extends E> after)
Chains given ThrowingConsumer instance- Parameters:
after
- - consumer that is chained after this instance- Returns:
- chained Consumer instance
-
asFunction
default ThrowingFunction<T,java.lang.Void,E> asFunction()
- Returns:
- this consumer instance as a Function instance
-
uncheck
default java.util.function.Consumer<T> uncheck()
- Returns:
- a Consumer instance which wraps thrown checked exception instance into a RuntimeException
-
-