Record Class FunctionContext

java.lang.Object
java.lang.Record
com.yworkflow.definition.model.FunctionContext
Record Components:
functionType - the type of function being executed
originId - the ID of the origin element (state, destination, etc.)
transitionId - the ID of the transition being executed

public record FunctionContext(FunctionType functionType, DestinationId originId, TransitionId transitionId) extends Record
Represents the context in which a workflow function is executed. FunctionContext provides information about the execution environment, including the function type, origin ID, and transition ID, which helps functions understand their execution context.

FunctionContext is used by the workflow engine to provide functions with contextual information about when and where they are being executed. This allows functions to adapt their behavior based on the execution context and make informed decisions about their operations.

FunctionContext supports various execution contexts:

  • State Functions - Pre- or Post-state execution
  • Transition Functions - Pre/post transition execution
  • Result Functions - Pre/post result execution
  • Trigger Functions - Event-driven execution
Since:
1.0
See Also:
  • Constructor Details

    • FunctionContext

      public FunctionContext(FunctionType functionType, DestinationId originId, TransitionId transitionId)
      Creates an instance of a FunctionContext record class.
      Parameters:
      functionType - the value for the functionType record component
      originId - the value for the originId record component
      transitionId - the value for the transitionId record component
  • Method Details

    • preState

      public static FunctionContext preState(StateId stateId)
      Creates a function context for pre-state execution.
      Parameters:
      stateId - the state ID
      Returns:
      a new FunctionContext for pre-state execution
    • postState

      public static FunctionContext postState(StateId stateId)
      Creates a function context for post-state execution.
      Parameters:
      stateId - the state ID
      Returns:
      a new FunctionContext for post-state execution
    • trigger

      public static FunctionContext trigger()
      Creates a function context for trigger execution.
      Returns:
      a new FunctionContext for trigger execution
    • preStateTransition

      public static FunctionContext preStateTransition(StateId stateId, TransitionId transitionId)
      Creates a function context for pre-state transition execution.
      Parameters:
      stateId - the state ID
      transitionId - the transition ID
      Returns:
      a new FunctionContext for pre-state transition execution
    • postStateTransition

      public static FunctionContext postStateTransition(StateId stateId, TransitionId transitionId)
      Creates a function context for post-state transition execution.
      Parameters:
      stateId - the state ID
      transitionId - the transition ID
      Returns:
      a new FunctionContext for post-state transition execution
    • preInitialTransition

      public static FunctionContext preInitialTransition(TransitionId transitionId)
      Creates a function context for pre-initial transition execution.
      Parameters:
      transitionId - the transition ID
      Returns:
      a new FunctionContext for pre-initial transition execution
    • postInitialTransition

      public static FunctionContext postInitialTransition(TransitionId transitionId)
      Creates a function context for post-initial transition execution.
      Parameters:
      transitionId - the transition ID
      Returns:
      a new FunctionContext for post-initial transition execution
    • preGlobalTransition

      public static FunctionContext preGlobalTransition(TransitionId transitionId)
      Creates a function context for pre-global transition execution.
      Parameters:
      transitionId - the transition ID
      Returns:
      a new FunctionContext for pre-global transition execution
    • postGlobalTransition

      public static FunctionContext postGlobalTransition(TransitionId transitionId)
      Creates a function context for post-global transition execution.
      Parameters:
      transitionId - the transition ID
      Returns:
      a new FunctionContext for post-global transition execution
    • preCommonTransition

      public static FunctionContext preCommonTransition(StateId stateId, TransitionId transitionId)
      Creates a function context for pre-common transition execution.
      Parameters:
      stateId - the state ID
      transitionId - the transition ID
      Returns:
      a new FunctionContext for pre-common transition execution
    • postCommonTransition

      public static FunctionContext postCommonTransition(StateId stateId, TransitionId transitionId)
      Creates a function context for post-common transition execution.
      Parameters:
      stateId - the state ID
      transitionId - the transition ID
      Returns:
      a new FunctionContext for post-common transition execution
    • preDefaultResult

      public static FunctionContext preDefaultResult(DestinationId destinationId, TransitionId transitionId)
      Creates a function context for pre-default result execution.
      Parameters:
      destinationId - the destination ID
      transitionId - the transition ID
      Returns:
      a new FunctionContext for pre-default result execution
    • postDefaultResult

      public static FunctionContext postDefaultResult(DestinationId destinationId, TransitionId transitionId)
      Creates a function context for post-default result execution.
      Parameters:
      destinationId - the destination ID
      transitionId - the transition ID
      Returns:
      a new FunctionContext for post-default result execution
    • preConditionalResult

      public static FunctionContext preConditionalResult(DestinationId originId, TransitionId transitionId)
      Creates a function context for pre-conditional result execution.
      Parameters:
      originId - the origin ID
      transitionId - the transition ID
      Returns:
      a new FunctionContext for pre-conditional result execution
    • postConditionalResult

      public static FunctionContext postConditionalResult(DestinationId originId, TransitionId transitionId)
      Creates a function context for post-conditional result execution.
      Parameters:
      originId - the origin ID
      transitionId - the transition ID
      Returns:
      a new FunctionContext for post-conditional result execution
    • withOriginId

      public FunctionContext withOriginId(DestinationId originId)
      Creates a new FunctionContext with the specified origin ID.
      Parameters:
      originId - the new origin ID
      Returns:
      a new FunctionContext with the specified origin ID
    • withTransitionId

      public FunctionContext withTransitionId(TransitionId transitionId)
      Creates a new FunctionContext with the specified transition ID.
      Parameters:
      transitionId - the new transition ID
      Returns:
      a new FunctionContext with the specified transition ID
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • functionType

      public FunctionType functionType()
      Returns the value of the functionType record component.
      Returns:
      the value of the functionType record component
    • originId

      public DestinationId originId()
      Returns the value of the originId record component.
      Returns:
      the value of the originId record component
    • transitionId

      public TransitionId transitionId()
      Returns the value of the transitionId record component.
      Returns:
      the value of the transitionId record component