Package io.vavr
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 CheckedRunnable
of
(CheckedRunnable methodReference) Creates aCheckedRunnable
.void
run()
Performs side-effects.default Runnable
Returns an uncheckedRunnable
that 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
Performs side-effects.- Throws:
Throwable
- if an error occurs
-
unchecked
Returns an uncheckedRunnable
that will sneaky throw if an exceptions occurs when running the unit of work.- Returns:
- a new
Runnable
that throws aThrowable
.
-