Class Transition

java.lang.Object
com.scivicslab.pojoactor.workflow.Transition

public class Transition extends Object
Represents a single transition in the workflow graph.

Each transition defines a state change with associated actions. The states list typically contains two elements: the current state and the next state. The actions can be represented in two ways:

  • Legacy format: List of string lists [actorName, actionName, argument]
  • New format: List of Action objects with execution mode support

This class is designed to be populated from YAML workflow definitions using deserialization frameworks like SnakeYAML or Jackson.

Since:
2.12.0
Author:
devteam@scivicslab.com
  • Constructor Details

    • Transition

      public Transition()
  • Method Details

    • getActions

      public List<Action> getActions()
      Returns the list of Action objects for this transition.
      Returns:
      a list of Action objects
    • getStates

      public List<String> getStates()
      Returns the list of states for this transition.

      Typically contains two elements: [currentState, nextState]

      Returns:
      a list of state identifiers
    • setActions

      public void setActions(List<Action> actions)
      Sets the list of actions for this transition.
      Parameters:
      actions - a list of Action objects
    • setStates

      public void setStates(List<String> list)
      Sets the list of states for this transition.
      Parameters:
      list - a list of state identifiers
    • getLabel

      public String getLabel()
      Returns the label.

      The label is used as a stable identifier for overlay matching. When applying patches, transitions are matched by this label rather than by states or array index.

      Returns:
      the label, or null if not set
    • setLabel

      public void setLabel(String label)
      Sets the label.
      Parameters:
      label - the label identifier
    • getNote

      public String getNote()
      Returns the note for this transition.

      The note provides human-readable documentation about what this transition does. It is optional and not used at runtime.

      Returns:
      the note, or null if not set
    • setNote

      public void setNote(String note)
      Sets the note for this transition.
      Parameters:
      note - the human-readable note
    • toYamlString

      public String toYamlString(int maxLines)
      Returns a YAML-formatted string representation of this transition.

      This method reconstructs a YAML-like format from the parsed data, useful for debugging and visualization. The output shows the first N lines of the transition definition.

      Example output:

       - states: ["0", "1"]
         actions:
           - actor: node
             method: executeCommand
             arguments: ["ls -la"]
       
      Parameters:
      maxLines - maximum number of lines to include (0 for unlimited)
      Returns:
      YAML-formatted string representation