66import io .eigr .spawn .api .actors .workflows .Pipe ;
77import io .eigr .spawn .api .actors .workflows .SideEffect ;
88
9+ import java .util .ArrayList ;
910import java .util .List ;
1011import java .util .Objects ;
1112import java .util .Optional ;
@@ -14,6 +15,8 @@ public final class Value<S extends GeneratedMessageV3, R extends GeneratedMessag
1415
1516 private S state ;
1617 private R response ;
18+
19+ private boolean checkpoint ;
1720 private Optional <Broadcast <?>> broadcast ;
1821 private Optional <Forward > forward ;
1922 private Optional <Pipe > pipe ;
@@ -24,6 +27,7 @@ public final class Value<S extends GeneratedMessageV3, R extends GeneratedMessag
2427 private Value () {
2528 this .state = null ;
2629 this .response = null ;
30+ this .checkpoint = false ;
2731 this .broadcast = Optional .empty ();
2832 this .forward = Optional .empty ();
2933 this .pipe = Optional .empty ();
@@ -34,20 +38,26 @@ private Value() {
3438 private Value (
3539 R response ,
3640 S state ,
41+ boolean checkpoint ,
3742 Optional <Broadcast <?>> broadcast ,
3843 Optional <Forward > forward ,
3944 Optional <Pipe > pipe ,
4045 Optional <List <SideEffect >> effects ,
4146 ResponseType type ) {
4247 this .response = response ;
4348 this .state = state ;
49+ this .checkpoint = checkpoint ;
4450 this .broadcast = broadcast ;
4551 this .forward = forward ;
4652 this .pipe = pipe ;
4753 this .effects = effects ;
4854 this .type = type ;
4955 }
5056
57+ public static <S , V > Value at () {
58+ return new Value ();
59+ }
60+
5161 public R getResponse () {
5262 return response ;
5363 }
@@ -56,6 +66,10 @@ public S getState() {
5666 return state ;
5767 }
5868
69+ public boolean getCheckpoint () {
70+ return checkpoint ;
71+ }
72+
5973 public Optional <Broadcast <?>> getBroadcast () {
6074 return broadcast ;
6175 }
@@ -76,10 +90,6 @@ public ResponseType getType() {
7690 return type ;
7791 }
7892
79- public static <S , V > Value at () {
80- return new Value ();
81- }
82-
8393 public Value response (R value ) {
8494 this .response = value ;
8595 return this ;
@@ -90,6 +100,12 @@ public Value state(S state) {
90100 return this ;
91101 }
92102
103+ public Value state (S state , boolean checkpoint ) {
104+ this .state = state ;
105+ this .checkpoint = checkpoint ;
106+ return this ;
107+ }
108+
93109 public Value flow (Broadcast broadcast ) {
94110 this .broadcast = Optional .of (broadcast );
95111 return this ;
@@ -106,11 +122,16 @@ public Value flow(Pipe pipe) {
106122 }
107123
108124 public Value flow (SideEffect effect ) {
125+ List <SideEffect > ef ;
109126 if (this .effects .isPresent ()) {
110- List <SideEffect > ef = this .effects .get ();
127+ ef = this .effects .get ();
128+ ef .add (effect );
129+ } else {
130+ ef = new ArrayList <>();
111131 ef .add (effect );
112- this .effects = Optional .of (ef );
113132 }
133+
134+ this .effects = Optional .of (ef );
114135 return this ;
115136 }
116137
@@ -120,11 +141,11 @@ public Value flow(List<SideEffect> effects) {
120141 }
121142
122143 public Value reply () {
123- return new Value (this .response , this .state , this .broadcast , this .forward , this .pipe , this .effects , ResponseType .REPLY );
144+ return new Value (this .response , this .state , this .checkpoint , this . broadcast , this .forward , this .pipe , this .effects , ResponseType .REPLY );
124145 }
125146
126147 public Value noReply () {
127- return new Value (this .response , this .state , this .broadcast , this .forward , this .pipe , this .effects , ResponseType .NO_REPLY );
148+ return new Value (this .response , this .state , this .checkpoint , this . broadcast , this .forward , this .pipe , this .effects , ResponseType .NO_REPLY );
128149 }
129150
130151 public Value empty () {
@@ -135,6 +156,7 @@ public Value empty() {
135156 public String toString () {
136157 final StringBuilder sb = new StringBuilder ("Value{" );
137158 sb .append ("state=" ).append (state );
159+ sb .append ("checkpoint=" ).append (checkpoint );
138160 sb .append (", value=" ).append (response );
139161 sb .append (", broadcast=" ).append (broadcast );
140162 sb .append (", forward=" ).append (forward );
@@ -152,6 +174,7 @@ public boolean equals(Object o) {
152174 Value <?, ?> value = (Value <?, ?>) o ;
153175 return Objects .equals (state , value .state ) &&
154176 Objects .equals (response , value .response ) &&
177+ Objects .equals (checkpoint , value .checkpoint ) &&
155178 Objects .equals (broadcast , value .broadcast ) &&
156179 Objects .equals (forward , value .forward ) &&
157180 Objects .equals (pipe , value .pipe ) &&
@@ -161,7 +184,7 @@ public boolean equals(Object o) {
161184
162185 @ Override
163186 public int hashCode () {
164- return Objects .hash (state , response , broadcast , forward , pipe , effects , type );
187+ return Objects .hash (state , response , checkpoint , broadcast , forward , pipe , effects , type );
165188 }
166189
167190 enum ResponseType {
0 commit comments