Class Condition
- java.lang.Object
-
- software.amazon.smithy.rulesengine.language.syntax.SyntaxElement
-
- software.amazon.smithy.rulesengine.language.syntax.rule.Condition
-
- All Implemented Interfaces:
FromSourceLocation
,ToNode
,TypeCheck
,ToCondition
,ToExpression
public final class Condition extends SyntaxElement implements TypeCheck, FromSourceLocation, ToNode
A condition is call to a rule-set function that used to determine whether a rule should be executed. Can assign the results of functions to new parameters within the current scope.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Condition.Builder
A builder used to create aCondition
class.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ASSIGN
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Condition.Builder
builder()
Builder to create aCondition
instance.boolean
equals(java.lang.Object o)
static Condition
fromNode(Node node)
Constructs a condition from the given node.Expression
getFunction()
Gets the function used to express this condition.java.util.Optional<Identifier>
getResult()
Get the identifier of the parameter that the result is assigned to.SourceLocation
getSourceLocation()
Gets the source location of a value.int
hashCode()
Condition.Builder
toBuilder()
Condition
toCondition()
Convert this into a condition.Condition.Builder
toConditionBuilder()
Convert this into a condition builder for compositional use.Expression
toExpression()
Convert this into an expression.Node
toNode()
Converts a value to aNode
.java.lang.String
toString()
Type
typeCheck(Scope<Type> scope)
Checks whether the given types within a scope satisfy the constraints.-
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
-
-
-
-
Field Detail
-
ASSIGN
public static final java.lang.String ASSIGN
- See Also:
- Constant Field Values
-
-
Method Detail
-
builder
public static Condition.Builder builder()
Builder to create aCondition
instance.- Returns:
- returns a new Builder.
-
fromNode
public static Condition fromNode(Node node)
Constructs a condition from the given node.- Parameters:
node
- the node.- Returns:
- the condition instance.
-
getSourceLocation
public SourceLocation getSourceLocation()
Description copied from interface:FromSourceLocation
Gets the source location of a value.- Specified by:
getSourceLocation
in interfaceFromSourceLocation
- Returns:
- Returns the source location of the value.
-
getResult
public java.util.Optional<Identifier> getResult()
Get the identifier of the parameter that the result is assigned to.- Returns:
- the optional identifier.
-
getFunction
public Expression getFunction()
Gets the function used to express this condition.- Returns:
- the function for this condition.
-
toConditionBuilder
public Condition.Builder toConditionBuilder()
Description copied from interface:ToCondition
Convert this into a condition builder for compositional use.- Specified by:
toConditionBuilder
in interfaceToCondition
- Returns:
- the condition builder.
-
toCondition
public Condition toCondition()
Description copied from interface:ToCondition
Convert this into a condition.- Specified by:
toCondition
in interfaceToCondition
- Returns:
- the condition.
-
toExpression
public Expression toExpression()
Description copied from interface:ToExpression
Convert this into an expression.- Specified by:
toExpression
in interfaceToExpression
- Returns:
- the expression.
-
toBuilder
public Condition.Builder toBuilder()
-
typeCheck
public Type typeCheck(Scope<Type> scope)
Description copied from interface:TypeCheck
Checks whether the given types within a scope satisfy the constraints.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-