Class GetAttr
- 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.functions.LibraryFunction
-
- software.amazon.smithy.rulesengine.language.syntax.expressions.functions.GetAttr
-
- All Implemented Interfaces:
FromSourceLocation
,ToNode
,TypeCheck
,ToCondition
,ToExpression
public final class GetAttr extends LibraryFunction
A rule-set expression for indexing a record/object or array.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GetAttr.Definition
AFunctionDefinition
for theGetAttr
function.static interface
GetAttr.Part
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ID
-
Fields inherited from class software.amazon.smithy.rulesengine.language.syntax.expressions.functions.LibraryFunction
definition, functionNode
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> R
accept(ExpressionVisitor<R> visitor)
Invoke theExpressionVisitor
functions for this expression.boolean
equals(java.lang.Object o)
Value
evaluate(Value target)
Gets the value at the defined path out of the target value.static GetAttr.Definition
getDefinition()
Gets theFunctionDefinition
implementation.java.util.List<GetAttr.Part>
getPath()
Gets the list ofGetAttr.Part
s that make up the path to the requested attribute.Expression
getTarget()
Gets the expression to retrieve an attribute of.int
hashCode()
static GetAttr
ofExpressions(ToExpression arg1, java.lang.String arg2)
Creates aGetAttr
function from the given expressions.static GetAttr
ofExpressions(ToExpression arg1, ToExpression arg2)
Creates aGetAttr
function from the given expressions.java.lang.String
template()
Converts this expression to a string template.Node
toNode()
Converts a value to aNode
.java.lang.String
toString()
protected Type
typeCheckLocal(Scope<Type> scope)
-
Methods inherited from class software.amazon.smithy.rulesengine.language.syntax.expressions.functions.LibraryFunction
expectOneArgument, getArguments, getName, getSourceLocation
-
Methods inherited from class software.amazon.smithy.rulesengine.language.syntax.expressions.Expression
fromNode, getLiteral, getReference, of, of, of, parseShortform, toConditionBuilder, toExpression, type, typeCheck
-
Methods inherited from class software.amazon.smithy.rulesengine.language.syntax.SyntaxElement
booleanEqual, getAttr, getAttr, isSet, isValidHostLabel, not, parseUrl, stringEqual, substring
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface software.amazon.smithy.rulesengine.language.syntax.ToCondition
toCondition, toCondition
-
-
-
-
Field Detail
-
ID
public static final java.lang.String ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDefinition
public static GetAttr.Definition getDefinition()
Gets theFunctionDefinition
implementation.- Returns:
- the function definition.
-
ofExpressions
public static GetAttr ofExpressions(ToExpression arg1, ToExpression arg2)
Creates aGetAttr
function from the given expressions.- Parameters:
arg1
- the argument to extract from.arg2
- the path to extract.- Returns:
- The resulting
GetAttr
function.
-
ofExpressions
public static GetAttr ofExpressions(ToExpression arg1, java.lang.String arg2)
Creates aGetAttr
function from the given expressions.- Parameters:
arg1
- the argument to extract from.arg2
- the path to extract.- Returns:
- The resulting
GetAttr
function.
-
evaluate
public Value evaluate(Value target)
Gets the value at the defined path out of the target value.- Parameters:
target
- the target value to retrieve a value out of.- Returns:
- the retrieve value.
-
getTarget
public Expression getTarget()
Gets the expression to retrieve an attribute of.- Returns:
- the expression targeted by this function.
-
getPath
public java.util.List<GetAttr.Part> getPath()
Gets the list ofGetAttr.Part
s that make up the path to the requested attribute.- Returns:
- the list of path parts to the requested attribute.
-
accept
public <R> R accept(ExpressionVisitor<R> visitor)
Description copied from class:Expression
Invoke theExpressionVisitor
functions for this expression.- Specified by:
accept
in classExpression
- Type Parameters:
R
- the visitor return type.- Parameters:
visitor
- the visitor to be invoked.- Returns:
- the return value of the visitor.
-
typeCheckLocal
protected Type typeCheckLocal(Scope<Type> scope)
- Overrides:
typeCheckLocal
in classLibraryFunction
-
template
public java.lang.String template()
Description copied from class:SyntaxElement
Converts this expression to a string template. By default, this implementation returns aRuntimeException
.- Overrides:
template
in classSyntaxElement
- Returns:
- the String template.
-
toNode
public Node toNode()
Description copied from interface:ToNode
Converts a value to aNode
.- Specified by:
toNode
in interfaceToNode
- Overrides:
toNode
in classLibraryFunction
- Returns:
- Returns the creates Node.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classLibraryFunction
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classLibraryFunction
-
toString
public java.lang.String toString()
- Overrides:
toString
in classLibraryFunction
-
-