Class Literal
- java.lang.Object
- 
- software.amazon.smithy.rulesengine.language.syntax.SyntaxElement
- 
- software.amazon.smithy.rulesengine.language.syntax.expressions.Expression
- 
- software.amazon.smithy.rulesengine.language.syntax.expressions.literal.Literal
 
 
 
- 
- All Implemented Interfaces:
- FromSourceLocation,- ToNode,- TypeCheck,- ToCondition,- ToExpression
 - Direct Known Subclasses:
- BooleanLiteral,- IntegerLiteral,- RecordLiteral,- StringLiteral,- TupleLiteral
 
 public abstract class Literal extends Expression Literals allow rules and properties to define arbitrarily nested JSON structures (e.g.for properties)They support template strings, but _do not_ support template objects since that creates ambiguity. Templates are a basic example of literals–literal strings. Literals can also be booleans, objects, integers or tuples.
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <R> Raccept(ExpressionVisitor<R> visitor)Invoke theExpressionVisitorfunctions for this expression.abstract <T> Taccept(LiteralVisitor<T> visitor)java.util.Optional<java.lang.Boolean>asBooleanLiteral()java.util.Optional<java.lang.Integer>asIntegerLiteral()java.util.Optional<java.util.Map<Identifier,Literal>>asRecordLiteral()java.util.Optional<Template>asStringLiteral()java.util.Optional<java.util.List<Literal>>asTupleLiteral()static LiteralbooleanLiteral(boolean value)Constructs a bool literal from a boolean value.Valueevaluate(RuleEvaluator evaluator)static LiteralfromNode(Node node)Constructs a literal from aNodebased on the Node's type.static LiteralintegerLiteral(int value)Constructs an integer literal from an integer value.static LiteralrecordLiteral(java.util.Map<Identifier,Literal> record)Constructs a record literal of values.static LiteralstringLiteral(Template value)Constructs a string literal from aTemplatevalue.static LiteraltupleLiteral(java.util.List<Literal> values)Constructs a tuple literal of values.TypetypeCheckLocal(Scope<Type> scope)- 
Methods inherited from class software.amazon.smithy.rulesengine.language.syntax.expressions.Expressionequals, getLiteral, getReference, getSourceLocation, hashCode, of, of, of, parseShortform, toConditionBuilder, toExpression, type, typeCheck
 - 
Methods inherited from class software.amazon.smithy.rulesengine.language.syntax.SyntaxElementbooleanEqual, getAttr, getAttr, isSet, isValidHostLabel, not, parseUrl, stringEqual, substring, template
 - 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface software.amazon.smithy.rulesengine.language.syntax.ToConditiontoCondition, toCondition
 
- 
 
- 
- 
- 
Method Detail- 
booleanLiteralpublic static Literal booleanLiteral(boolean value) Constructs a bool literal from a boolean value.- Parameters:
- value- the boolean value.
- Returns:
- the bool literal.
 
 - 
integerLiteralpublic static Literal integerLiteral(int value) Constructs an integer literal from an integer value.- Parameters:
- value- the integer value.
- Returns:
- the integer literal.
 
 - 
recordLiteralpublic static Literal recordLiteral(java.util.Map<Identifier,Literal> record) Constructs a record literal of values.- Parameters:
- record- a map of values to be converted to a record.
- Returns:
- the record literal.
 
 - 
stringLiteralpublic static Literal stringLiteral(Template value) Constructs a string literal from aTemplatevalue.- Parameters:
- value- the template value.
- Returns:
- the string literal.
 
 - 
tupleLiteralpublic static Literal tupleLiteral(java.util.List<Literal> values) Constructs a tuple literal of values.- Parameters:
- values- the values.
- Returns:
- the tuple literal.
 
 - 
asBooleanLiteralpublic java.util.Optional<java.lang.Boolean> asBooleanLiteral() 
 - 
asIntegerLiteralpublic java.util.Optional<java.lang.Integer> asIntegerLiteral() 
 - 
asRecordLiteralpublic java.util.Optional<java.util.Map<Identifier,Literal>> asRecordLiteral() 
 - 
asStringLiteralpublic java.util.Optional<Template> asStringLiteral() 
 - 
asTupleLiteralpublic java.util.Optional<java.util.List<Literal>> asTupleLiteral() 
 - 
acceptpublic <R> R accept(ExpressionVisitor<R> visitor) Description copied from class:ExpressionInvoke theExpressionVisitorfunctions for this expression.- Specified by:
- acceptin class- Expression
- Type Parameters:
- R- the visitor return type.
- Parameters:
- visitor- the visitor to be invoked.
- Returns:
- the return value of the visitor.
 
 - 
acceptpublic abstract <T> T accept(LiteralVisitor<T> visitor) 
 - 
fromNodepublic static Literal fromNode(Node node) Constructs a literal from aNodebased on the Node's type.- Parameters:
- node- a node to construct as a literal.
- Returns:
- the literal representation of the node.
 
 - 
typeCheckLocalpublic Type typeCheckLocal(Scope<Type> scope) - Specified by:
- typeCheckLocalin class- Expression
 
 - 
evaluatepublic Value evaluate(RuleEvaluator evaluator) - Parameters:
- evaluator- the rule-set evaluator.
- Returns:
- the resulting value.
 
 
- 
 
-