Class EndpointUrlCodeEmitter

java.lang.Object
software.amazon.awssdk.codegen.poet.rules.EndpointUrlCodeEmitter

public final class EndpointUrlCodeEmitter extends Object
Emits the optimal EndpointUrl construction code for a URL expression.

This class encapsulates both the analysis of the URL expression structure (determining whether it can be statically decomposed) and the code emission. When the URL starts with a literal scheme prefix (https:// or http://) and the components (scheme, host, port, path) can be identified at codegen time then we eliminate runtime parsing and use EndpointUrl.fromComponents(). Otherwise, falls back to EndpointUrl.fromString() for runtime parsing.

The endpoint URL spec guarantees that URLs contain only scheme, host, optional port, and optional base path (no query or fragment). Dynamic (template based) resolution are only supported in the host and path segments in pre-parsing. Otherwise, we fall back to runtime parsing.

  • Method Details

    • emit

      public static void emit(RuleExpression urlExpr, com.squareup.javapoet.CodeBlock.Builder builder, RuleExpressionVisitor<?> visitor)
      Emit the optimal EndpointUrl construction code for the given URL expression.

      This overload accepts any RuleExpressionVisitor that emits code into the same builder, allowing both the standard CodeGeneratorVisitor and BDD visitors to share the same URL emission logic.