All Implemented Interfaces:
FromSourceLocation, ToNode, TypeCheck, ToCondition, ToExpression

public final class Ite extends LibraryFunction
An if-then-else (ITE) function that returns one of two values based on a boolean condition.

This function is critical for avoiding SSA (Static Single Assignment) fragmentation in BDD compilation. By computing conditional values atomically without branching, it prevents the graph explosion that occurs when boolean flags like UseFips or UseDualStack create divergent paths with distinct variable identities.

Semantics: ite(condition, trueValue, falseValue)

  • If condition is true, returns trueValue
  • If condition is false, returns falseValue
  • The condition must be a non-optional boolean (use coalesce to provide a default if needed)

Type checking rules (least upper bound of nullability):

  • ite(Boolean, T, T) => T - both non-optional, result is non-optional
  • ite(Boolean, T, Optional<T>) => Optional<T> - any optional makes result optional
  • ite(Boolean, Optional<T>, T) => Optional<T> - any optional makes result optional
  • ite(Boolean, Optional<T>, Optional<T>) => Optional<T> - both optional, result is optional

Available since: rules engine 1.1.

  • Field Details

  • Method Details

    • getDefinition

      public static Ite.Definition getDefinition()
      Gets the FunctionDefinition implementation.
      Returns:
      the function definition.
    • ofExpressions

      public static Ite ofExpressions(ToExpression condition, ToExpression trueValue, ToExpression falseValue)
      Creates a Ite function from the given expressions.
      Parameters:
      condition - the boolean condition to evaluate
      trueValue - the value to return if condition is true
      falseValue - the value to return if condition is false
      Returns:
      The resulting Ite function.
    • ofStrings

      public static Ite ofStrings(ToExpression conditionRef, String trueValue, String falseValue)
      Creates a Ite function with a reference condition and string values.
      Parameters:
      conditionRef - the reference to a boolean parameter
      trueValue - the string value if condition is true
      falseValue - the string value if condition is false
      Returns:
      The resulting Ite function.
    • availableSince

      public RulesVersion availableSince()
      Description copied from class: SyntaxElement
      Get the rules engine version that this syntax element is available since.
      Overrides:
      availableSince in class SyntaxElement
      Returns:
      the version this is available since.
    • accept

      public <R> R accept(ExpressionVisitor<R> visitor)
      Description copied from class: Expression
      Invoke the ExpressionVisitor functions for this expression.
      Specified by:
      accept in class Expression
      Type Parameters:
      R - the visitor return type.
      Parameters:
      visitor - the visitor to be invoked.
      Returns:
      the return value of the visitor.
    • typeCheckLocal

      protected Type typeCheckLocal(Scope<Type> scope) throws InnerParseError
      Overrides:
      typeCheckLocal in class LibraryFunction
      Throws:
      InnerParseError