Interface ThrowingDoubleConsumer<X extends Throwable>
-
- Type Parameters:
X- The type of checked exception that can be thrown.
- 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 ThrowingDoubleConsumer<X extends Throwable>
Represents an operation that accepts a singledouble-valued argument and returns no result. This is a checked-exception throwing equivalent ofDoubleConsumer.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaccept(double value)Performs this operation on the given argument.default ThrowingDoubleConsumer<X>andThen(ThrowingDoubleConsumer<? extends X> after)Returns a composedThrowingDoubleConsumerthat performs, in sequence, this operation followed by theafteroperation.static <X extends Throwable>
ThrowingDoubleConsumer<X>checked(DoubleConsumer operation)Returns an operation that performs theoperationoperation to its input.static <X extends Throwable>
ThrowingDoubleConsumer<X>checked(DoubleConsumer operation, Class<X> errorType)Returns an operation that performs theoperationoperation to its input.static <X extends Throwable>
ThrowingDoubleConsumer<X>of(ThrowingDoubleConsumer<X> operation)Factory method for turningThrowingDoubleConsumer-shaped lambdas intoThrowingDoubleConsumers.default <E extends Throwable>
ThrowingDoubleConsumer<E>onErrorAcceptChecked(ThrowingDoubleConsumer<? extends E> fallback)Returns an operation that performs this operation on its input.default DoubleConsumeronErrorAcceptUnchecked(DoubleConsumer fallback)Returns an operation that performs this operation on its input.default DoubleConsumeronErrorDiscard()Returns an operation that performs this operation on its input.default <E extends Throwable>
ThrowingDoubleConsumer<E>onErrorHandleChecked(ThrowingConsumer<? super X,? extends E> errorHandler)Returns an operation that performs this operation on its input.default DoubleConsumeronErrorHandleUnchecked(Consumer<? super X> errorHandler)Returns an operation that performs this operation on its input.default <E extends Throwable>
ThrowingDoubleConsumer<E>onErrorThrowAsChecked(Function<? super X,? extends E> errorMapper)Returns an operation that performs this operation on its input.default <E extends RuntimeException>
DoubleConsumeronErrorThrowAsUnchecked(Function<? super X,? extends E> errorMapper)Returns an operation that performs this operation on its input.default DoubleConsumerunchecked()Returns an operation that performs this operation on its input.static DoubleConsumerunchecked(ThrowingDoubleConsumer<?> operation)Returns an operation that performs theoperationoperation to its input.
-
-
-
Method Detail
-
accept
void accept(double value) throws X extends ThrowablePerforms this operation on the given argument.
-
andThen
default ThrowingDoubleConsumer<X> andThen(ThrowingDoubleConsumer<? extends X> after)
Returns a composedThrowingDoubleConsumerthat 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
ThrowingDoubleConsumerthat performs in sequence this operation followed by theafteroperation. - Throws:
NullPointerException- Ifafterisnull.
-
onErrorThrowAsChecked
default <E extends Throwable> ThrowingDoubleConsumer<E> onErrorThrowAsChecked(Function<? super X,? extends E> errorMapper)
Returns an operation that performs this operation on its input. Any checked exception thrown by this operation is transformed using the given error mapper, and the returned operation throws the transformation result.- Type Parameters:
E- The type of checked exception to transform to.- Parameters:
errorMapper- The function to use to transform any checked exception thrown by this operation.- Returns:
- An operation that transforms any thrown checked exception.
- Throws:
NullPointerException- IferrorMapperisnull.
-
onErrorThrowAsUnchecked
default <E extends RuntimeException> DoubleConsumer onErrorThrowAsUnchecked(Function<? super X,? extends E> errorMapper)
Returns an operation that performs this operation on its input. Any checked exception thrown by this operation is transformed using the given error mapper, and the returned operation throws the transformation result.- Type Parameters:
E- The type of unchecked exception to transform to.- Parameters:
errorMapper- The function to use to transform any checked exception thrown by this operation.- Returns:
- An operation that transforms any thrown checked exception.
- Throws:
NullPointerException- IferrorMapperisnull.
-
onErrorHandleChecked
default <E extends Throwable> ThrowingDoubleConsumer<E> onErrorHandleChecked(ThrowingConsumer<? super X,? extends E> errorHandler)
Returns an operation that performs this operation on its input. Any checked exception thrown by this operation is handled by the given error handler.- Type Parameters:
E- The type of checked exception that can be thrown by the given error handler.- Parameters:
errorHandler- The operation to perform on any checked exception thrown by this operation.- Returns:
- An operation that handles any thrown checked exception.
- Throws:
NullPointerException- IferrorHandlerisnull.
-
onErrorHandleUnchecked
default DoubleConsumer onErrorHandleUnchecked(Consumer<? super X> errorHandler)
Returns an operation that performs this operation on its input. Any checked exception thrown by this operation is handled by the given error handler.- Parameters:
errorHandler- The operation to perform on any checked exception thrown by this operation.- Returns:
- An operation that handles any thrown checked exception.
- Throws:
NullPointerException- IferrorHandlerisnull.
-
onErrorAcceptChecked
default <E extends Throwable> ThrowingDoubleConsumer<E> onErrorAcceptChecked(ThrowingDoubleConsumer<? extends E> fallback)
Returns an operation that performs this operation on its input. If this operation throws any checked exception, it is discarded and the given fallback operation is invoked.- Type Parameters:
E- The type of checked exception that can be thrown by the given fallback operation.- Parameters:
fallback- The operation to invoke if this operation throws any checked exception.- Returns:
- An operation that invokes the
fallbackoperation if this operation throws any checked exception. - Throws:
NullPointerException- Iffallbackisnull.
-
onErrorAcceptUnchecked
default DoubleConsumer onErrorAcceptUnchecked(DoubleConsumer fallback)
Returns an operation that performs this operation on its input. If this operation throws any checked exception, it is discarded and the given fallback operation is invoked.- Parameters:
fallback- The operation to invoke if this operation throws any checked exception.- Returns:
- An operation that invokes the
fallbackoperation if this operation throws any checked exception. - Throws:
NullPointerException- Iffallbackisnull.
-
onErrorDiscard
default DoubleConsumer onErrorDiscard()
Returns an operation that performs this operation on its input. Any checked exception thrown by this operation is discarded.- Returns:
- An operation that discards any thrown checked exception.
-
unchecked
default DoubleConsumer unchecked()
Returns an operation that performs this operation on its input. Any checked exception thrown by this operation is wrapped in anUncheckedExceptionwithout a stack trace.- Returns:
- An operation that wraps any checked exception in an
UncheckedException.
-
of
static <X extends Throwable> ThrowingDoubleConsumer<X> of(ThrowingDoubleConsumer<X> operation)
Factory method for turningThrowingDoubleConsumer-shaped lambdas intoThrowingDoubleConsumers.- Type Parameters:
X- The type of checked exception that can be thrown.- Parameters:
operation- The lambda to return asThrowingDoubleConsumer.- Returns:
- The given lambda as a
ThrowingDoubleConsumer. - Throws:
NullPointerException- Ifoperationisnull.
-
unchecked
static DoubleConsumer unchecked(ThrowingDoubleConsumer<?> operation)
Returns an operation that performs theoperationoperation to its input. Any checked exception thrown by theoperationoperation is wrapped in anUncheckedException.- Parameters:
operation- The operation to perform when the returned operation is performed.- Returns:
- An operation that wraps any checked exception in an
UncheckedException. - Throws:
NullPointerException- Ifoperationisnull.
-
checked
static <X extends Throwable> ThrowingDoubleConsumer<X> checked(DoubleConsumer operation)
Returns an operation that performs theoperationoperation to its input. Any checked exception thrown by theoperationoperation is relayed to the caller. This method allows existingDoubleConsumerinstances to be used whereThrowingDoubleConsumeris expected.- Type Parameters:
X- The type of checked exception that can be thrown.- Parameters:
operation- The operation to perform when the returned operation is performed.- Returns:
- An operation that wraps any checked exception in an
UncheckedException. - Throws:
NullPointerException- Ifoperationisnull.
-
checked
static <X extends Throwable> ThrowingDoubleConsumer<X> checked(DoubleConsumer operation, Class<X> errorType)
Returns an operation that performs theoperationoperation to its input. AnyUncheckedExceptionthrown by theoperationoperation is unwrapped if its cause is an instance oferrorType, otherwise it is relayed to the caller.- Type Parameters:
X- The type of checked exception that can be thrown.- Parameters:
operation- The operation to perform when the returned operation is performed.errorType- The type of checked exception that can be thrown.- Returns:
- An operation that wraps any checked exception in an
UncheckedException. - Throws:
NullPointerException- IfoperationorerrorTypeisnull.
-
-