java.lang.Object
software.amazon.smithy.rulesengine.language.syntax.rule.Condition
All Implemented Interfaces:
FromSourceLocation, ToNode, Into<Condition>, IntoSelf<Condition>, TypeCheck

public final class Condition extends Object implements TypeCheck, FromSourceLocation, ToNode, IntoSelf<Condition>
A condition is call to a rule-set function that used to determine whether a rule should be executed. Can assign the results of functions to new parameters within the current scope.
  • Field Details

  • Method Details

    • fromNode

      public static Condition fromNode(Node node)
      Constructs a condition from the given node.
      Parameters:
      node - the node.
      Returns:
      the condition instance.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getFn

      public Expression getFn()
    • getSourceLocation

      public SourceLocation getSourceLocation()
      Description copied from interface: FromSourceLocation
      Gets the source location of a value.
      Specified by:
      getSourceLocation in interface FromSourceLocation
      Returns:
      Returns the source location of the value.
    • getResult

      public Optional<Identifier> getResult()
      Get the identifier of the parameter that the result is assigned to.
      Returns:
      the optional identifier.
    • typeCheck

      public Type typeCheck(Scope<Type> scope)
      Specified by:
      typeCheck in interface TypeCheck
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toNode

      public Node toNode()
      Description copied from interface: ToNode
      Converts a value to a Node.
      Specified by:
      toNode in interface ToNode
      Returns:
      Returns the creates Node.
    • toExpression

      public Expression toExpression()
      Converts this condition to an expression reference if the condition has a result assignment. Otherwise throws an exception.
      Returns:
      the result as a reference expression.