@FunctionalInterface public interface CheckedRunnable
Modifier and Type | Method and Description |
---|---|
static CheckedRunnable |
of(CheckedRunnable methodReference)
Creates a
CheckedRunnable . |
void |
run()
Performs side-effects.
|
default Runnable |
unchecked()
Returns an unchecked
Runnable that will sneaky throw if an exceptions occurs when running the unit of work. |
static CheckedRunnable of(CheckedRunnable methodReference)
CheckedRunnable
.
// 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();
methodReference
- (typically) a method reference, e.g. Type::method
CheckedRunnable
CheckedFunction1.of(CheckedFunction1)
Copyright © 2019. All Rights Reserved.