Class Rule
- java.lang.Object
-
- software.amazon.smithy.rulesengine.language.syntax.rule.Rule
-
- All Implemented Interfaces:
FromSourceLocation
,ToNode
,TypeCheck
- Direct Known Subclasses:
EndpointRule
,ErrorRule
,TreeRule
public abstract class Rule extends java.lang.Object implements TypeCheck, ToNode, FromSourceLocation
The core functionality of a rule-set rule.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Rule.Builder
A builder used to create aRule
class.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Rule(Rule.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <T> T
accept(RuleValueVisitor<T> visitor)
Invoke theRuleValueVisitor
functions for this Rule.static Rule.Builder
builder()
Builder to create aRule
instance.static Rule.Builder
builder(FromSourceLocation sourceLocation)
Builder to create aRule
instance.boolean
equals(java.lang.Object o)
static Rule
fromNode(Node node)
Creates aRule
instance from the given Node information.java.util.List<Condition>
getConditions()
Gets the conditions required to satisfy this rule.java.util.Optional<java.lang.String>
getDocumentation()
Gets the documentation value.SourceLocation
getSourceLocation()
Gets the source location of a value.int
hashCode()
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.protected abstract Type
typecheckValue(Scope<Type> scope)
-
-
-
Field Detail
-
DOCUMENTATION
public static final java.lang.String DOCUMENTATION
- See Also:
- Constant Field Values
-
ENDPOINT
public static final java.lang.String ENDPOINT
- See Also:
- Constant Field Values
-
ERROR
public static final java.lang.String ERROR
- See Also:
- Constant Field Values
-
TREE
public static final java.lang.String TREE
- See Also:
- Constant Field Values
-
RULES
public static final java.lang.String RULES
- See Also:
- Constant Field Values
-
TYPE
public static final java.lang.String TYPE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Rule
protected Rule(Rule.Builder builder)
-
-
Method Detail
-
builder
public static Rule.Builder builder()
Builder to create aRule
instance.- Returns:
- returns a new Builder.
-
builder
public static Rule.Builder builder(FromSourceLocation sourceLocation)
Builder to create aRule
instance.- Parameters:
sourceLocation
- the source of the rule.- Returns:
- returns a new Builder.
-
fromNode
public static Rule fromNode(Node node)
Creates aRule
instance from the given Node information.- Parameters:
node
- the node to deserialize.- Returns:
- the created Rule.
-
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.
-
getConditions
public java.util.List<Condition> getConditions()
Gets the conditions required to satisfy this rule.- Returns:
- the list of conditions.
-
getDocumentation
public java.util.Optional<java.lang.String> getDocumentation()
Gets the documentation value.- Returns:
- returns the optional documentation value.
-
accept
public abstract <T> T accept(RuleValueVisitor<T> visitor)
Invoke theRuleValueVisitor
functions for this Rule.- Type Parameters:
T
- the visitor return type.- Parameters:
visitor
- the visitor to be invoked.- Returns:
- the return value of the visitor.
-
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
-
-