Interface BiConsumerWithException<T,U,E extends Exception>
-
- Type Parameters:
T- the type of the first argument to the operationU- the type of the second argument to the operationE- the type of the potential exception of the operation
- All Superinterfaces:
ExceptionHandlerSupport<BiConsumer<T,U>,BiConsumer<T,U>,BiConsumerWithException<T,U,E>>,NoReturnExceptionHandlerSupport<BiConsumer<T,U>,BiFunction<T,U,CompletionStage<Void>>,BiConsumerWithException<T,U,E>>
- 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 BiConsumerWithException<T,U,E extends Exception> extends NoReturnExceptionHandlerSupport<BiConsumer<T,U>,BiFunction<T,U,CompletionStage<Void>>,BiConsumerWithException<T,U,E>>
Represents an operation that accepts two input arguments and returns no result and may throw exception. Unlike most other functional interfaces,BiConsumerWithExceptionis expected to operate via side-effects.General contract
void accept(T t,U u) throws E- The functional method.- uncheck - Return a
Biconsumer<T,U> - lift - Return a
Biconsumer<T,U> - ignore - Return a
Biconsumer<T,U>
- See Also:
BiConsumer
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaccept(T t, U u)Performs this operation on the given arguments.default BiConsumerWithException<T,U,E>andThen(BiConsumerWithException<? super T,? super U,? extends E> after)Returns a composedBiConsumerWithExceptionthat performs, in sequence, this operation followed by theafteroperation.default <R> BiFunctionWithException<T,U,R,E>asBiFunction()Converts aBiConsumerWithExceptionto aBiFunctionWithExceptionreturningnull.static <T,U,R,E extends Exception>
BiFunctionWithException<T,U,R,E>asBiFunction(BiConsumerWithException<T,U,E> consumer)Converts aBiConsumerWithExceptionto aBiFunctionWithExceptionreturningnull.static <T,U,E extends Exception>
BiConsumerWithException<T,U,E>failing(Supplier<E> exceptionBuilder)Returns aBiConsumerWithExceptionthat always throw exception.default BiConsumer<T,U>ignore()Converts thisBiConsumerWithExceptionto a liftedBiConsumerthat ignore exception.static <T,U,E extends Exception>
BiConsumer<T,U>ignored(BiConsumerWithException<T,U,E> consumer)Converts aBiConsumerWithExceptionto a liftedBiConsumerignoring exception.static <T,U,E extends Exception>
BiConsumer<T,U>lifted(BiConsumerWithException<T,U,E> consumer)Converts aBiConsumerWithExceptionto a liftedBiConsumerignoring exception.default BiFunction<T,U,CompletionStage<Void>>stage()Converts thisBiConsumerWithExceptionto a stagedBiFunctionthat return aCompletionStage.static <T,U,E extends Exception>
BiFunction<T,U,CompletionStage<Void>>staged(BiConsumerWithException<T,U,E> consumer)Converts aBiConsumerWithExceptionto a stagedBiFunction.default BiConsumer<T,U>uncheck()Converts thisBiConsumerWithExceptionto aBiConsumerthat wraps exception intoRuntimeException.static <T,U,E extends Exception>
BiConsumer<T,U>unchecked(BiConsumerWithException<T,U,E> consumer)Converts aBiConsumerWithExceptionto aBiConsumerthat wraps exception toRuntimeException.static <T,U,E extends Exception>
BiConsumer<T,U>unchecked(BiConsumerWithException<T,U,E> consumer, Function<Exception,RuntimeException> exceptionMapper)Converts aBiConsumerWithExceptionto aBiConsumerthat wraps exception toRuntimeExceptionby using the provided mapping function.-
Methods inherited from interface ch.powerunit.extensions.exceptions.ExceptionHandlerSupport
documented, exceptionMapper
-
Methods inherited from interface ch.powerunit.extensions.exceptions.NoReturnExceptionHandlerSupport
lift, notThrowingHandler, throwingHandler
-
-
-
-
Method Detail
-
accept
void accept(T t, U u) throws E extends Exception
Performs this operation on the given arguments.- Parameters:
t- the first input argumentu- the second input argument- Throws:
E- any exceptionE extends Exception- See Also:
BiConsumer.accept(Object,Object)
-
uncheck
default BiConsumer<T,U> uncheck()
Converts thisBiConsumerWithExceptionto aBiConsumerthat wraps exception intoRuntimeException.- Specified by:
uncheckin interfaceExceptionHandlerSupport<T,U,E extends Exception>- Specified by:
uncheckin interfaceNoReturnExceptionHandlerSupport<T,U,E extends Exception>- Returns:
- the unchecked operation
- See Also:
unchecked(BiConsumerWithException),unchecked(BiConsumerWithException, Function),BiConsumer
-
ignore
default BiConsumer<T,U> ignore()
Converts thisBiConsumerWithExceptionto a liftedBiConsumerthat ignore exception.- Specified by:
ignorein interfaceExceptionHandlerSupport<T,U,E extends Exception>- Specified by:
ignorein interfaceNoReturnExceptionHandlerSupport<T,U,E extends Exception>- Returns:
- the operation that ignore error
- See Also:
ignored(BiConsumerWithException),BiConsumer
-
stage
default BiFunction<T,U,CompletionStage<Void>> stage()
Converts thisBiConsumerWithExceptionto a stagedBiFunctionthat return aCompletionStage.
-
andThen
default BiConsumerWithException<T,U,E> andThen(BiConsumerWithException<? super T,? super U,? extends E> after)
Returns a composedBiConsumerWithExceptionthat performs, in sequence, this operation followed by theafteroperation. If performing either operation throws an exception, it is relayed to the caller of the composed operation. If performing this operation throws an exception, theafteroperation will not be performed.- Parameters:
after- the operation to perform after this operation- Returns:
- a composed
BiConsumerWithExceptionthat performs in sequence this operation followed by theafteroperation - Throws:
NullPointerException- ifafteris null- See Also:
BiConsumer.andThen(BiConsumer)
-
failing
static <T,U,E extends Exception> BiConsumerWithException<T,U,E> failing(Supplier<E> exceptionBuilder)
Returns aBiConsumerWithExceptionthat always throw exception.- Type Parameters:
T- the type of the first argument to the operationU- the type of the second argument to the operationE- the type of the potential exception of the operation- Parameters:
exceptionBuilder- the supplier to create the exception- Returns:
- an operation that always throw exception
-
unchecked
static <T,U,E extends Exception> BiConsumer<T,U> unchecked(BiConsumerWithException<T,U,E> consumer)
Converts aBiConsumerWithExceptionto aBiConsumerthat wraps exception toRuntimeException.For example :
BiConsumerWithException<String, String, IOException> consumerThrowingException = ...; BiConsumer<String, String> consumerThrowingRuntimeException = ConsumerWithException.unchecked(consumerThrowingException); myMap.forEach(consumerThrowingRuntimeException);
In case of exception insideconsumerThrowingRuntimeExceptionan instance ofWrappedExceptionwith the original exception as cause will be thrown.- Type Parameters:
T- the type of the first argument to the operationU- the type of the second argument to the operationE- the type of the potential exception of the operation- Parameters:
consumer- to be unchecked- Returns:
- the unchecked exception
- Throws:
NullPointerException- if consumer is null- See Also:
uncheck(),unchecked(BiConsumerWithException, Function)
-
unchecked
static <T,U,E extends Exception> BiConsumer<T,U> unchecked(BiConsumerWithException<T,U,E> consumer, Function<Exception,RuntimeException> exceptionMapper)
Converts aBiConsumerWithExceptionto aBiConsumerthat wraps exception toRuntimeExceptionby using the provided mapping function.For example :
BiConsumerWithException<String, String, IOException> consumerThrowingException = ...; BiConsumer<String, String> consumerThrowingRuntimeException = ConsumerWithException.unchecked( consumerThrowingException, IllegalArgumentException::new); myMap.forEach(consumerThrowingRuntimeException)In case of exception insideconsumerThrowingRuntimeExceptionan instance ofIllegalArgumentExceptionwith the original exception as cause will be thrown.- Type Parameters:
T- the type of the first argument to the operationU- the type of the second argument to the operationE- the type of the potential exception of the operation- Parameters:
consumer- the be uncheckedexceptionMapper- a function to convert the exception to the runtime exception.- Returns:
- the unchecked exception
- Throws:
NullPointerException- if consumer or exceptionMapper is null- See Also:
uncheck(),unchecked(BiConsumerWithException)
-
lifted
static <T,U,E extends Exception> BiConsumer<T,U> lifted(BiConsumerWithException<T,U,E> consumer)
Converts aBiConsumerWithExceptionto a liftedBiConsumerignoring exception.For example :
BiConsumerWithException<String, String, IOException> consumerThrowingException = ...; BiConsumer<String, String> consumerThrowingRuntimeException = ConsumerWithException.lifted(consumerThrowingException); myMap.forEach(consumerThrowingRuntimeException);
In case of exception insideconsumerThrowingRuntimeExceptionthe exception will be ignored.- Type Parameters:
T- the type of the first argument to the operationU- the type of the second argument to the operationE- the type of the potential exception of the operation- Parameters:
consumer- to be lifted- Returns:
- the lifted operation
- Throws:
NullPointerException- if consumer is null- See Also:
NoReturnExceptionHandlerSupport.lift()
-
ignored
static <T,U,E extends Exception> BiConsumer<T,U> ignored(BiConsumerWithException<T,U,E> consumer)
Converts aBiConsumerWithExceptionto a liftedBiConsumerignoring exception.For example :
BiConsumerWithException<String, String, IOException> consumerThrowingException = ...; BiConsumer<String, String> consumerThrowingRuntimeException = ConsumerWithException.ignored(consumerThrowingException); myMap.forEach(consumerThrowingRuntimeException);
In case of exception insideconsumerThrowingRuntimeExceptionthe exception will be ignored.- Type Parameters:
T- the type of the first argument to the operationU- the type of the second argument to the operationE- the type of the potential exception of the operation- Parameters:
consumer- to be lifted- Returns:
- the lifted operation
- Throws:
NullPointerException- if consumer is null- See Also:
ignore()
-
staged
static <T,U,E extends Exception> BiFunction<T,U,CompletionStage<Void>> staged(BiConsumerWithException<T,U,E> consumer)
Converts aBiConsumerWithExceptionto a stagedBiFunction.- Type Parameters:
T- the type of the first argument to the operationU- the type of the second argument to the operationE- the type of the potential exception- Parameters:
consumer- to be staged- Returns:
- the staged operation
- Throws:
NullPointerException- if consumer is null- Since:
- 1.1.0
-
asBiFunction
static <T,U,R,E extends Exception> BiFunctionWithException<T,U,R,E> asBiFunction(BiConsumerWithException<T,U,E> consumer)
Converts aBiConsumerWithExceptionto aBiFunctionWithExceptionreturningnull.- Type Parameters:
T- the type of the first argument to the operationU- the type of the second argument to the operationR- the type of the return value of the functionE- the type of the potential exception of the operation- Parameters:
consumer- to be converter- Returns:
- the function
- Throws:
NullPointerException- if consumer is null
-
asBiFunction
default <R> BiFunctionWithException<T,U,R,E> asBiFunction()
Converts aBiConsumerWithExceptionto aBiFunctionWithExceptionreturningnull.- Type Parameters:
R- the type of the return value of the function- Returns:
- the function
- Since:
- 1.2.0
-
-