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 class
AFunctionDefinition
for theCoalesce
function. -
Field Summary
FieldsFields inherited from class software.amazon.smithy.rulesengine.language.syntax.expressions.functions.LibraryFunction
definition, functionNode
-
Method Summary
Modifier and TypeMethodDescription<R> R
accept
(ExpressionVisitor<R> visitor) Invoke theExpressionVisitor
functions for this expression.Get the rules engine version that this syntax element is available since.static Coalesce.Definition
Gets theFunctionDefinition
implementation.static Coalesce
ofExpressions
(List<? extends ToExpression> args) Creates aCoalesce
function from a list of expressions.static Coalesce
ofExpressions
(ToExpression... args) Creates aCoalesce
function 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, typeCheckLocal
Methods inherited from class software.amazon.smithy.rulesengine.language.syntax.expressions.Expression
fromNode, getLiteral, getReference, getReference, getReference, getReferences, of, of, of, parseShortform, toExpression, type
Methods inherited from class software.amazon.smithy.rulesengine.language.syntax.SyntaxElement
booleanEqual, getAttr, getAttr, isSet, isValidHostLabel, not, parseUrl, stringEqual, substring, template
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 Details
-
ID
- See Also:
-
-
Method Details
-
getDefinition
Gets theFunctionDefinition
implementation.- Returns:
- the function definition.
-
ofExpressions
Creates aCoalesce
function from variadic expressions.- Parameters:
args
- the expressions to coalesce- Returns:
- The resulting
Coalesce
function.
-
ofExpressions
Creates aCoalesce
function from a list of expressions.- Parameters:
args
- the expressions to coalesce- Returns:
- The resulting
Coalesce
function.
-
availableSince
Description copied from class:SyntaxElement
Get the rules engine version that this syntax element is available since.- Overrides:
availableSince
in classSyntaxElement
- Returns:
- the version this is available since.
-
accept
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.
-
typeCheck
Description copied from interface:TypeCheck
Checks whether the given types within a scope satisfy the constraints.- Specified by:
typeCheck
in interfaceTypeCheck
- Overrides:
typeCheck
in classExpression
- Parameters:
scope
- the scope to evaluate.- Returns:
- the type validated by the scope check.
-