Record Class DefaultCaseDetails

java.lang.Object
java.lang.Record
org.ek9lang.compiler.ir.DefaultCaseDetails

public record DefaultCaseDetails(List<IRInstr> defaultBodyEvaluation, String defaultResult) extends Record
Record containing default case management information for CONTROL_FLOW_CHAIN constructs.

Default cases handle the fallback behavior when no condition in the condition chain matches: - if/else statements: "else" block - switch statements: "default" case - Question operators: the _isSet() check (default behavior when not null)

Some constructs may not have default cases (e.g., incomplete if statements without else, guarded assignments that only execute conditionally).

  • Constructor Details

    • DefaultCaseDetails

      public DefaultCaseDetails(List<IRInstr> defaultBodyEvaluation, String defaultResult)
      Creates an instance of a DefaultCaseDetails record class.
      Parameters:
      defaultBodyEvaluation - the value for the defaultBodyEvaluation record component
      defaultResult - the value for the defaultResult record component
  • Method Details

    • none

      public static DefaultCaseDetails none()
      Create empty default case details (no default case).
    • withInstructions

      public static DefaultCaseDetails withInstructions(List<IRInstr> defaultBodyEvaluation)
      Create default case details with instructions only.
    • withResult

      public static DefaultCaseDetails withResult(List<IRInstr> defaultBodyEvaluation, String defaultResult)
      Create default case details with instructions and result.
    • hasDefaultCase

      public boolean hasDefaultCase()
      Check if this has a default case.
    • hasDefaultResult

      public boolean hasDefaultResult()
      Check if this has a default result variable.
    • isEmpty

      public boolean isEmpty()
      Check if this default details object is empty (no default case).
    • toString

      @Nonnull public String toString()
      IR-optimized toString following EK9's bracket-only, no-indentation format. Returns empty string if no default case to prevent rightward drift.
      Specified by:
      toString in class Record
    • 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.
    • defaultBodyEvaluation

      public List<IRInstr> defaultBodyEvaluation()
      Returns the value of the defaultBodyEvaluation record component.
      Returns:
      the value of the defaultBodyEvaluation record component
    • defaultResult

      public String defaultResult()
      Returns the value of the defaultResult record component.
      Returns:
      the value of the defaultResult record component