Interface DoubleFunctionWithException<R,E extends Exception>
-
- Type Parameters:
R- the type of the result of the functionE- the type of the potential exception of the function
- All Superinterfaces:
ExceptionHandlerSupport<DoubleFunction<R>,DoubleFunction<Optional<R>>,DoubleFunctionWithException<R,E>>,ObjectReturnExceptionHandlerSupport<DoubleFunction<R>,DoubleFunction<Optional<R>>,DoubleFunction<CompletionStage<R>>,R,DoubleFunctionWithException<R,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 DoubleFunctionWithException<R,E extends Exception> extends ObjectReturnExceptionHandlerSupport<DoubleFunction<R>,DoubleFunction<Optional<R>>,DoubleFunction<CompletionStage<R>>,R,DoubleFunctionWithException<R,E>>
Represents a function that accepts a double-valued argument, may throw exception and produces a result. This is thedouble-consuming primitive specialization forFunctionWithException.General contract
R apply(double value) throws E- The functional method.- uncheck - Return a
DoubleFunction<R> - lift - Return a
DoubleFunction<Optional<R>> - ignore - Return a
DoubleFunction<R>
- See Also:
DoubleFunction
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Rapply(double value)Applies this function to the given argument.static <R,E extends Exception>
DoubleFunctionWithException<R,E>failing(Supplier<E> exceptionBuilder)Returns a function that always throw exception.default DoubleFunction<R>ignore()Converts thisDoubleFunctionWithExceptionto a liftedDoubleFunctionreturningnull(or the value redefined by the methodObjectReturnExceptionHandlerSupport.defaultValue()) in case of exception.static <R,E extends Exception>
DoubleFunction<R>ignored(DoubleFunctionWithException<R,E> function)Converts aDoubleFunctionWithExceptionto a liftedDoubleFunctionreturningnullin case of exception.static <R,E extends Exception>
DoubleFunction<R>ignored(DoubleFunctionWithException<R,E> function, R defaultValue)Converts aDoubleFunctionWithExceptionto a liftedDoubleFunctionreturning a default value in case of exception.default DoubleFunction<Optional<R>>lift()Converts thisDoubleFunctionWithExceptionto a liftedDoubleFunctionusingOptionalas return value.static <R,E extends Exception>
DoubleFunction<Optional<R>>lifted(DoubleFunctionWithException<R,E> function)Converts aDoubleFunctionWithExceptionto a liftedDoubleFunctionusingOptionalas return value.default DoubleFunction<CompletionStage<R>>stage()Convert thisDoubleFunctionWithExceptionto a liftedDoubleFunctionreturningCompletionStageas return value.static <R,E extends Exception>
DoubleFunction<CompletionStage<R>>staged(DoubleFunctionWithException<R,E> function)Convert thisDoubleFunctionWithExceptionto a liftedDoubleFunctionreturnCompletionStageas return value.default DoubleFunction<R>uncheck()Converts thisDoubleFunctionWithExceptionto aDoubleFunctionthat wraps toRuntimeException.static <R,E extends Exception>
DoubleFunction<R>unchecked(DoubleFunctionWithException<R,E> function)Converts aDoubleFunctionWithExceptionto aDoubleFunctionthat wraps toRuntimeException.static <R,E extends Exception>
DoubleFunction<R>unchecked(DoubleFunctionWithException<R,E> function, Function<Exception,RuntimeException> exceptionMapper)Converts aDoubleFunctionWithExceptionto aDoubleFunctionthat wraps 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.ObjectReturnExceptionHandlerSupport
defaultValue, notThrowingHandler, throwingHandler
-
-
-
-
Method Detail
-
apply
R apply(double value) throws E extends Exception
Applies this function to the given argument.- Parameters:
value- the function argument- Returns:
- the function result
- Throws:
E- any exceptionE extends Exception- See Also:
DoubleFunction.apply(double)
-
uncheck
default DoubleFunction<R> uncheck()
Converts thisDoubleFunctionWithExceptionto aDoubleFunctionthat wraps toRuntimeException.- Specified by:
uncheckin interfaceExceptionHandlerSupport<DoubleFunction<R>,DoubleFunction<Optional<R>>,DoubleFunctionWithException<R,E extends Exception>>- Specified by:
uncheckin interfaceObjectReturnExceptionHandlerSupport<DoubleFunction<R>,DoubleFunction<Optional<R>>,DoubleFunction<CompletionStage<R>>,R,DoubleFunctionWithException<R,E extends Exception>>- Returns:
- the unchecked function
- See Also:
unchecked(DoubleFunctionWithException),unchecked(DoubleFunctionWithException, Function)
-
lift
default DoubleFunction<Optional<R>> lift()
Converts thisDoubleFunctionWithExceptionto a liftedDoubleFunctionusingOptionalas return value.- Specified by:
liftin interfaceExceptionHandlerSupport<DoubleFunction<R>,DoubleFunction<Optional<R>>,DoubleFunctionWithException<R,E extends Exception>>- Specified by:
liftin interfaceObjectReturnExceptionHandlerSupport<DoubleFunction<R>,DoubleFunction<Optional<R>>,DoubleFunction<CompletionStage<R>>,R,DoubleFunctionWithException<R,E extends Exception>>- Returns:
- the lifted function
- See Also:
lifted(DoubleFunctionWithException)
-
ignore
default DoubleFunction<R> ignore()
Converts thisDoubleFunctionWithExceptionto a liftedDoubleFunctionreturningnull(or the value redefined by the methodObjectReturnExceptionHandlerSupport.defaultValue()) in case of exception.- Specified by:
ignorein interfaceExceptionHandlerSupport<DoubleFunction<R>,DoubleFunction<Optional<R>>,DoubleFunctionWithException<R,E extends Exception>>- Specified by:
ignorein interfaceObjectReturnExceptionHandlerSupport<DoubleFunction<R>,DoubleFunction<Optional<R>>,DoubleFunction<CompletionStage<R>>,R,DoubleFunctionWithException<R,E extends Exception>>- Returns:
- the function that ignore error
- See Also:
ignored(DoubleFunctionWithException)
-
stage
default DoubleFunction<CompletionStage<R>> stage()
Convert thisDoubleFunctionWithExceptionto a liftedDoubleFunctionreturningCompletionStageas return value.- Specified by:
stagein interfaceObjectReturnExceptionHandlerSupport<DoubleFunction<R>,DoubleFunction<Optional<R>>,DoubleFunction<CompletionStage<R>>,R,DoubleFunctionWithException<R,E extends Exception>>- Returns:
- the lifted function
- See Also:
staged(DoubleFunctionWithException)
-
failing
static <R,E extends Exception> DoubleFunctionWithException<R,E> failing(Supplier<E> exceptionBuilder)
Returns a function that always throw exception.- Type Parameters:
R- the type of the result of the functionE- the type of the exception- Parameters:
exceptionBuilder- the supplier to create the exception- Returns:
- a function that always throw exception
-
unchecked
static <R,E extends Exception> DoubleFunction<R> unchecked(DoubleFunctionWithException<R,E> function)
Converts aDoubleFunctionWithExceptionto aDoubleFunctionthat wraps toRuntimeException.- Type Parameters:
R- the type of the result of the functionE- the type of the potential exception- Parameters:
function- to be unchecked- Returns:
- the unchecked exception
- Throws:
NullPointerException- if function is null- See Also:
uncheck(),unchecked(DoubleFunctionWithException, Function)
-
unchecked
static <R,E extends Exception> DoubleFunction<R> unchecked(DoubleFunctionWithException<R,E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aDoubleFunctionWithExceptionto aDoubleFunctionthat wraps toRuntimeExceptionby using the provided mapping function.- Type Parameters:
R- the type of the result of the functionE- the type of the potential exception- Parameters:
function- the be uncheckedexceptionMapper- a function to convert the exception to the runtime exception.- Returns:
- the unchecked function
- Throws:
NullPointerException- if function or exceptionMapper is null- See Also:
uncheck(),unchecked(DoubleFunctionWithException)
-
lifted
static <R,E extends Exception> DoubleFunction<Optional<R>> lifted(DoubleFunctionWithException<R,E> function)
Converts aDoubleFunctionWithExceptionto a liftedDoubleFunctionusingOptionalas return value.- Type Parameters:
R- the type of the result of the functionE- the type of the potential exception- Parameters:
function- to be lifted- Returns:
- the lifted function
- Throws:
NullPointerException- if function is null- See Also:
lift()
-
ignored
static <R,E extends Exception> DoubleFunction<R> ignored(DoubleFunctionWithException<R,E> function)
Converts aDoubleFunctionWithExceptionto a liftedDoubleFunctionreturningnullin case of exception.- Type Parameters:
R- the type of the result of the functionE- the type of the potential exception- Parameters:
function- to be lifted- Returns:
- the lifted function
- Throws:
NullPointerException- if function is null- See Also:
ignore()
-
ignored
static <R,E extends Exception> DoubleFunction<R> ignored(DoubleFunctionWithException<R,E> function, R defaultValue)
Converts aDoubleFunctionWithExceptionto a liftedDoubleFunctionreturning a default value in case of exception.- Type Parameters:
R- the type of the result of the functionE- the type of the potential exception- Parameters:
function- to be lifteddefaultValue- the default value in case of error.- Returns:
- the lifted function
- Throws:
NullPointerException- if function is null- Since:
- 3.0.0
- See Also:
ignore(),ignored(DoubleFunctionWithException)
-
staged
static <R,E extends Exception> DoubleFunction<CompletionStage<R>> staged(DoubleFunctionWithException<R,E> function)
Convert thisDoubleFunctionWithExceptionto a liftedDoubleFunctionreturnCompletionStageas return value.- Type Parameters:
R- the type of the result of the functionE- the type of the potential exception- Parameters:
function- to be lifted- Returns:
- the lifted function
- Throws:
NullPointerException- if function is null- See Also:
stage()
-
-