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/).
20
20
- ` Either#diverge ` returns a ` Choice3 `
21
21
- ` Maybe ` is now a ` CoProduct2 ` of ` Unit ` and ` A `
22
22
- ` Fn0 ` now additionally implements ` Callable `
23
+ - ` CheckedRunnable ` is an ` IO<Unit> `
23
24
24
25
### Added
25
26
- ` Predicate#predicate ` static factory method
Original file line number Diff line number Diff line change 1
1
package com .jnape .palatable .lambda .functions .specialized .checked ;
2
2
3
3
import com .jnape .palatable .lambda .adt .Unit ;
4
+ import com .jnape .palatable .lambda .functions .IO ;
4
5
5
6
import static com .jnape .palatable .lambda .adt .Unit .UNIT ;
6
7
import static com .jnape .palatable .lambda .functions .specialized .checked .Runtime .throwChecked ;
13
14
* @see CheckedFn1
14
15
*/
15
16
@ 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 ;
17
25
18
26
@ Override
19
27
default void run () {
@@ -24,12 +32,11 @@ default void run() {
24
32
}
25
33
}
26
34
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
+ }
33
40
34
41
/**
35
42
* Convert this {@link CheckedRunnable} to a {@link CheckedSupplier} that returns {@link Unit}.
You can’t perform that action at this time.
0 commit comments