|
8 | 8 | import software.amazon.smithy.aws.traits.ServiceTrait; |
9 | 9 |
|
10 | 10 | import java.util.Map; |
| 11 | +import java.util.Optional; |
11 | 12 |
|
12 | 13 | public final class ServiceNameUtil { |
13 | 14 |
|
@@ -170,12 +171,18 @@ public static String getExportMacro(ServiceShape service, Map<String, String> se |
170 | 171 | * Follows C2J convention: AWS_{UPPERCASED_SERVICE_NAME}_LOCAL |
171 | 172 | * |
172 | 173 | * @param service The service shape to generate the macro for |
173 | | - * @param serviceMap Service ID mappings for namespace overrides (reserved for future consistency with getSmithyServiceName) |
| 174 | + * @param serviceMap Service ID mappings, used to resolve the key into namespaceMap |
| 175 | + * @param namespaceMap Namespace overrides, keyed by smithy service name; the macro must follow the |
| 176 | + * override because the C2J-generated {@code <Prefix>_EXPORTS.h} defines it off |
| 177 | + * {@code metadata.classNamePrefix} |
174 | 178 | * @return The local macro in format AWS_{SERVICE_NAME}_LOCAL |
175 | 179 | */ |
176 | | - public static String getLocalMacro(ServiceShape service, Map<String, String> serviceMap) { |
177 | | - String serviceName = getServiceName(service); |
178 | | - return "AWS_" + serviceName.toUpperCase() + "_LOCAL"; |
| 180 | + public static String getLocalMacro(ServiceShape service, Map<String, String> serviceMap, |
| 181 | + Map<String, String> namespaceMap) { |
| 182 | + return Optional.ofNullable(namespaceMap.get(getSmithyServiceName(service, serviceMap))) |
| 183 | + .orElseGet(() -> getServiceName(service)) |
| 184 | + .toUpperCase() |
| 185 | + .transform(name -> "AWS_" + name + "_LOCAL"); |
179 | 186 | } |
180 | 187 |
|
181 | 188 | public static boolean isS3CrtProjection(ServiceShape service) { |
|
0 commit comments