11package io .iworkflow .core ;
22
33import io .iworkflow .gen .models .WorkflowConditionalCloseType ;
4+ import io .iworkflow .gen .models .WorkflowStateOptions ;
45import org .immutables .value .Value ;
56
67import java .util .ArrayList ;
@@ -145,54 +146,79 @@ public static StateDecision forceCompleteIfSignalChannelEmptyOrElse(final Object
145146 .build ();
146147 }
147148
148- public static StateDecision singleNextState (final Class <? extends WorkflowState > stateClass ) {
149- return singleNextState (stateClass .getSimpleName ());
149+ /**
150+ *
151+ * @param stateClass required
152+ * @param stateInput optional, can be null
153+ * @param stateOptionsOverride optional, can be null. It is used to override the defined one in the State class
154+ * @return state decision
155+ */
156+ public static StateDecision singleNextState (final Class <? extends WorkflowState > stateClass , final Object stateInput , final WorkflowStateOptions stateOptionsOverride ) {
157+ return singleNextState (stateClass .getSimpleName (), stateInput , stateOptionsOverride );
150158 }
151159
152160 /**
153- * use the other one with WorkflowState class param if the StateId is provided by default, to make your code cleaner
154161 *
155- * @param stateId stateId
162+ * @param stateClass required
163+ * @param stateInput optional, can be null
156164 * @return state decision
157165 */
158- public static StateDecision singleNextState (final String stateId ) {
159- return ImmutableStateDecision .builder ().nextStates (Arrays .asList (
160- StateMovement .create (stateId )
161- )).build ();
166+ public static StateDecision singleNextState (final Class <? extends WorkflowState > stateClass , final Object stateInput ) {
167+ return singleNextState (stateClass , stateInput , null );
162168 }
163169
164- public static StateDecision singleNextState (final Class <? extends WorkflowState > stateClass , final Object stateInput ) {
165- return singleNextState (stateClass .getSimpleName (), stateInput );
170+ /**
171+ *
172+ * @param stateClass required
173+ * @return state decision
174+ */
175+ public static StateDecision singleNextState (final Class <? extends WorkflowState > stateClass ) {
176+ return singleNextState (stateClass , null , null );
166177 }
167178
168179 /**
169- * use the other one with WorkflowState class param if the StateId is provided by default, to make your code cleaner
170- * @param stateId stateId of next state
171- * @param stateInput input for next state
180+ * use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleaner
181+ * @param stateId required. StateId of next state
182+ * @param stateInput optional, can be null. Input for next state
183+ * @param stateOptionsOverride optional, can be null. It is used to override the defined one in the State class
172184 * @return state decision
173185 */
174- public static StateDecision singleNextState (final String stateId , final Object stateInput ) {
186+ public static StateDecision singleNextState (final String stateId , final Object stateInput , final WorkflowStateOptions stateOptionsOverride ) {
175187 return ImmutableStateDecision .builder ().nextStates (Arrays .asList (
176- StateMovement .create (stateId , stateInput )
188+ StateMovement .create (stateId , stateInput , stateOptionsOverride )
177189 )).build ();
178190 }
179191
180- public static StateDecision multiNextStates (final StateMovement ... stateMovements ) {
181- return ImmutableStateDecision .builder ().nextStates (Arrays .asList (stateMovements )).build ();
192+ /**
193+ * use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleaner
194+ * @param stateId stateId of next state
195+ * @return state decision
196+ */
197+ public static StateDecision singleNextState (final String stateId ) {
198+ return singleNextState (stateId , null , null );
182199 }
183200
201+ /**
202+ *
203+ * @param stateMovements required
204+ * @return state decision
205+ */
184206 public static StateDecision multiNextStates (final List <StateMovement > stateMovements ) {
185207 return ImmutableStateDecision .builder ().nextStates (stateMovements ).build ();
186208 }
187209
188- public static StateDecision multiNextStates (final Class <? extends WorkflowState >... states ) {
189- List <String > stateIds = new ArrayList <>();
190- Arrays .stream (states ).forEach (s -> stateIds .add (s .getSimpleName ()));
191- return multiNextStates (stateIds .toArray (new String [0 ]));
210+ /**
211+ *
212+ * @param stateMovements required
213+ * @return state decision
214+ */
215+ public static StateDecision multiNextStates (final StateMovement ... stateMovements ) {
216+ return multiNextStates (Arrays .asList (stateMovements ));
192217 }
193218
194219 /**
195- * use the other one with WorkflowState class param if the StateId is provided by default, to make your code cleaner
220+ * use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleaner
221+ * or use other ones with a list of StateMovement to enable the WorkflowStateOptions overriding
196222 * @param stateIds stateIds of next states
197223 * @return state decision
198224 */
@@ -201,6 +227,17 @@ public static StateDecision multiNextStates(final String... stateIds) {
201227 Arrays .stream (stateIds ).forEach (id -> {
202228 stateMovements .add (StateMovement .create (id ));
203229 });
204- return ImmutableStateDecision .builder ().nextStates (stateMovements ).build ();
230+ return multiNextStates (stateMovements );
231+ }
232+
233+ /**
234+ * use other ones with a list of StateMovement to enable the WorkflowStateOptions overriding
235+ * @param states required
236+ * @return state decision
237+ */
238+ public static StateDecision multiNextStates (final Class <? extends WorkflowState >... states ) {
239+ List <String > stateIds = new ArrayList <>();
240+ Arrays .stream (states ).forEach (s -> stateIds .add (s .getSimpleName ()));
241+ return multiNextStates (stateIds .toArray (new String [0 ]));
205242 }
206243}
0 commit comments