Class Expression
java.lang.Object
software.amazon.smithy.rulesengine.language.util.MandatorySourceLocation
software.amazon.smithy.rulesengine.language.syntax.expr.Expression
- All Implemented Interfaces:
FromSourceLocation
,ToNode
,TypeCheck
A dynamically computed expression.
Expressions are the fundamental building block of the rule language.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract <R> R
accept
(ExpressionVisitor<R> visitor) Invoke theExpressionVisitor
functions for this expression.equal
(boolean value) Returns aBooleanEquals
expression comparing this expression to the provided boolean value.Returns a StringEquals function of this expression and the given string value.abstract boolean
static Expression
Constructs an expression from the providedNode
.Constructs aGetAttr
expression containing the given path string.getAttr
(Identifier path) Constructs aGetAttr
expression containing the givenIdentifier
.abstract int
hashCode()
isSet()
Returns an IsSet expression for this instance.isValidHostLabel
(boolean allowDots) Returns a isValidHostLabel expression of this expression.isVirtualHostableS3Bucket
(boolean allowDots) Returns a isVirtualHostableS3Bucket expression of this expression.static Literal
literal
(StringNode node) Constructs aLiteral
from the givenStringNode
.not()
Returns a Not expression of this instance.static Expression
of
(boolean value) static Expression
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.parseArn()
Returns a ParseArn function of this expression.static Expression
parseShortform
(String shortForm, FromSourceLocation context) Parse a value from a "short form" used within a template.parseUrl()
Returns a parseUrl expression of this expression.static Reference
reference
(Identifier name, FromSourceLocation context) Constructs aReference
for the givenIdentifier
at the given location.Returns a substring expression of this expression.template()
Converts this expression to a string template.type()
Returns the type for this expression, throws a runtime exception iftypeCheck
has not been invoked.protected abstract Type
typeCheckLocal
(Scope<Type> scope) Methods inherited from class software.amazon.smithy.rulesengine.language.util.MandatorySourceLocation
getSourceLocation
-
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
-
reference
Constructs aReference
for the givenIdentifier
at the given location.- Parameters:
name
- the referenced identifier.context
- the source location.- Returns:
- the reference.
-
literal
Constructs aLiteral
from the givenStringNode
.- Parameters:
node
- the node to construct the literal from.- Returns:
- the string node as a literal.
-
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.
-
hashCode
public abstract int hashCode() -
equals
-
getAttr
Constructs aGetAttr
expression containing the given path string.- Parameters:
path
- the path.- Returns:
- the
GetAttr
expression.
-
getAttr
Constructs aGetAttr
expression containing the givenIdentifier
.- Parameters:
path
- the pathIdentifier
.- Returns:
- the
GetAttr
expression.
-
typeCheck
-
type
Returns the type for this expression, throws a runtime exception iftypeCheck
has not been invoked.- Returns:
- the type.
-
typeCheckLocal
- Throws:
InnerParseError
-
isSet
Returns an IsSet expression for this instance.- Returns:
- the IsSet expression.
-
equal
Returns aBooleanEquals
expression comparing this expression to the provided boolean value.- Parameters:
value
- the value to compare against.- Returns:
- the BooleanEquals
Function
.
-
not
Returns a Not expression of this instance.- Returns:
- the
Not
expression.
-
equal
Returns a StringEquals function of this expression and the given string value.- Parameters:
value
- the string value to compare this expression to.- Returns:
- the StringEquals
Function
.
-
parseArn
Returns a ParseArn function of this expression.- Returns:
- the ParseArn function expression.
-
substring
Returns a substring expression of this expression.- Parameters:
startIndex
- the starting index of the string.stopIndex
- the ending index of the string.reverse
- whether the indexing is should start from end of the string to start.- Returns:
- the Substring function expression.
-
isValidHostLabel
Returns a isValidHostLabel expression of this expression.- Parameters:
allowDots
- whether the UTF-8.
is considered valid within a host label.- Returns:
- the isValidHostLabel function expression.
-
isVirtualHostableS3Bucket
Returns a isVirtualHostableS3Bucket expression of this expression.- Parameters:
allowDots
- whether the UTF-8.
is considered valid within a host label.- Returns:
- the isVirtualHostableS3Bucket function expression.
-
parseUrl
Returns a parseUrl expression of this expression.- Returns:
- the parseUrl function expression.
-
template
Converts this expression to a string template. By default this implementation returns aRuntimeException
.- Returns:
- the string template.
-