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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract <R> Raccept(ExpressionVisitor<R> visitor) Invoke theExpressionVisitorfunctions for this expression.equal(boolean value) Returns aBooleanEqualsexpression comparing this expression to the provided boolean value.Returns a StringEquals function of this expression and the given string value.abstract booleanstatic ExpressionConstructs an expression from the providedNode.Constructs aGetAttrexpression containing the given path string.getAttr(Identifier path) Constructs aGetAttrexpression containing the givenIdentifier.abstract inthashCode()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 Literalliteral(StringNode node) Constructs aLiteralfrom the givenStringNode.not()Returns a Not expression of this instance.static Expressionof(boolean value) static Expressionof(int value) Construct an integer literal for the given value, and returns it as an expression.static LiteralConstructs a string literal for the given values.parseArn()Returns a ParseArn function of this expression.static ExpressionparseShortform(String shortForm, FromSourceLocation context) Parse a value from a "short form" used within a template.parseUrl()Returns a parseUrl expression of this expression.static Referencereference(Identifier name, FromSourceLocation context) Constructs aReferencefor the givenIdentifierat 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 iftypeCheckhas not been invoked.protected abstract TypetypeCheckLocal(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 aReferencefor the givenIdentifierat the given location.- Parameters:
name- the referenced identifier.context- the source location.- Returns:
- the reference.
-
literal
Constructs aLiteralfrom the givenStringNode.- Parameters:
node- the node to construct the literal from.- Returns:
- the string node as a literal.
-
accept
Invoke theExpressionVisitorfunctions 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 aGetAttrexpression containing the given path string.- Parameters:
path- the path.- Returns:
- the
GetAttrexpression.
-
getAttr
Constructs aGetAttrexpression containing the givenIdentifier.- Parameters:
path- the pathIdentifier.- Returns:
- the
GetAttrexpression.
-
typeCheck
-
type
Returns the type for this expression, throws a runtime exception iftypeCheckhas not been invoked.- Returns:
- the type.
-
typeCheckLocal
- Throws:
InnerParseError
-
isSet
Returns an IsSet expression for this instance.- Returns:
- the IsSet expression.
-
equal
Returns aBooleanEqualsexpression 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
Notexpression.
-
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.
-