Class TransitionId

java.lang.Object
com.yworkflow.definition.model.value.TransitionId
All Implemented Interfaces:
Comparable<TransitionId>

public class TransitionId extends Object implements Comparable<TransitionId>
Represents a unique identifier for a transition within a workflow. TransitionId is an immutable value object that serves as the primary key for transitions within workflow definitions and instances.

TransitionId instances can optionally include a human-readable name in addition to the unique identifier. This is useful for display purposes and debugging.

Since:
1.0
  • Field Details

    • EMPTY

      public static final TransitionId EMPTY
      An empty TransitionId instance with an empty value and no name.
  • Method Details

    • getValue

      public String getValue()
      Returns the string value of this transition ID.
      Returns:
      the transition ID value
    • getName

      public Optional<String> getName()
      Returns the optional human-readable name of this transition.
      Returns:
      an Optional containing the name if present, empty otherwise
    • transitionId

      public static TransitionId transitionId(String value)
      Creates a new TransitionId instance with the specified value and no name.
      Parameters:
      value - the string value for the transition ID
      Returns:
      a new TransitionId instance
      Throws:
      IllegalArgumentException - if the value is invalid
    • transitionId

      public static TransitionId transitionId(String value, String name)
      Creates a new TransitionId instance with the specified value and name.
      Parameters:
      value - the string value for the transition ID
      name - the human-readable name for the transition (can be null)
      Returns:
      a new TransitionId instance
      Throws:
      IllegalArgumentException - if the value is invalid
    • orNull

      public static TransitionId orNull(String value)
      Creates a new TransitionId instance with the specified value, or returns null if the value is null. This is useful for handling nullable string values.
      Parameters:
      value - the string value for the transition ID (can be null)
      Returns:
      a new TransitionId instance or null if value is null
    • name

      public TransitionId name(String name)
      Creates a new TransitionId instance with the same value but a different name.
      Parameters:
      name - the new name for the transition
      Returns:
      a new TransitionId instance with the specified name
    • compareTo

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

      public boolean equals(Object object)
      Compares this TransitionId with the specified object for equality. Two TransitionId instances are equal if they have the same 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 TransitionId.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
    • toString

      public String toString()
      Returns a string representation of this TransitionId.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the TransitionId