Interface IntFunctionWithException<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<IntFunction<R>,IntFunction<Optional<R>>,IntFunctionWithException<R,E>>,ObjectReturnExceptionHandlerSupport<IntFunction<R>,IntFunction<Optional<R>>,IntFunction<CompletionStage<R>>,R,IntFunctionWithException<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 IntFunctionWithException<R,E extends Exception> extends ObjectReturnExceptionHandlerSupport<IntFunction<R>,IntFunction<Optional<R>>,IntFunction<CompletionStage<R>>,R,IntFunctionWithException<R,E>>
Represents a function that accepts an int-valued argument, may throw exception and produces a result. This is theint-consuming primitive specialization forFunctionWithException.General contract
R apply(int value) throws E- The functional method.- uncheck - Return a
IntFunction<R> - lift - Return a
IntFunction<Optional<R>> - ignore - Return a
IntFunction<R>
- See Also:
IntFunction
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Rapply(int value)Applies this function to the given argument.static <R,E extends Exception>
IntFunctionWithException<R,E>failing(Supplier<E> exceptionBuilder)Returns a function that always throw exception.default IntFunction<R>ignore()Converts thisIntFunctionWithExceptionto a liftedIntFunctionreturningnull(or the value redefined by the methodObjectReturnExceptionHandlerSupport.defaultValue()) in case of exception.static <R,E extends Exception>
IntFunction<R>ignored(IntFunctionWithException<R,E> function)Converts aIntFunctionWithExceptionto a liftedIntFunctionreturningnullin case of exception.static <R,E extends Exception>
IntFunction<R>ignored(IntFunctionWithException<R,E> function, R defaultValue)Converts aIntFunctionWithExceptionto a liftedIntFunctionreturning a default value in case of exception.default IntFunction<Optional<R>>lift()Converts thisIntFunctionWithExceptionto a liftedIntFunctionusingOptionalas return value.static <R,E extends Exception>
IntFunction<Optional<R>>lifted(IntFunctionWithException<R,E> function)Converts aIntFunctionWithExceptionto a liftedIntFunctionusingOptionalas return value.default IntFunction<CompletionStage<R>>stage()Convert thisIntFunctionWithExceptionto a liftedIntFunctionreturningCompletionStageas return value.static <R,E extends Exception>
IntFunction<CompletionStage<R>>staged(IntFunctionWithException<R,E> function)Convert thisIntFunctionWithExceptionto a liftedIntFunctionreturningCompletionStageas return value.default IntFunction<R>uncheck()Converts thisIntFunctionWithExceptionto aIntFunctionthat wraps exception toRuntimeException.static <R,E extends Exception>
IntFunction<R>unchecked(IntFunctionWithException<R,E> function)Converts aIntFunctionWithExceptionto aIntFunctionthat wraps exception toRuntimeException.static <R,E extends Exception>
IntFunction<R>unchecked(IntFunctionWithException<R,E> function, Function<Exception,RuntimeException> exceptionMapper)Converts aIntFunctionWithExceptionto aIntFunctionthat 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(int 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:
IntFunction.apply(int)
-
uncheck
default IntFunction<R> uncheck()
Converts thisIntFunctionWithExceptionto aIntFunctionthat wraps exception toRuntimeException.- Specified by:
uncheckin interfaceExceptionHandlerSupport<IntFunction<R>,IntFunction<Optional<R>>,IntFunctionWithException<R,E extends Exception>>- Specified by:
uncheckin interfaceObjectReturnExceptionHandlerSupport<IntFunction<R>,IntFunction<Optional<R>>,IntFunction<CompletionStage<R>>,R,IntFunctionWithException<R,E extends Exception>>- Returns:
- the unchecked function
- See Also:
unchecked(IntFunctionWithException),unchecked(IntFunctionWithException, Function)
-
lift
default IntFunction<Optional<R>> lift()
Converts thisIntFunctionWithExceptionto a liftedIntFunctionusingOptionalas return value.- Specified by:
liftin interfaceExceptionHandlerSupport<IntFunction<R>,IntFunction<Optional<R>>,IntFunctionWithException<R,E extends Exception>>- Specified by:
liftin interfaceObjectReturnExceptionHandlerSupport<IntFunction<R>,IntFunction<Optional<R>>,IntFunction<CompletionStage<R>>,R,IntFunctionWithException<R,E extends Exception>>- Returns:
- the lifted function
- See Also:
lifted(IntFunctionWithException)
-
ignore
default IntFunction<R> ignore()
Converts thisIntFunctionWithExceptionto a liftedIntFunctionreturningnull(or the value redefined by the methodObjectReturnExceptionHandlerSupport.defaultValue()) in case of exception.- Specified by:
ignorein interfaceExceptionHandlerSupport<IntFunction<R>,IntFunction<Optional<R>>,IntFunctionWithException<R,E extends Exception>>- Specified by:
ignorein interfaceObjectReturnExceptionHandlerSupport<IntFunction<R>,IntFunction<Optional<R>>,IntFunction<CompletionStage<R>>,R,IntFunctionWithException<R,E extends Exception>>- Returns:
- the function that ignore error
- See Also:
ignored(IntFunctionWithException)
-
stage
default IntFunction<CompletionStage<R>> stage()
Convert thisIntFunctionWithExceptionto a liftedIntFunctionreturningCompletionStageas return value.- Specified by:
stagein interfaceObjectReturnExceptionHandlerSupport<IntFunction<R>,IntFunction<Optional<R>>,IntFunction<CompletionStage<R>>,R,IntFunctionWithException<R,E extends Exception>>- Returns:
- the lifted function
- See Also:
staged(IntFunctionWithException)
-
failing
static <R,E extends Exception> IntFunctionWithException<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> IntFunction<R> unchecked(IntFunctionWithException<R,E> function)
Converts aIntFunctionWithExceptionto aIntFunctionthat wraps exception 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(IntFunctionWithException, Function)
-
unchecked
static <R,E extends Exception> IntFunction<R> unchecked(IntFunctionWithException<R,E> function, Function<Exception,RuntimeException> exceptionMapper)
Converts aIntFunctionWithExceptionto aIntFunctionthat 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(IntFunctionWithException)
-
lifted
static <R,E extends Exception> IntFunction<Optional<R>> lifted(IntFunctionWithException<R,E> function)
Converts aIntFunctionWithExceptionto a liftedIntFunctionusingOptionalas 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> IntFunction<R> ignored(IntFunctionWithException<R,E> function)
Converts aIntFunctionWithExceptionto a liftedIntFunctionreturningnullin 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> IntFunction<R> ignored(IntFunctionWithException<R,E> function, R defaultValue)
Converts aIntFunctionWithExceptionto a liftedIntFunctionreturning 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 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(IntFunctionWithException)
-
staged
static <R,E extends Exception> IntFunction<CompletionStage<R>> staged(IntFunctionWithException<R,E> function)
Convert thisIntFunctionWithExceptionto a liftedIntFunctionreturningCompletionStageas 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()
-
-