Class RuleEvaluator
- java.lang.Object
-
- software.amazon.smithy.rulesengine.language.evaluation.RuleEvaluator
-
- All Implemented Interfaces:
ExpressionVisitor<Value>
public class RuleEvaluator extends java.lang.Object implements ExpressionVisitor<Value>
A runtime implementation of a rule-set evaluation engine.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface software.amazon.smithy.rulesengine.language.syntax.expressions.ExpressionVisitor
ExpressionVisitor.Default<R>
-
-
Constructor Summary
Constructors Constructor Description RuleEvaluator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Value
evaluate(EndpointRuleSet ruleset, java.util.Map<Identifier,Value> parameterArguments)
Initializes a newRuleEvaluator
instances, and evaluates the provided ruleset and parameter arguments.Value
evaluateCondition(Condition condition)
Evaluates the given condition in the current scope.Value
evaluateRuleSet(EndpointRuleSet ruleset, java.util.Map<Identifier,Value> parameterArguments)
Evaluate the provided ruleset and parameter arguments.Value
visitBoolEquals(Expression left, Expression right)
Does a boolean equality check.Value
visitGetAttr(GetAttr getAttr)
Visits a GetAttr function.Value
visitIsSet(Expression fn)
Visits an isSet function.Value
visitLibraryFunction(FunctionDefinition definition, java.util.List<Expression> arguments)
Visits a library function.Value
visitLiteral(Literal literal)
Visits a literal.Value
visitNot(Expression not)
Visits a not function.Value
visitRef(Reference reference)
Visits a reference.Value
visitStringEquals(Expression left, Expression right)
Does a string equality check.
-
-
-
Method Detail
-
evaluate
public static Value evaluate(EndpointRuleSet ruleset, java.util.Map<Identifier,Value> parameterArguments)
Initializes a newRuleEvaluator
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, java.util.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 interfaceExpressionVisitor<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 interfaceExpressionVisitor<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 interfaceExpressionVisitor<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 interfaceExpressionVisitor<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 interfaceExpressionVisitor<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 interfaceExpressionVisitor<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 interfaceExpressionVisitor<Value>
- Parameters:
getAttr
- the GetAttr function to visit.- Returns:
- the value from the visitor.
-
visitLibraryFunction
public Value visitLibraryFunction(FunctionDefinition definition, java.util.List<Expression> arguments)
Description copied from interface:ExpressionVisitor
Visits a library function.- Specified by:
visitLibraryFunction
in interfaceExpressionVisitor<Value>
- Parameters:
definition
- the library function to visit.arguments
- the arguments to the function being visited.- Returns:
- the value from the visitor.
-
-