-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriple.java
More file actions
35 lines (26 loc) · 810 Bytes
/
Triple.java
File metadata and controls
35 lines (26 loc) · 810 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
27
28
29
30
31
32
33
34
35
package org.lambdaql;
import org.lambdaql.utils.Consumer3;
import org.lambdaql.utils.Function3;
import java.util.List;
public record Triple<T1, T2, T3>(T1 t1, T2 t2, T3 t3) implements Tuple {
public static <T1, T2, T3> Triple<T1, T2, T3> of(T1 t1, T2 t2, T3 t3) {
return new Triple<>(t1, t2, t3);
}
public T1 component1() { return t1; }
public T2 component2() { return t2; }
public T3 component3() { return t3; }
@Override
public List<Object> toList() {
return List.of(t1, t2, t3);
}
@Override
public int arity() {
return 3;
}
public <R> R map(Function3<T1, T2, T3, R> mapper) {
return mapper.apply(t1, t2, t3);
}
public void forEach(Consumer3<T1, T2, T3> action) {
action.accept(t1, t2, t3);
}
}