File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/main/java/io/eigr/spawn/api/actors Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 55import io .eigr .spawn .api .actors .workflows .Forward ;
66import io .eigr .spawn .api .actors .workflows .Pipe ;
77import io .eigr .spawn .api .actors .workflows .SideEffect ;
8+ import io .eigr .spawn .api .exceptions .SpawnFailureException ;
89
910import java .util .ArrayList ;
1011import java .util .List ;
@@ -105,17 +106,23 @@ public <S extends GeneratedMessageV3> Value state(S state, boolean checkpoint) {
105106 }
106107
107108 public Value flow (Broadcast <?> broadcast ) {
108- this .broadcast = Optional .of (broadcast );
109+ this .broadcast = Optional .ofNullable (broadcast );
109110 return this ;
110111 }
111112
112113 public Value flow (Forward forward ) {
114+ if (this .pipe .isPresent ()) {
115+ throw new SpawnFailureException ("You can only use Forward or Pipe. Never both together." );
116+ }
113117 this .forward = Optional .ofNullable (forward );
114118 return this ;
115119 }
116120
117121 public Value flow (Pipe pipe ) {
118- this .pipe = Optional .of (pipe );
122+ if (this .forward .isPresent ()) {
123+ throw new IllegalArgumentException ("You can only use Pipe or Forward. Never both together." );
124+ }
125+ this .pipe = Optional .ofNullable (pipe );
119126 return this ;
120127 }
121128
@@ -129,7 +136,7 @@ public Value flow(SideEffect<?> effect) {
129136 ef .add (effect );
130137 }
131138
132- this .effects = Optional .of (ef );
139+ this .effects = Optional .ofNullable (ef );
133140 return this ;
134141 }
135142
You can’t perform that action at this time.
0 commit comments