W
- Type of SymbolWriter
used to generate code.I
- Type of SmithyIntegration
to apply.C
- Type of CodegenContext
to create and use.S
- Type of settings object to pass to directed methods.public final class CodegenDirector<W extends SymbolWriter<W,? extends ImportContainer>,I extends SmithyIntegration<S,W,C>,C extends CodegenContext<S,W>,S>
extends java.lang.Object
DirectedCodegen
.Constructor and Description |
---|
CodegenDirector() |
Modifier and Type | Method and Description |
---|---|
void |
createDedicatedInputsAndOutputs()
Generates dedicated input and output shapes for every operation if the operation
doesn't already have them.
|
void |
createDedicatedInputsAndOutputs(java.lang.String inputSuffix,
java.lang.String outputSuffix)
Generates dedicated input and output shapes for every operation if the operation
doesn't already have them.
|
void |
directedCodegen(DirectedCodegen<C,S> directedCodegen)
Sets the required
DirectedCodegen implementation to invoke. |
void |
fileManifest(FileManifest fileManifest)
Sets the required file manifest used to write files to disk.
|
void |
integrationClass(java.lang.Class<I> integrationClass)
Sets the required class used for SmithyIntegrations.
|
void |
integrationClassLoader(java.lang.ClassLoader classLoader)
Sets a custom class loader for finding implementations of
SmithyIntegration . |
void |
integrationFinder(java.util.function.Supplier<java.lang.Iterable<I>> integrationFinder)
Sets a custom implementation for finding
SmithyIntegration s. |
void |
model(Model model)
Sets the required model to generate from.
|
void |
performDefaultCodegenTransforms()
Set to true to apply
simplifyModelForServiceCodegen(software.amazon.smithy.model.Model, software.amazon.smithy.model.shapes.ShapeId, software.amazon.smithy.model.transform.ModelTransformer)
prior to code generation. |
void |
run()
Finalizes the Runner and performs directed code generation.
|
void |
service(ShapeId service)
Sets the required service being generated.
|
S |
settings(java.lang.Class<S> settingsType,
Node settingsNode)
Sets the required settings object used for code generation using
a
Node . |
void |
settings(S settings)
Sets the required settings object used for code generation.
|
static Model |
simplifyModelForServiceCodegen(Model model,
ShapeId service,
ModelTransformer transformer)
Simplifies a Smithy model for code generation of a single service.
|
void |
sortMembers()
Sorts all members of the model prior to codegen.
|
public static Model simplifyModelForServiceCodegen(Model model, ShapeId service, ModelTransformer transformer)
Note: This transform is applied automatically by a code
generator if performDefaultCodegenTransforms()
is
set to true.
model
- Model being code generated.service
- Service being generated.transformer
- Model transformer to use.public void integrationClass(java.lang.Class<I> integrationClass)
integrationClass
- SmithyIntegration class.public void service(ShapeId service)
service
- Service to generate.public void directedCodegen(DirectedCodegen<C,S> directedCodegen)
DirectedCodegen
implementation to invoke.directedCodegen
- Directed code generator to run.public void model(Model model)
model
- Model to generate from.public void settings(S settings)
settings
- Settings object.public S settings(java.lang.Class<S> settingsType, Node settingsNode)
Node
.
A Node value is used by Smithy-Build plugins to configure settings.
This method is a helper method that uses Smithy's fairly simple
object-mapper to deserialize a node into the desired settings type.
You will need to manually deserialize your settings if using types that
are not supported by Smithy's NodeMapper
.
settingsType
- Settings type to deserialize into.settingsNode
- Settings node value to deserialize.public void fileManifest(FileManifest fileManifest)
fileManifest
- File manifest to write files.public void integrationFinder(java.util.function.Supplier<java.lang.Iterable<I>> integrationFinder)
SmithyIntegration
s.
Most implementations can use integrationClassLoader(ClassLoader)
.
integrationFinder
- Smithy integration finder.public void integrationClassLoader(java.lang.ClassLoader classLoader)
SmithyIntegration
.classLoader
- Class loader to find integrations.* @return Returns self.public void performDefaultCodegenTransforms()
simplifyModelForServiceCodegen(software.amazon.smithy.model.Model, software.amazon.smithy.model.shapes.ShapeId, software.amazon.smithy.model.transform.ModelTransformer)
prior to code generation.public void createDedicatedInputsAndOutputs()
This method uses "Input" as the default suffix for input, and "Output" as the
default suffix for output shapes. Use createDedicatedInputsAndOutputs(String, String)
to use custom suffixes.
public void createDedicatedInputsAndOutputs(java.lang.String inputSuffix, java.lang.String outputSuffix)
inputSuffix
- Suffix to use for input shapes (e.g., "Input").outputSuffix
- Suffix to use for output shapes (e.g., "Output").ModelTransformer.createDedicatedInputAndOutput(Model, String, String)
public void sortMembers()
This should only be used by languages where changing the order of members in a structure or union is a backward compatible change (i.e., not C, C++, Rust, etc). Once this is performed, there's no need to ever explicitly sort members throughout the rest of code generation.
public void run()
java.lang.IllegalStateException
- if a required value has not been provided.