Uses of Interface
dk.cloudcreate.essentials.shared.functional.CheckedConsumer
-
Packages that use CheckedConsumer Package Description dk.cloudcreate.essentials.shared.functional -
-
Uses of CheckedConsumer in dk.cloudcreate.essentials.shared.functional
Methods in dk.cloudcreate.essentials.shared.functional with parameters of type CheckedConsumer Modifier and Type Method Description static <T> Consumer<T>CheckedConsumer. safe(CheckedConsumer<T> runnableThatCanFailWithACheckedException)Wraps aCheckedConsumer(basically a lambda with one argument that doesn't return any result and which throws a CheckedException) by returning a newConsumerinstance
The returnedConsumer.accept(Object)method delegates directly to theaccept(Object)and catches any thrown checkedException's and rethrows them as aCheckedExceptionRethrownException
Unless you provide a context-message (usingsafe(String, CheckedConsumer)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 aConsumerwith the purpose of the calling theConsumer.accept(Object).static <T> Consumer<T>CheckedConsumer. safe(String contextMessage, CheckedConsumer<T> runnableThatCanFailWithACheckedException)Wraps aCheckedConsumer(basically a lambda with one argument that doesn't return any result and which throws a CheckedException) by returning a newConsumerinstance
The returnedConsumer.accept(Object)method delegates directly to theaccept(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 aConsumerwith the purpose of the calling theConsumer.accept(Object).
-