Class Coalesce
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.Coalesce
- All Implemented Interfaces:
FromSourceLocation,ToNode,TypeCheck,ToCondition,ToExpression
A coalesce function that returns the first non-empty value.
This variadic function requires two or more arguments. At runtime, returns the first argument that contains a non-EmptyValue, otherwise returns the result of the last argument.
Type checking rules:
coalesce(T, T, T) => T(same types)coalesce(Optional<T>, T, T) => T(any non-optional makes result non-optional)coalesce(Optional<T>, Optional<T>, Optional<T>) => Optional<T>(all optional)
Available since: rules engine 1.1.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAFunctionDefinitionfor theCoalescefunction. -
Field Summary
FieldsFields inherited from class software.amazon.smithy.rulesengine.language.syntax.expressions.functions.LibraryFunction
definition, functionNode -
Method Summary
Modifier and TypeMethodDescription<R> Raccept(ExpressionVisitor<R> visitor) Invoke theExpressionVisitorfunctions for this expression.Get the rules engine version that this syntax element is available since.static Coalesce.DefinitionGets theFunctionDefinitionimplementation.static CoalesceofExpressions(List<? extends ToExpression> args) Creates aCoalescefunction from a list of expressions.static CoalesceofExpressions(ToExpression... args) Creates aCoalescefunction from variadic expressions.Checks whether the given types within a scope satisfy the constraints.Methods inherited from class software.amazon.smithy.rulesengine.language.syntax.expressions.functions.LibraryFunction
calculateReferences, canonicalize, equals, expectOneArgument, getArguments, getFunctionDefinition, getName, getSourceLocation, hashCode, shouldSwapArgs, toConditionBuilder, toNode, toString, typeCheckLocalMethods inherited from class software.amazon.smithy.rulesengine.language.syntax.expressions.Expression
fromNode, getLiteral, getReference, getReference, getReference, getReferences, of, of, of, parseShortform, toExpression, typeMethods inherited from class software.amazon.smithy.rulesengine.language.syntax.SyntaxElement
booleanEqual, getAttr, getAttr, isSet, isValidHostLabel, not, parseUrl, stringEqual, substring, templateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.smithy.rulesengine.language.syntax.ToCondition
toCondition, toCondition
-
Field Details
-
ID
- See Also:
-
-
Method Details
-
getDefinition
Gets theFunctionDefinitionimplementation.- Returns:
- the function definition.
-
ofExpressions
Creates aCoalescefunction from variadic expressions.- Parameters:
args- the expressions to coalesce- Returns:
- The resulting
Coalescefunction.
-
ofExpressions
Creates aCoalescefunction from a list of expressions.- Parameters:
args- the expressions to coalesce- Returns:
- The resulting
Coalescefunction.
-
availableSince
Description copied from class:SyntaxElementGet the rules engine version that this syntax element is available since.- Overrides:
availableSincein classSyntaxElement- Returns:
- the version this is available since.
-
accept
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.
-
typeCheck
Description copied from interface:TypeCheckChecks whether the given types within a scope satisfy the constraints.- Specified by:
typeCheckin interfaceTypeCheck- Overrides:
typeCheckin classExpression- Parameters:
scope- the scope to evaluate.- Returns:
- the type validated by the scope check.
-