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 Object implements TypeCheck, ToNode, FromSourceLocation
The core functionality of a rule-set rule.
  • Field Details

  • Constructor Details

  • Method Details

    • builder

      public static Rule.Builder builder()
      Builder to create a Rule instance.
      Returns:
      returns a new Builder.
    • builder

      public static Rule.Builder builder(FromSourceLocation sourceLocation)
      Builder to create a Rule instance.
      Parameters:
      sourceLocation - the source of the rule.
      Returns:
      returns a new Builder.
    • fromNode

      public static Rule fromNode(Node node)
      Creates a Rule 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 interface FromSourceLocation
      Returns:
      Returns the source location of the value.
    • getConditions

      public List<Condition> getConditions()
      Gets the conditions required to satisfy this rule.
      Returns:
      the list of conditions.
    • getDocumentation

      public Optional<String> getDocumentation()
      Gets the documentation value.
      Returns:
      returns the optional documentation value.
    • accept

      public abstract <T> T accept(RuleValueVisitor<T> visitor)
      Invoke the RuleValueVisitor 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.
    • typecheckValue

      protected abstract Type typecheckValue(Scope<Type> scope)
    • typeCheck

      public Type typeCheck(Scope<Type> scope)
      Description copied from interface: TypeCheck
      Checks whether the given types within a scope satisfy the constraints.
      Specified by:
      typeCheck in interface TypeCheck
      Parameters:
      scope - the scope to evaluate.
      Returns:
      the type validated by the scope check.
    • toNode

      public Node toNode()
      Description copied from interface: ToNode
      Converts a value to a Node.
      Specified by:
      toNode in interface ToNode
      Returns:
      Returns the creates Node.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object