Class StateInstance

java.lang.Object
com.yworkflow.instance.model.StateInstance

public class StateInstance extends Object
Represents an instance of a state within a workflow execution. StateInstance tracks the runtime information for a specific state in a workflow instance, including its status, timing, ownership, and execution history.
Since:
1.0
See Also:
  • Constructor Details

    • StateInstance

      public StateInstance(StateInstanceId id, WorkflowInstanceId workflowInstanceId, StateId state, TransitionId transitionId, List<String> owners, Instant startedAt, Instant dueAt, Instant completedAt, ResultStatus status, List<StateInstanceId> previousStateIds, WorkflowCaller caller, boolean active)
      Creates a new StateInstance with the specified parameters.
      Parameters:
      id - the unique identifier for this state instance
      workflowInstanceId - the ID of the workflow instance this state belongs to
      state - the state ID this instance represents
      transitionId - the transition that led to this state
      owners - the list of users responsible for this state
      startedAt - when this state instance was started
      dueAt - when this state instance is due
      completedAt - when this state instance was completed (null if not completed)
      status - the current status of this state instance
      previousStateIds - the list of previous state instance IDs
      caller - the caller who initiated this state
      active - whether this state instance is currently active
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDueAt

      public Instant getDueAt()
      Gets the due date for this state instance.
      Returns:
      the due date, or null if not set
    • setDueAt

      public void setDueAt(Instant dueAt)
      Sets the due date for this state instance.
      Parameters:
      dueAt - the due date to set
    • getCompletedAt

      public Instant getCompletedAt()
      Gets the completion date for this state instance.
      Returns:
      the completion date, or null if not completed
    • setCompletedAt

      public void setCompletedAt(Instant completedAt)
      Sets the completion date for this state instance.
      Parameters:
      completedAt - the completion date to set
    • getStartedAt

      public Instant getStartedAt()
      Gets the start date for this state instance.
      Returns:
      the start date, or null if not set
    • setStartedAt

      public void setStartedAt(Instant startedAt)
      Sets the start date for this state instance.
      Parameters:
      startedAt - the start date to set
    • getCaller

      public WorkflowCaller getCaller()
      Gets the caller who initiated this state instance.
      Returns:
      the caller, or null if not set
    • setCaller

      public void setCaller(WorkflowCaller caller)
      Sets the caller who initiated this state instance.
      Parameters:
      caller - the caller to set
    • getOwners

      public List<String> getOwners()
      Gets the list of owners responsible for this state instance.
      Returns:
      the list of owners, or null if not set
    • setOwners

      public void setOwners(List<String> owners)
      Sets the list of owners responsible for this state instance.
      Parameters:
      owners - the list of owners to set
    • getStatus

      public ResultStatus getStatus()
      Gets the current status of this state instance.
      Returns:
      the status, or null if not set
    • setStatus

      public void setStatus(ResultStatus status)
      Sets the current status of this state instance.
      Parameters:
      status - the status to set
    • getPreviousStateIds

      public List<StateInstanceId> getPreviousStateIds()
      Gets the list of previous state instance IDs.
      Returns:
      the list of previous state instance IDs, or null if not set
    • setPreviousStateIds

      public void setPreviousStateIds(List<StateInstanceId> previousStateIds)
      Sets the list of previous state instance IDs.
      Parameters:
      previousStateIds - the list of previous state instance IDs to set
    • getTransitionId

      public TransitionId getTransitionId()
      Gets the transition ID that led to this state instance.
      Returns:
      the transition ID, or null if not set
    • setTransitionId

      public void setTransitionId(TransitionId transitionId)
      Sets the transition ID that led to this state instance.
      Parameters:
      transitionId - the transition ID to set
    • getStateId

      public StateId getStateId()
      Gets the state ID that this instance represents.
      Returns:
      the state ID, or null if not set
    • setStateId

      public void setStateId(StateId stateId)
      Sets the state ID that this instance represents.
      Parameters:
      stateId - the state ID to set
    • getId

      public StateInstanceId getId()
      Gets the unique identifier for this state instance.
      Returns:
      the state instance ID
    • getWorkflowInstanceId

      public WorkflowInstanceId getWorkflowInstanceId()
      Gets the workflow instance ID that this state instance belongs to.
      Returns:
      the workflow instance ID
    • setActive

      public void setActive(boolean active)
      Sets whether this state instance is currently active.
      Parameters:
      active - true if the state instance is active, false otherwise
    • isActive

      public boolean isActive()
      Checks whether this state instance is currently active.
      Returns:
      true if the state instance is active, false otherwise
    • empty

      public static StateInstance empty()
      Creates an empty StateInstance with default empty values.
      Returns:
      a new StateInstance with empty/default values