Interface CheckedRunnable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A Runnable which may throw.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CheckedRunnableof(CheckedRunnable methodReference) Creates aCheckedRunnable.voidrun()Performs side-effects.default RunnableReturns an uncheckedRunnablethat will sneaky throw if an exceptions occurs when running the unit of work.
-
Method Details
-
of
Creates aCheckedRunnable.// class Evil { static void sideEffect() { ... } } final CheckedRunnable checkedRunnable = CheckedRunnable.of(Evil::sideEffect); final Runnable runnable = checkedRunnable.unchecked(); // may or may not perform a side-effect while not throwing runnable.run(); // may or may not perform a side-effect while throwing runnable.run();- Parameters:
methodReference- (typically) a method reference, e.g.Type::method- Returns:
- a new
CheckedRunnable - See Also:
-
run
-
unchecked
-