Class Directive<S>

java.lang.Object
software.amazon.smithy.codegen.core.directed.Directive<S>
Type Parameters:
S - Settings object used to configure code generation.
Direct Known Subclasses:
ContextualDirective, CreateContextDirective, CreateSymbolProviderDirective

public abstract class Directive<S> extends Object
Directive classes contain all of the context needed in order to perform the tasks defined in a DirectedCodegen implementation.
  • Method Details

    • model

      public final Model model()
      Returns:
      Gets the model being code generated.
    • settings

      public final S settings()
      Returns:
      Gets code generation settings.
    • service

      @Deprecated public final ServiceShape service()
      Deprecated.
      Use getService() to safely handle the absence of a service when code generation is driven by a shape closure.
      Gets the service being generated.
      Returns:
      Gets the service being generated.
      Throws:
      CodegenException - if there is no service because code generation is driven by a shape closure rather than a service.
    • getService

      public final Optional<ServiceShape> getService()
      Gets the service being generated, if code generation is driven by a service.
      Returns:
      Returns the optional service being generated.
    • expectService

      public final ServiceShape expectService()
      Gets the service being generated, failing if there is none.
      Returns:
      Returns the service being generated.
      Throws:
      CodegenException - if there is no service because code generation is driven by a shape closure rather than a service.
    • getShapeClosureId

      public final Optional<String> getShapeClosureId()
      Gets the ID of the shape closure being generated, if code generation is driven by a shape closure.
      Returns:
      Returns the optional shape closure ID being generated.
    • getRenames

      public final Map<ShapeId,String> getRenames()
      Gets the renames that apply to the shapes being generated.

      The renames mirror the generated set: when a shape closure is present (closure or combined mode) these are the closure's renames, otherwise they are the primary service's renames. Each key is the id of a shape being generated and each value is the name, without a namespace, to use for that shape.

      Returns:
      Returns a map of shape id to replacement name, empty if none apply.
    • connectedShapes

      public final Map<ShapeId,Shape> connectedShapes()
      Returns a map of the shapes being generated.

      When driven by a service, these are the shapes connected to the service. When driven by a shape closure, these are the shapes in that closure. When only data shapes are being generated, service, resource, and operation shapes are excluded since they are not generated.

      Returns:
      Returns a map of shapes being generated.
    • operations

      public Set<OperationShape> operations()
      Gets a set of all operation shapes being generated, sorted by name.

      When driven by a service, this includes operations contained in resources in the closure of the service. When driven by a shape closure, this is the set of operation shapes in the closure. When only data shapes are being generated, no operations are generated and this is always empty.

      Returns:
      Returns all sorted operations being generated.