Class EndpointRuleSet

java.lang.Object
software.amazon.smithy.rulesengine.language.EndpointRuleSet
All Implemented Interfaces:
FromSourceLocation, ToNode, TypeCheck, ToSmithyBuilder<EndpointRuleSet>

public final class EndpointRuleSet extends Object implements FromSourceLocation, ToNode, ToSmithyBuilder<EndpointRuleSet>, TypeCheck
A set of EndpointRules. EndpointType Rules describe the endpoint resolution behavior for a service.
  • Method Details

    • getDefaultComponentFactory

      public static EndpointComponentFactory getDefaultComponentFactory()
      Gets the shared EndpointComponentFactory discovered from this class's own classloader.

      Reused for any rule-set that does not need a distinct classloader (no explicit loader, or a loader equal to this class's own), so those cases avoid re-running service discovery.

      Returns:
      the shared default component factory.
    • getComponentFactory

      public EndpointComponentFactory getComponentFactory()
      Gets the EndpointComponentFactory used to resolve this rule-set's functions and built-ins.

      Captured from the classloader-aware fromNode(Node, EndpointComponentFactory) (the classloader used to assemble the model) and carried across toBuilder(), so transforms that round-trip a rule-set through the node form re-resolve functions against the same classloader. Defaults to the shared factory discovered from this class's own loader.

      Returns:
      the component factory for this rule-set.
    • builder

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

      public static EndpointRuleSet fromNode(Node node) throws RuleError
      Creates an EndpointRuleSet of a specific type from the given Node information.
      Parameters:
      node - the node to deserialize.
      Returns:
      the created EndpointRuleSet.
      Throws:
      RuleError
    • fromNode

      public static EndpointRuleSet fromNode(Node node, ClassLoader classLoader) throws RuleError
      Creates an EndpointRuleSet from the given Node, discovering endpoint functions and built-ins using the given classLoader.

      Convenience overload that builds an EndpointComponentFactory from classLoader (or this class's own loader when null). Prefer fromNode(Node, EndpointComponentFactory) when a factory is already available so it can be reused across the deserialization and validation of the same rule-set.

      Parameters:
      node - the node to deserialize.
      classLoader - the classloader used to discover endpoint extensions, or null.
      Returns:
      the created EndpointRuleSet.
      Throws:
      RuleError
    • fromNode

      public static EndpointRuleSet fromNode(Node node, EndpointComponentFactory factory) throws RuleError
      Creates an EndpointRuleSet from the given Node, resolving endpoint functions and built-ins using the given EndpointComponentFactory.

      The factory wraps the classloader used to discover EndpointRuleSetExtensions and caches the discovered components, so a caller can build it once (typically from a dependency-closure classloader) and reuse it. When factory is null, the default factory discovered from this class's own loader is used.

      Parameters:
      node - the node to deserialize.
      factory - the factory used to resolve endpoint components, or null.
      Returns:
      the created EndpointRuleSet.
      Throws:
      RuleError
    • 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.
    • getParameters

      public Parameters getParameters()
      Gets the Parameters defined in this rule-set.
      Returns:
      the parameters defined in the rule-set.
    • getRules

      public List<Rule> getRules()
      Gets the list of Rules defined in this rule-set.
      Returns:
      the rules defined in this rule-set.
    • getVersion

      public String getVersion()
      Gets the version of this rule-set.
      Returns:
      the rule-set version.
    • getRulesVersion

      public RulesVersion getRulesVersion()
      Get the parsed rules engine version.
      Returns:
      parsed version.
    • typeCheck

      public Type typeCheck()
    • 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.
    • toBuilder

      public EndpointRuleSet.Builder toBuilder()
      Description copied from interface: ToSmithyBuilder
      Take this object and create a builder that contains all of the current property values of this object.
      Specified by:
      toBuilder in interface ToSmithyBuilder<EndpointRuleSet>
      Returns:
      a builder for type T
    • 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
    • hasBuiltIn

      public static boolean hasBuiltIn(String name)
      Returns true if a built-in of the provided name has been registered.
      Parameters:
      name - the name of the built-in to check for.
      Returns:
      true if the built-in is present, false otherwise.
    • getKeyString

      public static String getKeyString()
      Gets the built-in names as a joined string.
      Returns:
      a string of the built-in names.
    • createFunctionFactory

      public static Function<FunctionNode,Optional<LibraryFunction>> createFunctionFactory()
      Creates a LibraryFunction factory function using the loaded function definitions.
      Returns:
      the created factory.
    • getAuthSchemeValidators

      public static List<AuthSchemeValidator> getAuthSchemeValidators()
      Gets loaded authentication scheme validators.
      Returns:
      a list of AuthSchemeValidators.