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 classGetAttr.DefinitionAFunctionDefinitionfor theGetAttrfunction.static interfaceGetAttr.Part
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringID-
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> Raccept(ExpressionVisitor<R> visitor)Invoke theExpressionVisitorfunctions for this expression.booleanequals(java.lang.Object o)Valueevaluate(Value target)Gets the value at the defined path out of the target value.static GetAttr.DefinitiongetDefinition()Gets theFunctionDefinitionimplementation.java.util.List<GetAttr.Part>getPath()Gets the list ofGetAttr.Parts that make up the path to the requested attribute.ExpressiongetTarget()Gets the expression to retrieve an attribute of.inthashCode()static GetAttrofExpressions(ToExpression arg1, java.lang.String arg2)Creates aGetAttrfunction from the given expressions.static GetAttrofExpressions(ToExpression arg1, ToExpression arg2)Creates aGetAttrfunction from the given expressions.java.lang.Stringtemplate()Converts this expression to a string template.NodetoNode()Converts a value to aNode.java.lang.StringtoString()protected TypetypeCheckLocal(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 theFunctionDefinitionimplementation.- Returns:
- the function definition.
-
ofExpressions
public static GetAttr ofExpressions(ToExpression arg1, ToExpression arg2)
Creates aGetAttrfunction from the given expressions.- Parameters:
arg1- the argument to extract from.arg2- the path to extract.- Returns:
- The resulting
GetAttrfunction.
-
ofExpressions
public static GetAttr ofExpressions(ToExpression arg1, java.lang.String arg2)
Creates aGetAttrfunction from the given expressions.- Parameters:
arg1- the argument to extract from.arg2- the path to extract.- Returns:
- The resulting
GetAttrfunction.
-
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.Parts 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:ExpressionInvoke theExpressionVisitorfunctions for this expression.- Specified by:
acceptin 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:
typeCheckLocalin classLibraryFunction
-
template
public java.lang.String template()
Description copied from class:SyntaxElementConverts this expression to a string template. By default, this implementation returns aRuntimeException.- Overrides:
templatein classSyntaxElement- Returns:
- the String template.
-
toNode
public Node toNode()
Description copied from interface:ToNodeConverts a value to aNode.- Specified by:
toNodein interfaceToNode- Overrides:
toNodein classLibraryFunction- Returns:
- Returns the creates Node.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classLibraryFunction
-
hashCode
public int hashCode()
- Overrides:
hashCodein classLibraryFunction
-
toString
public java.lang.String toString()
- Overrides:
toStringin classLibraryFunction
-
-