Class EndpointBddTrait

java.lang.Object
software.amazon.smithy.model.traits.AbstractTrait
software.amazon.smithy.rulesengine.traits.EndpointBddTrait
All Implemented Interfaces:
FromSourceLocation, ToNode, ToShapeId, Trait, ToSmithyBuilder<EndpointBddTrait>

public final class EndpointBddTrait extends AbstractTrait implements ToSmithyBuilder<EndpointBddTrait>
Trait containing a precompiled BDD with full context for endpoint resolution.
  • Field Details

    • ID

      public static final ShapeId ID
  • Method Details

    • from

      public static EndpointBddTrait from(Cfg cfg)
      Creates a BddTrait from a control flow graph.
      Parameters:
      cfg - the control flow graph to compile
      Returns:
      the BddTrait containing the compiled BDD and all context
    • removeUnreferencedConditions

      public EndpointBddTrait removeUnreferencedConditions()
      Removes conditions that are not referenced by any BDD node and remaps indices.

      This should be called after all BDD optimizations (sifting, cost optimization) are complete. A condition could become unreferenced if it is optimized away by the BDD compiler because hi==lo.

      Returns:
      a new trait with unreferenced conditions removed, or this trait if none were removed
    • getParameters

      public Parameters getParameters()
      Gets the parameters for the endpoint rules.
      Returns:
      the parameters
    • getConditions

      public List<Condition> getConditions()
      Gets the ordered list of conditions.
      Returns:
      the conditions in evaluation order
    • getResults

      public List<Rule> getResults()
      Gets the ordered list of results.
      Returns:
      the results (index 0 is always NoMatchRule)
    • getBdd

      public Bdd getBdd()
      Gets the BDD structure.
      Returns:
      the BDD
    • getVersion

      public RulesVersion getVersion()
      Get the endpoint ruleset version.
      Returns:
      the rules engine version
    • getComponentFactory

      public EndpointComponentFactory getComponentFactory()
      Gets the EndpointComponentFactory used to resolve this BDD's functions, built-ins, and auth-scheme validators.

      Built lazily from the classloader captured when this trait was created (the classloader used to assemble the model) and cached, so endpoint extensions living only in a caller-supplied closure classloader are discovered. When no distinct classloader is present, the shared default factory is reused.

      Returns:
      the factory used to resolve endpoint components.
    • transform

      Transform this BDD using the given function and return the updated BddTrait.
      Parameters:
      transformer - Transformer used to modify the trait.
      Returns:
      the updated trait.
    • createNode

      protected Node createNode()
      Description copied from class: AbstractTrait
      The result of toNode is used for hashCodes and equality. Subclasses must implement createNode to turn the trait into a Node. This is then cached for subsequent retrievals.
      Specified by:
      createNode in class AbstractTrait
      Returns:
      Returns the trait as a node.
    • fromNode

      public static EndpointBddTrait fromNode(Node node)
      Creates a BddTrait from a Node representation.
      Parameters:
      node - the node to parse
      Returns:
      the BddTrait
    • fromNode

      public static EndpointBddTrait fromNode(Node node, ClassLoader classLoader)
      Creates a BddTrait from a Node representation, discovering endpoint functions and built-ins using the given classLoader.

      When classLoader is null, discovery falls back to this class's own loader. Use this overload when the BDD may reference functions contributed by an EndpointRuleSetExtension that lives in a caller-supplied classloader.

      Parameters:
      node - the node to parse.
      classLoader - the classloader used to discover endpoint extensions, or null.
      Returns:
      the BddTrait.
    • builder

      public static EndpointBddTrait.Builder builder()
      Creates a new builder for BddTrait.
      Returns:
      a new builder
    • toBuilder

      public EndpointBddTrait.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<EndpointBddTrait>
      Returns:
      a builder for type T