java.lang.Object
software.amazon.smithy.rulesengine.language.syntax.SyntaxElement
software.amazon.smithy.rulesengine.language.syntax.rule.Condition
All Implemented Interfaces:
FromSourceLocation, ToNode, TypeCheck, ToCondition, ToExpression

public final class Condition extends SyntaxElement implements TypeCheck, FromSourceLocation, ToNode
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

    • builder

      public static Condition.Builder builder()
      Builder to create a Condition instance.
      Returns:
      returns a new Builder.
    • fromNode

      public static Condition fromNode(Node node)
      Constructs a condition from the given node.
      Parameters:
      node - the node.
      Returns:
      the condition instance.
    • 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.
    • getFunction

      public Expression getFunction()
      Gets the function used to express this condition.
      Returns:
      the function for this condition.
    • toConditionBuilder

      public Condition.Builder toConditionBuilder()
      Description copied from interface: ToCondition
      Convert this into a condition builder for compositional use.
      Specified by:
      toConditionBuilder in interface ToCondition
      Returns:
      the condition builder.
    • toCondition

      public Condition toCondition()
      Description copied from interface: ToCondition
      Convert this into a condition.
      Specified by:
      toCondition in interface ToCondition
      Returns:
      the condition.
    • toExpression

      public Expression toExpression()
      Description copied from interface: ToExpression
      Convert this into an expression.
      Specified by:
      toExpression in interface ToExpression
      Returns:
      the expression.
    • toBuilder

      public Condition.Builder toBuilder()
    • typeCheck

      public Type typeCheck(Scope<Type> scope)
      Description copied from interface: TypeCheck
      Checks whether the given types within a scope satisfy the constraints.
      Specified by:
      typeCheck in interface TypeCheck
      Parameters:
      scope - the scope to evaluate.
      Returns:
      the type validated by the scope check.
    • 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.
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object