@@ -141,7 +141,7 @@ states:
141141 end : true
142142` ` `
143143
144- To parse it and create a Workflow intance you can do:
144+ To parse it and create a Workflow instance you can do:
145145
146146` ` ` java
147147Workflow workflow = Workflow.fromSource(source);
@@ -288,5 +288,43 @@ Here are some generated diagrams from the specification examples (with legend en
288288
2892892 . [ Send CloudEvent on Workflow completion Example] ( https://github.com/serverlessworkflow/specification/blob/master/examples/examples.md#send-cloudevent-on-workfow-completion-example )
290290<p align =" center " >
291- <img src =" img/provisionorders.png " alt =" Send Cloud Event on Workflow complation " />
291+ <img src =" img/provisionorders.png " alt =" Send Cloud Event on Workflow completion " />
292292</p >
293+
294+ #### Using Workflow Utils
295+ Workflow utility allows you to interpret the Serverless Workflow Model.
296+ Once you have a ` Workflow ` instance, you can use it
297+ ##### Get Starting State
298+ ``` Java
299+ State startingState = WorkflowUtils . getStartingState(workflow);
300+ ```
301+ ##### Get States by State Type
302+ ``` Java
303+ List<State > states = WorkflowUtils . getStates(workflow, DefaultState . Type . EVENT );
304+ ```
305+ ##### Get Consumed-Events, Produced-Events and their count
306+ ``` Java
307+ List<EventDefinition > consumedEvents = WorkflowUtils . getWorkflowConsumedEvents(workflow);
308+ int consumedEventsCount = WorkflowUtils . getWorkflowConsumedEventsCount(workflow);
309+
310+ List<EventDefinition > producedEvents = WorkflowUtils . getWorkflowProducedEvents(workflow);
311+ int producedEventsCount = WorkflowUtils . getWorkflowProducedEventsCount(workflow);
312+ ```
313+ ##### Get Defined Consumed-Events, Defined Produced-Events and their count
314+ ``` Java
315+ List<EventDefinition > consumedEvents = WorkflowUtils . getWorkflowConsumedEventsCount(workflow);
316+ int consumedEventsCount = WorkflowUtils . getWorkflowConsumedEventsCount(workflow);
317+
318+ List<EventDefinition > producedEvents = WorkflowUtils . getWorkflowProducedEvents(workflow);
319+ int producedEventsCount = WorkflowUtils . getWorkflowProducedEventsCount(workflow);
320+ ```
321+ ##### Get Function definitions which is used by an action
322+ ``` Java
323+ FunctionDefinition finalizeApplicationFunctionDefinition =
324+ WorkflowUtils . getFunctionDefinitionsForAction(workflow, " finalizeApplicationAction" );
325+ ```
326+ ##### Get Actions which uses a Function definition
327+ ``` Java
328+ List<Action > actionsForFunctionDefinition =
329+ WorkflowUtils . getActionsForFunctionDefinition(workflow, functionRefName);
330+ ```
0 commit comments