Skip to content

Commit 1b7faf6

Browse files
committed
Some minor adjusts
1 parent 888c902 commit 1b7faf6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/java/io/eigr/spawn/api/actors/Value.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import io.eigr.spawn.api.actors.workflows.Forward;
66
import io.eigr.spawn.api.actors.workflows.Pipe;
77
import io.eigr.spawn.api.actors.workflows.SideEffect;
8+
import io.eigr.spawn.api.exceptions.SpawnFailureException;
89

910
import java.util.ArrayList;
1011
import 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

0 commit comments

Comments
 (0)