|
| 1 | +/* |
| 2 | + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +package software.amazon.smithy.typescript.codegen.sections; |
| 7 | + |
| 8 | +import java.util.List; |
| 9 | +import java.util.Optional; |
| 10 | +import software.amazon.smithy.codegen.core.SymbolProvider; |
| 11 | +import software.amazon.smithy.model.Model; |
| 12 | +import software.amazon.smithy.model.shapes.OperationShape; |
| 13 | +import software.amazon.smithy.model.shapes.ServiceShape; |
| 14 | +import software.amazon.smithy.typescript.codegen.ApplicationProtocol; |
| 15 | +import software.amazon.smithy.typescript.codegen.TypeScriptSettings; |
| 16 | +import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator; |
| 17 | +import software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin; |
| 18 | +import software.amazon.smithy.utils.CodeSection; |
| 19 | +import software.amazon.smithy.utils.SmithyBuilder; |
| 20 | +import software.amazon.smithy.utils.SmithyUnstableApi; |
| 21 | + |
| 22 | +@SmithyUnstableApi |
| 23 | +public final class PreCommandClassCodeSection implements CodeSection { |
| 24 | + private final TypeScriptSettings settings; |
| 25 | + private final Model model; |
| 26 | + private final ServiceShape service; |
| 27 | + private final OperationShape operation; |
| 28 | + private final SymbolProvider symbolProvider; |
| 29 | + private final List<RuntimeClientPlugin> runtimeClientPlugins; |
| 30 | + private final ProtocolGenerator protocolGenerator; |
| 31 | + private final ApplicationProtocol applicationProtocol; |
| 32 | + |
| 33 | + private PreCommandClassCodeSection(Builder builder) { |
| 34 | + settings = SmithyBuilder.requiredState("settings", builder.settings); |
| 35 | + model = SmithyBuilder.requiredState("model", builder.model); |
| 36 | + service = SmithyBuilder.requiredState("service", builder.service); |
| 37 | + operation = SmithyBuilder.requiredState("operation", builder.operation); |
| 38 | + symbolProvider = SmithyBuilder.requiredState("symbolProvider", builder.symbolProvider); |
| 39 | + runtimeClientPlugins = SmithyBuilder.requiredState("runtimeClientPlugins", builder.runtimeClientPlugins); |
| 40 | + protocolGenerator = builder.protocolGenerator; |
| 41 | + applicationProtocol = SmithyBuilder.requiredState("applicationProtocol", builder.applicationProtocol); |
| 42 | + } |
| 43 | + |
| 44 | + public static Builder builder() { |
| 45 | + return new Builder(); |
| 46 | + } |
| 47 | + |
| 48 | + public TypeScriptSettings getSettings() { |
| 49 | + return settings; |
| 50 | + } |
| 51 | + |
| 52 | + public Model getModel() { |
| 53 | + return model; |
| 54 | + } |
| 55 | + |
| 56 | + public ServiceShape getService() { |
| 57 | + return service; |
| 58 | + } |
| 59 | + |
| 60 | + public OperationShape getOperation() { |
| 61 | + return operation; |
| 62 | + } |
| 63 | + |
| 64 | + public SymbolProvider getSymbolProvider() { |
| 65 | + return symbolProvider; |
| 66 | + } |
| 67 | + |
| 68 | + public List<RuntimeClientPlugin> getRuntimeClientPlugins() { |
| 69 | + return runtimeClientPlugins; |
| 70 | + } |
| 71 | + |
| 72 | + public Optional<ProtocolGenerator> getProtocolGenerator() { |
| 73 | + return Optional.ofNullable(protocolGenerator); |
| 74 | + } |
| 75 | + |
| 76 | + public ApplicationProtocol getApplicationProtocol() { |
| 77 | + return applicationProtocol; |
| 78 | + } |
| 79 | + |
| 80 | + public static class Builder implements SmithyBuilder<PreCommandClassCodeSection> { |
| 81 | + private TypeScriptSettings settings; |
| 82 | + private Model model; |
| 83 | + private ServiceShape service; |
| 84 | + private OperationShape operation; |
| 85 | + private SymbolProvider symbolProvider; |
| 86 | + private List<RuntimeClientPlugin> runtimeClientPlugins; |
| 87 | + private ProtocolGenerator protocolGenerator; |
| 88 | + private ApplicationProtocol applicationProtocol; |
| 89 | + |
| 90 | + @Override |
| 91 | + public PreCommandClassCodeSection build() { |
| 92 | + return new PreCommandClassCodeSection(this); |
| 93 | + } |
| 94 | + |
| 95 | + public Builder settings(TypeScriptSettings settings) { |
| 96 | + this.settings = settings; |
| 97 | + return this; |
| 98 | + } |
| 99 | + |
| 100 | + public Builder model(Model model) { |
| 101 | + this.model = model; |
| 102 | + return this; |
| 103 | + } |
| 104 | + |
| 105 | + public Builder service(ServiceShape service) { |
| 106 | + this.service = service; |
| 107 | + return this; |
| 108 | + } |
| 109 | + |
| 110 | + public Builder operation(OperationShape operation) { |
| 111 | + this.operation = operation; |
| 112 | + return this; |
| 113 | + } |
| 114 | + |
| 115 | + public Builder symbolProvider(SymbolProvider symbolProvider) { |
| 116 | + this.symbolProvider = symbolProvider; |
| 117 | + return this; |
| 118 | + } |
| 119 | + |
| 120 | + public Builder runtimeClientPlugins(List<RuntimeClientPlugin> runtimeClientPlugins) { |
| 121 | + this.runtimeClientPlugins = runtimeClientPlugins; |
| 122 | + return this; |
| 123 | + } |
| 124 | + |
| 125 | + public Builder protocolGenerator(ProtocolGenerator protocolGenerator) { |
| 126 | + this.protocolGenerator = protocolGenerator; |
| 127 | + return this; |
| 128 | + } |
| 129 | + |
| 130 | + public Builder applicationProtocol(ApplicationProtocol applicationProtocol) { |
| 131 | + this.applicationProtocol = applicationProtocol; |
| 132 | + return this; |
| 133 | + } |
| 134 | + } |
| 135 | +} |
0 commit comments