Record Class ImmutableWorkflowCallerContext

java.lang.Object
java.lang.Record
com.yworkflow.common.caller.ImmutableWorkflowCallerContext
Record Components:
tenantId - the tenant ID for this context
caller - the caller for this context
All Implemented Interfaces:
WorkflowCallerContext

public record ImmutableWorkflowCallerContext(TenantId tenantId, WorkflowCaller caller) extends Record implements WorkflowCallerContext
Immutable implementation of WorkflowCallerContext using a record. This class provides a thread-safe, immutable representation of a caller context that combines tenant information with caller identity.

ImmutableWorkflowCallerContext is implemented as a record, which automatically provides implementations for equals(), hashCode(), and toString() methods based on the record components. This ensures proper value semantics for the context.

The class implements the fluent interface pattern, allowing for easy creation of new contexts with modified tenant or caller information while maintaining immutability.

Since:
1.0
See Also:
  • Constructor Details

    • ImmutableWorkflowCallerContext

      public ImmutableWorkflowCallerContext(TenantId tenantId, WorkflowCaller caller)
      Creates an instance of a ImmutableWorkflowCallerContext record class.
      Parameters:
      tenantId - the value for the tenantId record component
      caller - the value for the caller record component
  • Method Details

    • from

      public WorkflowCallerContext from(TenantId tenantId)
      Creates a new WorkflowCallerContext with the specified tenant ID, keeping the same caller.
      Specified by:
      from in interface WorkflowCallerContext
      Parameters:
      tenantId - the new tenant ID
      Returns:
      a new ImmutableWorkflowCallerContext with the specified tenant ID
    • actAs

      public WorkflowCallerContext actAs(WorkflowCaller caller)
      Creates a new WorkflowCallerContext with the specified caller, keeping the same tenant ID.
      Specified by:
      actAs in interface WorkflowCallerContext
      Parameters:
      caller - the new caller
      Returns:
      a new ImmutableWorkflowCallerContext with the specified caller
    • 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.
    • tenantId

      public TenantId tenantId()
      Returns the value of the tenantId record component.
      Specified by:
      tenantId in interface WorkflowCallerContext
      Returns:
      the value of the tenantId record component
    • caller

      public WorkflowCaller caller()
      Returns the value of the caller record component.
      Specified by:
      caller in interface WorkflowCallerContext
      Returns:
      the value of the caller record component