Class ResultId

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

public class ResultId extends Object implements ModelId, Comparable<ResultId>
Represents a unique identifier for a workflow result. ResultId is an immutable value object that identifies a specific result within a workflow transition.

ResultId implements both ModelId and Comparable interfaces, making it suitable for use as an identifier in workflow models and for ordering in collections. It supports both a value (required) and an optional name for human-readable identification.

Results define what happens after a transition is executed, including the destination state, any functions to be executed, and additional metadata about the transition outcome. Each result must have a unique identifier within its context.

Since:
1.0
See Also:
  • Method Details

    • getValue

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

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

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

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

      public static ResultId orNull(String value)
      Creates a ResultId from the given value, returning null if the value is null.
      Parameters:
      value - the result identifier string
      Returns:
      a new ResultId instance or null if value is null
    • orNull

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

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

      public boolean equals(Object object)
      Compares this ResultId with another object for equality. Two ResultId 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 ResultId based on its string value.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code for this ResultId
    • toString

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