Uses of Interface
dk.cloudcreate.essentials.shared.functional.CheckedFunction
Packages that use CheckedFunction
-
Uses of CheckedFunction in dk.cloudcreate.essentials.shared.functional
Methods in dk.cloudcreate.essentials.shared.functional with parameters of type CheckedFunctionModifier and TypeMethodDescriptionstatic <T,R> Function<T, R> CheckedFunction.safe(CheckedFunction<T, R> functionThatCanFailWithACheckedException) Wraps aCheckedFunction(basically a lambda with one argument that returns a result and which throws a CheckedException) by returning a newFunctioninstance
The returnedFunction.apply(Object)method delegates directly to theapply(Object)and catches any thrown checkedException's and rethrows them as aCheckedExceptionRethrownException
Unless you provide a context-message (usingsafe(String, CheckedFunction)then any caught checkedException's message also becomes theCheckedExceptionRethrownException's message.
AnyRuntimeException's thrown aren't caught and the calling code will receive the originalRuntimeExceptionthrown.
Usage example:
Let's say we have a method calledsomeOperationthat cannot change, but which accepts aFunctionwith the purpose of the calling theFunction.apply(Object).static <T,R> Function<T, R> CheckedFunction.safe(String contextMessage, CheckedFunction<T, R> functionThatCanFailWithACheckedException) Wraps aCheckedFunction(basically a lambda with one argument that returns a result and which throws a CheckedException) by returning a newFunctioninstance
The returnedFunction.apply(Object)method delegates directly to theapply(Object)and catches any thrown checkedException's and rethrows them as aCheckedExceptionRethrownException
AnyRuntimeException's thrown aren't caught and the calling code will receive the originalRuntimeExceptionthrown.
Usage example:
Let's say we have a method calledsomeOperationthat cannot change, but which accepts aFunctionwith the purpose of the calling theFunction.apply(Object).