forked from ReactiveDesignPatterns/CodeSamples
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathSequentialExecution.java
More file actions
54 lines (42 loc) · 1.15 KB
/
SequentialExecution.java
File metadata and controls
54 lines (42 loc) · 1.15 KB
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
52
53
54
/*
* Copyright (c) 2018 https://www.reactivedesignpatterns.com/
*
* Copyright (c) 2018 https://rdp.reactiveplatform.xyz/
*
*/
public class SequentialExecution {
public static class ReplyA {}
public static class ReplyB {}
public static class ReplyC {}
public static class Result {
final ReplyA replyA;
final ReplyB replyB;
final ReplyC replyC;
public Result(ReplyA replyA, ReplyB replyB, ReplyC replyC) {
this.replyA = replyA;
this.replyB = replyB;
this.replyC = replyC;
}
}
public static Result aggregate(ReplyA replyA, ReplyB replyB, ReplyC replyC) {
return new Result(replyA, replyB, replyC);
}
public static ReplyA computeA() {
return new ReplyA(); // return from compute
}
public static ReplyB computeB() {
return new ReplyB(); // return from compute
}
public static ReplyC computeC() {
return new ReplyC(); // return from compute
}
public static void main(String[] args) {
// #snip
final ReplyA a = computeA();
final ReplyB b = computeB();
final ReplyC c = computeC();
final Result r = aggregate(a, b, c);
// #snip
System.out.println(r);
}
}