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 Valueevaluate(EndpointRuleSet ruleset, java.util.Map<Identifier,Value> parameterArguments)Initializes a newRuleEvaluatorinstances, and evaluates the provided ruleset and parameter arguments.ValueevaluateCondition(Condition condition)Evaluates the given condition in the current scope.ValueevaluateRuleSet(EndpointRuleSet ruleset, java.util.Map<Identifier,Value> parameterArguments)Evaluate the provided ruleset and parameter arguments.ValuevisitBoolEquals(Expression left, Expression right)Does a boolean equality check.ValuevisitGetAttr(GetAttr getAttr)Visits a GetAttr function.ValuevisitIsSet(Expression fn)Visits an isSet function.ValuevisitLibraryFunction(FunctionDefinition definition, java.util.List<Expression> arguments)Visits a library function.ValuevisitLiteral(Literal literal)Visits a literal.ValuevisitNot(Expression not)Visits a not function.ValuevisitRef(Reference reference)Visits a reference.ValuevisitStringEquals(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 newRuleEvaluatorinstances, 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:ExpressionVisitorVisits a literal.- Specified by:
visitLiteralin interfaceExpressionVisitor<Value>- Parameters:
literal- the literal to visit.- Returns:
- the value from the visitor.
-
visitRef
public Value visitRef(Reference reference)
Description copied from interface:ExpressionVisitorVisits a reference.- Specified by:
visitRefin interfaceExpressionVisitor<Value>- Parameters:
reference- the reference to visit.- Returns:
- the value from the visitor.
-
visitIsSet
public Value visitIsSet(Expression fn)
Description copied from interface:ExpressionVisitorVisits an isSet function.- Specified by:
visitIsSetin 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:ExpressionVisitorVisits a not function.- Specified by:
visitNotin 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:ExpressionVisitorDoes a boolean equality check.- Specified by:
visitBoolEqualsin 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:ExpressionVisitorDoes a string equality check.- Specified by:
visitStringEqualsin 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:ExpressionVisitorVisits a GetAttr function.- Specified by:
visitGetAttrin 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:ExpressionVisitorVisits a library function.- Specified by:
visitLibraryFunctionin interfaceExpressionVisitor<Value>- Parameters:
definition- the library function to visit.arguments- the arguments to the function being visited.- Returns:
- the value from the visitor.
-
-