forked from functionaljava/functionaljava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathF8Functions.java
More file actions
26 lines (22 loc) · 809 Bytes
/
F8Functions.java
File metadata and controls
26 lines (22 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package fj;
import fj.data.Validation;
/**
* Created by MarkPerry on 6/04/2014.
*/
public class F8Functions {
/**
* Promotes the TryCatch8 to a Validation that returns an Exception on the failure side and its result on the success side.
*
* @param t A TryCatch8 to promote
* @return A Validation with an Exception on the failure side and its result on the success side.
*/
static public <A, B, C, D, E, F, G, H, I> F8<A, B, C, D, E, F, G, H, Validation<Exception, I>> toF8(final TryCatch8<A, B, C, D, E, F, G, H, I> t) {
return (a, b, c, d, e, f, g, h) -> {
try {
return Validation.success(t.f(a, b, c, d, e, f, g, h));
} catch (Exception ex) {
return Validation.fail(ex);
}
};
}
}