Class Expression
java.lang.Object
software.amazon.smithy.rulesengine.language.syntax.SyntaxElement
software.amazon.smithy.rulesengine.language.syntax.expressions.Expression
- All Implemented Interfaces:
FromSourceLocation
,ToNode
,TypeCheck
,ToCondition
,ToExpression
- Direct Known Subclasses:
LibraryFunction
,Literal
,Reference
public abstract class Expression
extends SyntaxElement
implements FromSourceLocation, ToNode, TypeCheck
A dynamically computed expression.
Expressions are the fundamental building block of the rule language.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract <R> R
accept
(ExpressionVisitor<R> visitor) Invoke theExpressionVisitor
functions for this expression.Computes the references of an expression.abstract boolean
static Expression
Constructs an expression from the providedNode
.static Literal
getLiteral
(StringNode node) Constructs aLiteral
from the givenStringNode
.static Reference
getReference
(String name) Constructs aReference
for the givenIdentifier
.static Reference
getReference
(Identifier name) Constructs aReference
for the givenIdentifier
.static Reference
getReference
(Identifier name, FromSourceLocation context) Constructs aReference
for the givenIdentifier
at the given location.Get the set of variables that this condition references.Gets the source location of a value.abstract int
hashCode()
static Literal
of
(boolean value) static Literal
of
(int value) Construct an integer literal for the given value, and returns it as an expression.static Literal
Constructs a string literal for the given values.static Expression
parseShortform
(String shortForm, FromSourceLocation context) Parse a value from a "short form" used within a template.Convert this into an expression.type()
Returns the type for this expression, throws a runtime exception iftypeCheck
has not been invoked.Checks whether the given types within a scope satisfy the constraints.protected abstract Type
typeCheckLocal
(Scope<Type> scope) Methods inherited from class software.amazon.smithy.rulesengine.language.syntax.SyntaxElement
availableSince, booleanEqual, getAttr, getAttr, isSet, isValidHostLabel, not, parseUrl, stringEqual, substring, template
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.smithy.rulesengine.language.syntax.ToCondition
toCondition, toCondition, toConditionBuilder
-
Constructor Details
-
Expression
-
-
Method Details
-
of
-
of
Construct an integer literal for the given value, and returns it as an expression.- Parameters:
value
- the integer value.- Returns:
- the integer value as a literal expression.
-
of
Constructs a string literal for the given values.- Parameters:
value
- the string value.- Returns:
- the string value as a literal.
-
fromNode
Constructs an expression from the providedNode
.- Parameters:
node
- the node to construct the expression from.- Returns:
- the expression.
-
parseShortform
Parse a value from a "short form" used within a template.- Parameters:
shortForm
- the shortform value- Returns:
- the parsed expression
-
getReference
Constructs aReference
for the givenIdentifier
at the given location.- Parameters:
name
- the referenced identifier.context
- the source location.- Returns:
- the reference.
-
getReference
Constructs aReference
for the givenIdentifier
.- Parameters:
name
- the referenced identifier.- Returns:
- the reference.
-
getReference
Constructs aReference
for the givenIdentifier
.- Parameters:
name
- the referenced identifier.- Returns:
- the reference.
-
getLiteral
Constructs aLiteral
from the givenStringNode
.- Parameters:
node
- the node to construct the literal from.- Returns:
- the string node as a literal.
-
getReferences
Get the set of variables that this condition references.- Returns:
- variable references by name.
-
calculateReferences
Computes the references of an expression.- Returns:
- the computed references.
-
accept
Invoke theExpressionVisitor
functions for this expression.- Type Parameters:
R
- the visitor return type.- Parameters:
visitor
- the visitor to be invoked.- Returns:
- the return value of the visitor.
-
typeCheckLocal
- Throws:
InnerParseError
-
type
Returns the type for this expression, throws a runtime exception iftypeCheck
has not been invoked.- Returns:
- the type.
-
toExpression
Description copied from interface:ToExpression
Convert this into an expression.- Specified by:
toExpression
in interfaceToExpression
- Returns:
- the expression.
-
hashCode
public abstract int hashCode() -
equals
-
getSourceLocation
Description copied from interface:FromSourceLocation
Gets the source location of a value.- Specified by:
getSourceLocation
in interfaceFromSourceLocation
- Returns:
- Returns the source location of the value.
-
typeCheck
Description copied from interface:TypeCheck
Checks whether the given types within a scope satisfy the constraints.
-