From a17478ec18855cd91325b94e2e45c9b8befedf37 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Fri, 15 Mar 2024 08:58:20 -0700 Subject: [PATCH] Use map instead of isEmpty when writing shape docs (#1210) --- .../smithy/typescript/codegen/TypeScriptWriter.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptWriter.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptWriter.java index 0b37c181b40..b7cea6006c8 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptWriter.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/TypeScriptWriter.java @@ -190,10 +190,11 @@ boolean writeShapeDocs(Shape shape, UnaryOperator preprocessor) { .replace("}", "\\}"); docs = preprocessor.apply(docs); if (shape.getTrait(DeprecatedTrait.class).isPresent()) { - DeprecatedTrait deprecatedTrait = shape.getTrait(DeprecatedTrait.class).get(); - String deprecationMessage = deprecatedTrait.getMessage().orElse(""); - String deprecationString = "@deprecated" - + (deprecationMessage.isEmpty() ? "" : " " + deprecationMessage); + DeprecatedTrait deprecatedTrait = shape.expectTrait(DeprecatedTrait.class); + String deprecationMessage = deprecatedTrait.getMessage() + .map(msg -> " " + msg) + .orElse(""); + String deprecationString = "@deprecated" + deprecationMessage; docs = deprecationString + "\n\n" + docs; } docs = addReleaseTag(shape, docs);