private void serializeTrait(Trait trait) {
            Node node = trait.toNode();
            // We won't fail if the trait can't be found.
            Shape shape = model.getShape(trait.toShapeId()).orElse(null);

            if (shape != null && (trait instanceof AnnotationTrait || isEmptyStructure(node, shape))) {
                // Traits that inherit from AnnotationTrait specifically can omit a value.
                // Traits that are simply boolean shapes which don't implement AnnotationTrait cannot.
                // Additionally, empty structure traits can omit a value.
                codeWriter.write("@$I", trait.toShapeId());
            } else if (node.isObjectNode()) {
                codeWriter.writeIndent().openBlockInline("@$I(", trait.toShapeId());
                nodeSerializer.serializeKeyValuePairs(node.expectObjectNode(), shape);
                codeWriter.closeBlock(")");
            } else {
                codeWriter.writeIndent().writeInline("@$I(", trait.toShapeId());
                nodeSerializer.serialize(node, shape);
                codeWriter.write(")");
            }
        }
Serializes shapes in the IDL format.
smithy-model/src/main/java/software/amazon/smithy/model/shapes/SmithyIdlModelSerializer.java