Class StateId

java.lang.Object
com.yworkflow.definition.model.value.StateId
All Implemented Interfaces:
DestinationId, ModelId, Comparable<StateId>

public class StateId extends Object implements DestinationId, Comparable<StateId>
Represents a unique identifier for a workflow state. StateId is an immutable value object that identifies a specific state within a workflow definition.

StateId implements both DestinationId and Comparable interfaces, making it suitable for use as a destination in workflow transitions and for ordering in collections. It supports both a value (required) and an optional name for human-readable identification.

States are the fundamental building blocks of workflows, representing different stages or conditions in a business process. Each state can have multiple transitions leading to other states, forks, or joins.

Since:
1.0
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final StateId
    Represents an empty state ID, used when no specific state is specified.
    static final StateId
    Represents a self-reference state ID, used to indicate that a transition should remain in the current state.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compares this StateId with another for ordering.
    boolean
    equals(Object object)
    Compares this StateId with another object for equality.
    Returns the optional human-readable name of this state.
    Returns the string value of this state ID.
    int
    Returns the hash code for this StateId based on its string value.
    boolean
    Returns true since this is a StateId.
    name(String name)
    Creates a new StateId with the same value but a different name.
    static StateId
    orNull(String value, String name)
    Creates a StateId from the given value and name, returning null if the value is null.
    static StateId
    stateId(String value)
    Creates a new StateId with the specified value and no name.
    static StateId
    stateId(String value, String name)
    Creates a new StateId with the specified value and name.
    Returns a string representation of this StateId.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.yworkflow.definition.model.value.DestinationId

    isForkId, isJoinId
  • Field Details

    • EMPTY

      public static final StateId EMPTY
      Represents an empty state ID, used when no specific state is specified.
    • SELF

      public static final StateId SELF
      Represents a self-reference state ID, used to indicate that a transition should remain in the current state.
  • Method Details

    • getValue

      public String getValue()
      Returns the string value of this state ID.
      Specified by:
      getValue in interface DestinationId
      Specified by:
      getValue in interface ModelId
      Returns:
      the state identifier string
    • getName

      public Optional<String> getName()
      Returns the optional human-readable name of this state.
      Specified by:
      getName in interface DestinationId
      Returns:
      an Optional containing the name if present, empty otherwise
    • isStateId

      public boolean isStateId()
      Returns true since this is a StateId.
      Specified by:
      isStateId in interface DestinationId
      Returns:
      always true
    • stateId

      public static StateId stateId(String value)
      Creates a new StateId with the specified value and no name.
      Parameters:
      value - the state identifier string
      Returns:
      a new StateId instance
      Throws:
      IllegalArgumentException - if the value is invalid
    • stateId

      public static StateId stateId(String value, String name)
      Creates a new StateId with the specified value and name.
      Parameters:
      value - the state identifier string
      name - the optional human-readable name
      Returns:
      a new StateId instance
      Throws:
      IllegalArgumentException - if the value is invalid
    • name

      public StateId name(String name)
      Creates a new StateId with the same value but a different name.
      Parameters:
      name - the new name for this state ID
      Returns:
      a new StateId instance with the specified name
    • orNull

      public static StateId orNull(String value, String name)
      Creates a StateId from the given value and name, returning null if the value is null.
      Parameters:
      value - the state identifier string
      name - the optional human-readable name
      Returns:
      a new StateId instance or null if value is null
    • compareTo

      public int compareTo(StateId o)
      Compares this StateId with another for ordering. Comparison is based on the string value.
      Specified by:
      compareTo in interface Comparable<StateId>
      Parameters:
      o - the StateId to compare with
      Returns:
      a negative integer, zero, or a positive integer as this StateId is less than, equal to, or greater than the specified StateId
    • equals

      public boolean equals(Object object)
      Compares this StateId with another object for equality. Two StateId instances are equal if they have the same string value.
      Overrides:
      equals in class Object
      Parameters:
      object - the object to compare with
      Returns:
      true if the objects are equal, false otherwise
    • hashCode

      public int hashCode()
      Returns the hash code for this StateId based on its string value.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code for this StateId
    • toString

      public String toString()
      Returns a string representation of this StateId.
      Overrides:
      toString in class Object
      Returns:
      a string representation including the ID and optional name