File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
src/main/java/com/jnape/palatable/lambda/functions/specialized/checked Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
2020- ` Either#diverge ` returns a ` Choice3 `
2121- ` Maybe ` is now a ` CoProduct2 ` of ` Unit ` and ` A `
2222- ` Fn0 ` now additionally implements ` Callable `
23+ - ` CheckedRunnable ` is an ` IO<Unit> `
2324
2425### Added
2526- ` Predicate#predicate ` static factory method
Original file line number Diff line number Diff line change 11package com .jnape .palatable .lambda .functions .specialized .checked ;
22
33import com .jnape .palatable .lambda .adt .Unit ;
4+ import com .jnape .palatable .lambda .functions .IO ;
45
56import static com .jnape .palatable .lambda .adt .Unit .UNIT ;
67import static com .jnape .palatable .lambda .functions .specialized .checked .Runtime .throwChecked ;
1314 * @see CheckedFn1
1415 */
1516@ FunctionalInterface
16- public interface CheckedRunnable <T extends Throwable > extends Runnable {
17+ public interface CheckedRunnable <T extends Throwable > extends Runnable , IO <Unit > {
18+
19+ /**
20+ * A version of {@link Runnable#run()} that can throw checked exceptions.
21+ *
22+ * @throws T any exception that can be thrown by this method
23+ */
24+ void checkedRun () throws T ;
1725
1826 @ Override
1927 default void run () {
@@ -24,12 +32,11 @@ default void run() {
2432 }
2533 }
2634
27- /**
28- * A version of {@link Runnable#run()} that can throw checked exceptions.
29- *
30- * @throws T any exception that can be thrown by this method
31- */
32- void checkedRun () throws T ;
35+ @ Override
36+ default Unit unsafePerformIO () {
37+ run ();
38+ return UNIT ;
39+ }
3340
3441 /**
3542 * Convert this {@link CheckedRunnable} to a {@link CheckedSupplier} that returns {@link Unit}.
You can’t perform that action at this time.
0 commit comments