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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package com.github.markozajc.functions.exceptionable;
import static com.github.markozajc.functions.exceptionable.Utilities.asUnchecked;
import com.github.markozajc.functions.ObjObjIntFunction;
/**
* Variant of {@link ObjObjIntFunction} capable of throwing a generic
* {@link Throwable}.
*
* @author Marko Zajc
*
* @param <T>
* the type of the first argument to the function
* @param <U>
* the type of the second argument to the function
* @param <R>
* the type of the result of the function
* @param <E>
* {@link Throwable} type
*/
@FunctionalInterface
public interface EObjObjIntFunction<T, U, R, E extends Throwable> extends ObjObjIntFunction<T, U, R> {
@Override
default R apply(T t, U u, int i) {
try {
return applyChecked(t, u, i);
} catch (Throwable e) { // NOSONAR can't catch generic exceptions
throw asUnchecked(e);
}
}
/**
* Same as {@link #apply(Object, Object, int)}, but throws a checked exception.
*
* @param t
* the first function argument
* @param u
* the second function argument
* @param i
* the third ({@code int}) function argument
*
* @return the function result
*
* @throws E
* the defined exception type
*/
R applyChecked(T t, U u, int i) throws E;
}
|