Interface LongFunctionWithException<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<LongFunction<R>,LongFunction<Optional<R>>,LongFunctionWithException<R,E>>,ObjectReturnExceptionHandlerSupport<LongFunction<R>,LongFunction<Optional<R>>,LongFunction<CompletionStage<R>>,R,LongFunctionWithException<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 LongFunctionWithException<R,E extends Exception> extends ObjectReturnExceptionHandlerSupport<LongFunction<R>,LongFunction<Optional<R>>,LongFunction<CompletionStage<R>>,R,LongFunctionWithException<R,E>>
Represents a function that accepts a long-valued argument, may throw exception and produces a result. This is thelong-consuming primitive specialization forFunctionWithException.General contract
R apply(long value) throws E- The functional method.- uncheck - Return a
LongFunction<R> - lift - Return a
LongFunction<Optional<R>> - ignore - Return a
LongFunction<R>
- See Also:
LongFunction
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Rapply(long value)Applies this function to the given argument.static <R,E extends Exception>
LongFunctionWithException<R,E>failing(Supplier<E> exceptionBuilder)Returns a function that always throw exception.default LongFunction<R>ignore()Converts thisLongFunctionWithExceptionto a liftedLongFunctionreturningnull(or the value redefined by the methodObjectReturnExceptionHandlerSupport.defaultValue()) in case of exception.static <R,E extends Exception>
LongFunction<R>ignored(LongFunctionWithException<R,E> function)Converts aLongFunctionWithExceptionto a liftedLongFunctionreturningnullin case of exception.static <R,E extends Exception>
LongFunction<R>ignored(LongFunctionWithException<R,E> function, R defaultValue)Converts aLongFunctionWithExceptionto a liftedLongFunctionreturning a default value in case of exception.default LongFunction<Optional<R>>lift()Converts thisLongFunctionWithExceptionto a liftedLongFunctionusingOptionalas return value.static <R,E extends Exception>
LongFunction<Optional<R>>lifted(LongFunctionWithException<R,E> function)Converts aLongFunctionWithExceptionto a liftedFunctionusingOptionalas return value.default LongFunction<CompletionStage<R>>stage()Convert thisLongFunctionWithExceptionto a liftedLongFunctionreturningCompletionStageas return value.static <R,E extends Exception>
LongFunction<CompletionStage<R>>staged(LongFunctionWithException<R,E> function)Convert thisLongFunctionWithExceptionto a liftedLongFunctionreturnCompletionStageas return value.default LongFunction<R>uncheck()Converts thisLongFunctionWithExceptionto aLongFunctionthat wraps exception toRuntimeException.static <R,E extends Exception>
LongFunction<R>unchecked(LongFunctionWithException<R,E> function)Converts aFunctionWithExceptionto aLongFunctionthat wraps toRuntimeException.static <R,E extends Exception>
LongFunction<R>unchecked(LongFunctionWithException<R,E> function, Function<Exception,RuntimeException> exceptionMapper)Converts aLongFunctionWithExceptionto aLongFunctionthat 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.ObjectReturnExceptionHandlerSupport
defaultValue, notThrowingHandler, throwingHandler
-
-
-
-
Method Detail
-
apply
R apply(long 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:
LongFunction.apply(long)
-
uncheck
default LongFunction<R> uncheck()
Converts thisLongFunctionWithExceptionto aLongFunctionthat wraps exception toRuntimeException.- Specified by:
uncheckin interfaceExceptionHandlerSupport<LongFunction<R>,LongFunction<Optional<R>>,LongFunctionWithException<R,E extends Exception>>- Specified by:
uncheckin interfaceObjectReturnExceptionHandlerSupport<LongFunction<R>,LongFunction<Optional<R>>,LongFunction<CompletionStage<R>>,R,LongFunctionWithException<R,E extends Exception>>- Returns:
- the unchecked function
- See Also:
unchecked(LongFunctionWithException),unchecked(LongFunctionWithException, Function)
-
lift
default LongFunction<Optional<R>> lift()
Converts thisLongFunctionWithExceptionto a liftedLongFunctionusingOptionalas return value.- Specified by:
liftin interfaceExceptionHandlerSupport<LongFunction<R>,LongFunction<Optional<R>>,LongFunctionWithException<R,E extends Exception>>- Specified by:
liftin interfaceObjectReturnExceptionHandlerSupport<LongFunction<R>,LongFunction<Optional<R>>,LongFunction<CompletionStage<R>>,R,LongFunctionWithException<R,E extends Exception>>- Returns:
- the lifted function
- See Also:
lifted(LongFunctionWithException)
-
ignore
default LongFunction<R> ignore()
Converts thisLongFunctionWithExceptionto a liftedLongFunctionreturningnull(or the value redefined by the methodObjectReturnExceptionHandlerSupport.defaultValue()) in case of exception.- Specified by:
ignorein interfaceExceptionHandlerSupport<LongFunction<R>,LongFunction<Optional<R>>,LongFunctionWithException<R,E extends Exception>>- Specified by:
ignorein interfaceObjectReturnExceptionHandlerSupport<LongFunction<R>,LongFunction<Optional<R>>,LongFunction<CompletionStage<R>>,R,LongFunctionWithException<R,E extends Exception>>- Returns:
- the function that ignore error
- See Also:
ignored(LongFunctionWithException)
-
stage
default LongFunction<CompletionStage<R>> stage()
Convert thisLongFunctionWithExceptionto a liftedLongFunctionreturningCompletionStageas return value.- Specified by:
stagein interfaceObjectReturnExceptionHandlerSupport<LongFunction<R>,LongFunction<Optional<R>>,LongFunction<CompletionStage<R>>,R,LongFunctionWithException<R,E extends Exception>>- Returns:
- the lifted function
- See Also:
staged(LongFunctionWithException)
-
failing
static <R,E extends Exception> LongFunctionWithException<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> LongFunction<R> unchecked(LongFunctionWithException<R,E> function)
Converts aFunctionWithExceptionto aLongFunctionthat wraps toRuntimeException.- Type Parameters:
R- the type of the output object to 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(LongFunctionWithException, Function)
-
unchecked
static <R,E extends Exception> LongFunction<R> unchecked(LongFunctionWithException<R,E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aLongFunctionWithExceptionto aLongFunctionthat wraps exception 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(LongFunctionWithException)
-
lifted
static <R,E extends Exception> LongFunction<Optional<R>> lifted(LongFunctionWithException<R,E> function)
Converts aLongFunctionWithExceptionto a liftedFunctionusingOptionalas 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> LongFunction<R> ignored(LongFunctionWithException<R,E> function)
Converts aLongFunctionWithExceptionto a liftedLongFunctionreturningnullin 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> LongFunction<R> ignored(LongFunctionWithException<R,E> function, R defaultValue)
Converts aLongFunctionWithExceptionto a liftedLongFunctionreturning 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 value to be returned in case of exception- Returns:
- the lifted function
- Throws:
NullPointerException- if function is null- Since:
- 3.0.0
- See Also:
ignore(),ignored(LongFunctionWithException)
-
staged
static <R,E extends Exception> LongFunction<CompletionStage<R>> staged(LongFunctionWithException<R,E> function)
Convert thisLongFunctionWithExceptionto a liftedLongFunctionreturnCompletionStageas 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()
-
-