java.lang.Object
software.amazon.smithy.rulesengine.language.evaluation.RuleEvaluator
All Implemented Interfaces:
ExpressionVisitor<Value>

public class RuleEvaluator extends Object implements ExpressionVisitor<Value>
A runtime implementation of a rule-set evaluation engine.
  • Constructor Details

    • RuleEvaluator

      public RuleEvaluator()
  • Method Details

    • evaluate

      public static Value evaluate(EndpointRuleSet ruleset, Map<Identifier,Value> parameterArguments)
      Initializes a new RuleEvaluator instances, and evaluates the provided ruleset and parameter arguments.
      Parameters:
      ruleset - The endpoint ruleset.
      parameterArguments - The rule-set parameter identifiers and values to evaluate the rule-set against.
      Returns:
      The resulting value from the final matched rule.
    • evaluateRuleSet

      public Value evaluateRuleSet(EndpointRuleSet ruleset, Map<Identifier,Value> parameterArguments)
      Evaluate the provided ruleset and parameter arguments.
      Parameters:
      ruleset - The endpoint ruleset.
      parameterArguments - The rule-set parameter identifiers and values to evaluate the rule-set against.
      Returns:
      The resulting value from the final matched rule.
    • evaluateCondition

      public Value evaluateCondition(Condition condition)
      Evaluates the given condition in the current scope.
      Parameters:
      condition - the condition to evaluate.
      Returns:
      the value returned by the condition.
    • visitLiteral

      public Value visitLiteral(Literal literal)
      Description copied from interface: ExpressionVisitor
      Visits a literal.
      Specified by:
      visitLiteral in interface ExpressionVisitor<Value>
      Parameters:
      literal - the literal to visit.
      Returns:
      the value from the visitor.
    • visitRef

      public Value visitRef(Reference reference)
      Description copied from interface: ExpressionVisitor
      Visits a reference.
      Specified by:
      visitRef in interface ExpressionVisitor<Value>
      Parameters:
      reference - the reference to visit.
      Returns:
      the value from the visitor.
    • visitIsSet

      public Value visitIsSet(Expression fn)
      Description copied from interface: ExpressionVisitor
      Visits an isSet function.
      Specified by:
      visitIsSet in interface ExpressionVisitor<Value>
      Parameters:
      fn - the isSet function to visit.
      Returns:
      the value from the visitor.
    • visitNot

      public Value visitNot(Expression not)
      Description copied from interface: ExpressionVisitor
      Visits a not function.
      Specified by:
      visitNot in interface ExpressionVisitor<Value>
      Parameters:
      not - the not function to visit.
      Returns:
      the value from the visitor.
    • visitBoolEquals

      public Value visitBoolEquals(Expression left, Expression right)
      Description copied from interface: ExpressionVisitor
      Does a boolean equality check.
      Specified by:
      visitBoolEquals in interface ExpressionVisitor<Value>
      Parameters:
      left - the first value to compare.
      right - the second value to compare.
      Returns:
      the value from the visitor.
    • visitStringEquals

      public Value visitStringEquals(Expression left, Expression right)
      Description copied from interface: ExpressionVisitor
      Does a string equality check.
      Specified by:
      visitStringEquals in interface ExpressionVisitor<Value>
      Parameters:
      left - the first value to compare.
      right - the second value to compare.
      Returns:
      the value from the visitor.
    • visitGetAttr

      public Value visitGetAttr(GetAttr getAttr)
      Description copied from interface: ExpressionVisitor
      Visits a GetAttr function.
      Specified by:
      visitGetAttr in interface ExpressionVisitor<Value>
      Parameters:
      getAttr - the GetAttr function to visit.
      Returns:
      the value from the visitor.
    • visitLibraryFunction

      public Value visitLibraryFunction(FunctionDefinition definition, List<Expression> arguments)
      Description copied from interface: ExpressionVisitor
      Visits a library function.
      Specified by:
      visitLibraryFunction in interface ExpressionVisitor<Value>
      Parameters:
      definition - the library function to visit.
      arguments - the arguments to the function being visited.
      Returns:
      the value from the visitor.