Skip to content

Commit ef79720

Browse files
committed
Updated inheritance of interfaces to Java 8 interfaces
1 parent d3af237 commit ef79720

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

core/src/main/java/fj/F0.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
package fj;
22

3+
import java.util.function.Supplier;
4+
35
/**
46
* Created by MarkPerry on 21/01/2015.
57
*/
68
@FunctionalInterface
7-
public interface F0<A> {
9+
public interface F0<A> extends Supplier<A> {
810

911
A f();
1012

13+
default A get() {
14+
return f();
15+
}
16+
1117
}

core/src/main/java/fj/data/IO.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import fj.F;
88
import fj.Unit;
9+
import fj.function.Try0;
910

1011
import java.io.IOException;
1112

@@ -17,10 +18,14 @@
1718
* @param <A> the type of the result produced by the IO
1819
*/
1920
@FunctionalInterface
20-
public interface IO<A> {
21+
public interface IO<A> extends Try0<A, IOException> {
2122

2223
A run() throws IOException;
2324

25+
default A f() throws IOException {
26+
return run();
27+
}
28+
2429
default SafeIO<Validation<IOException, A>> safe() {
2530
return IOFunctions.toSafeValidation(this);
2631
}

core/src/main/java/fj/function/Effect0.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package fj.function;
22

3+
import fj.F0;
4+
35
/**
46
* Created by mperry on 28/08/2014.
57
*/
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
package fj.function;
22

3+
import fj.F;
4+
import fj.Unit;
5+
6+
import java.util.function.Consumer;
7+
8+
import static fj.Unit.unit;
9+
310
/**
411
* Created by mperry on 28/08/2014.
512
*/
6-
public interface Effect1<A> {
13+
public interface Effect1<A> extends Consumer<A> {
714

815
void f(A a);
916

17+
default void accept(A a) {
18+
f(a);
19+
}
20+
21+
default F<A, Unit> toF() {
22+
return a -> {
23+
f(a);
24+
return unit();
25+
};
26+
}
27+
1028
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
package fj.function;
22

3+
import java.util.function.BiConsumer;
4+
35
/**
46
* Created by mperry on 28/08/2014.
57
*/
6-
public interface Effect2<A, B> {
8+
public interface Effect2<A, B> extends BiConsumer<A, B> {
79

810
void f(A a, B b);
911

12+
default void accept(A a, B b) {
13+
f(a, b);
14+
}
15+
1016
}

0 commit comments

Comments
 (0)